MCPcopy Create free account
hub / github.com/angular/angular / parseCallChain

Method parseCallChain

packages/compiler/src/expression_parser/parser.ts:1107–1146  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1105 }
1106
1107 private parseCallChain(): AST {
1108 const start = this.inputIndex;
1109 let result = this.parsePrimary();
1110 while (true) {
1111 if (this.consumeOptionalCharacter(chars.$PERIOD)) {
1112 result = this.parseAccessMember(result, start, false);
1113 } else if (this.consumeOptionalOperator('?.')) {
1114 if (this.consumeOptionalCharacter(chars.$LPAREN)) {
1115 result = this.parseCall(result, start, true);
1116 } else {
1117 result = this.consumeOptionalCharacter(chars.$LBRACKET)
1118 ? this.parseKeyedReadOrWrite(result, start, true)
1119 : this.parseAccessMember(result, start, true);
1120 }
1121 } else if (this.consumeOptionalCharacter(chars.$LBRACKET)) {
1122 result = this.parseKeyedReadOrWrite(result, start, false);
1123 } else if (this.consumeOptionalCharacter(chars.$LPAREN)) {
1124 result = this.parseCall(result, start, false);
1125 } else if (this.consumeOptionalOperator('!')) {
1126 result = new NonNullAssert(this.span(start), this.sourceSpan(start), result);
1127 } else if (this.next.isTemplateLiteralEnd()) {
1128 result = this.parseNoInterpolationTaggedTemplateLiteral(result, start);
1129 } else if (this.next.isTemplateLiteralPart()) {
1130 result = this.parseTaggedTemplateLiteral(result, start);
1131 } else {
1132 break;
1133 }
1134 }
1135
1136 if (this.next.isOperator('++') || this.next.isOperator('--')) {
1137 // Note: we need to capture this here before we advance.
1138 const operator = this.next.strValue as '++' | '--';
1139 this.advance();
1140 return this.validateIncrementDecrementTarget(result)
1141 ? Unary.createPostfixUpdate(this.span(start), this.sourceSpan(start), operator, result)
1142 : new EmptyExpr(this.span(start), this.sourceSpan(start));
1143 }
1144
1145 return result;
1146 }
1147
1148 private parsePrimary(): AST {
1149 const start = this.inputIndex;

Callers 1

parsePrefixMethod · 0.95

Calls 15

parsePrimaryMethod · 0.95
parseAccessMemberMethod · 0.95
parseCallMethod · 0.95
parseKeyedReadOrWriteMethod · 0.95
spanMethod · 0.95
sourceSpanMethod · 0.95
advanceMethod · 0.95

Tested by

no test coverage detected