| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 | 3 |
| 4 library engine.parser; | 4 library engine.parser; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
| 8 import 'instrumentation.dart'; | 8 import 'instrumentation.dart'; |
| 9 import 'error.dart'; | 9 import 'error.dart'; |
| 10 import 'source.dart'; | 10 import 'source.dart'; |
| 11 import 'scanner.dart'; | 11 import 'scanner.dart'; |
| 12 import 'ast.dart'; | 12 import 'ast.dart'; |
| 13 import 'utilities_dart.dart'; | 13 import 'utilities_dart.dart'; |
| 14 import 'engine.dart' show AnalysisEngine; | 14 import 'engine.dart' show AnalysisEngine; |
| 15 import 'utilities_collection.dart' show TokenMap; | 15 import 'utilities_collection.dart' show TokenMap; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Instances of the class `CommentAndMetadata` implement a simple data-holder fo
r a method | 18 * Instances of the class `CommentAndMetadata` implement a simple data-holder fo
r a method |
| 19 * that needs to return multiple values. | 19 * that needs to return multiple values. |
| 20 * | 20 * |
| 21 * @coverage dart.engine.parser | 21 * @coverage dart.engine.parser |
| 22 */ | 22 */ |
| 23 class CommentAndMetadata { | 23 class CommentAndMetadata { |
| 24 /** | 24 /** |
| 25 * The documentation comment that was parsed, or `null` if none was given. | 25 * The documentation comment that was parsed, or `null` if none was given. |
| 26 */ | 26 */ |
| 27 Comment comment; | 27 final Comment comment; |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * The metadata that was parsed. | 30 * The metadata that was parsed. |
| 31 */ | 31 */ |
| 32 List<Annotation> metadata; | 32 final List<Annotation> metadata; |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * Initialize a newly created holder with the given data. | 35 * Initialize a newly created holder with the given data. |
| 36 * | 36 * |
| 37 * @param comment the documentation comment that was parsed | 37 * @param comment the documentation comment that was parsed |
| 38 * @param metadata the metadata that was parsed | 38 * @param metadata the metadata that was parsed |
| 39 */ | 39 */ |
| 40 CommentAndMetadata(Comment comment, List<Annotation> metadata) { | 40 CommentAndMetadata(this.comment, this.metadata); |
| 41 this.comment = comment; | |
| 42 this.metadata = metadata; | |
| 43 } | |
| 44 } | 41 } |
| 45 | 42 |
| 46 /** | 43 /** |
| 47 * Instances of the class `FinalConstVarOrType` implement a simple data-holder f
or a method | 44 * Instances of the class `FinalConstVarOrType` implement a simple data-holder f
or a method |
| 48 * that needs to return multiple values. | 45 * that needs to return multiple values. |
| 49 * | 46 * |
| 50 * @coverage dart.engine.parser | 47 * @coverage dart.engine.parser |
| 51 */ | 48 */ |
| 52 class FinalConstVarOrType { | 49 class FinalConstVarOrType { |
| 53 /** | 50 /** |
| 54 * The 'final', 'const' or 'var' keyword, or `null` if none was given. | 51 * The 'final', 'const' or 'var' keyword, or `null` if none was given. |
| 55 */ | 52 */ |
| 56 Token keyword; | 53 final Token keyword; |
| 57 | 54 |
| 58 /** | 55 /** |
| 59 * The type, of `null` if no type was specified. | 56 * The type, of `null` if no type was specified. |
| 60 */ | 57 */ |
| 61 TypeName type; | 58 final TypeName type; |
| 62 | 59 |
| 63 /** | 60 /** |
| 64 * Initialize a newly created holder with the given data. | 61 * Initialize a newly created holder with the given data. |
| 65 * | 62 * |
| 66 * @param keyword the 'final', 'const' or 'var' keyword | 63 * @param keyword the 'final', 'const' or 'var' keyword |
| 67 * @param type the type | 64 * @param type the type |
| 68 */ | 65 */ |
| 69 FinalConstVarOrType(Token keyword, TypeName type) { | 66 FinalConstVarOrType(this.keyword, this.type); |
| 70 this.keyword = keyword; | |
| 71 this.type = type; | |
| 72 } | |
| 73 } | 67 } |
| 74 | 68 |
| 75 /** | 69 /** |
| 76 * Instances of the class `Modifiers` implement a simple data-holder for a metho
d that needs | 70 * Instances of the class `Modifiers` implement a simple data-holder for a metho
d that needs |
| 77 * to return multiple values. | 71 * to return multiple values. |
| 78 * | 72 * |
| 79 * @coverage dart.engine.parser | 73 * @coverage dart.engine.parser |
| 80 */ | 74 */ |
| 81 class Modifiers { | 75 class Modifiers { |
| 82 /** | 76 /** |
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 * A map from old tokens to new tokens used during the cloning process. | 1135 * A map from old tokens to new tokens used during the cloning process. |
| 1142 */ | 1136 */ |
| 1143 TokenMap _tokenMap; | 1137 TokenMap _tokenMap; |
| 1144 | 1138 |
| 1145 /** | 1139 /** |
| 1146 * The error listener that will be informed of any errors that are found durin
g the parse. | 1140 * The error listener that will be informed of any errors that are found durin
g the parse. |
| 1147 */ | 1141 */ |
| 1148 AnalysisErrorListener _errorListener; | 1142 AnalysisErrorListener _errorListener; |
| 1149 | 1143 |
| 1150 /** | 1144 /** |
| 1145 * The node in the AST structure that contains the revised content. |
| 1146 */ |
| 1147 ASTNode _updatedNode; |
| 1148 |
| 1149 /** |
| 1151 * Initialize a newly created incremental parser to parse a portion of the con
tent of the given | 1150 * Initialize a newly created incremental parser to parse a portion of the con
tent of the given |
| 1152 * source. | 1151 * source. |
| 1153 * | 1152 * |
| 1154 * @param source the source being parsed | 1153 * @param source the source being parsed |
| 1155 * @param tokenMap a map from old tokens to new tokens used during the cloning
process | 1154 * @param tokenMap a map from old tokens to new tokens used during the cloning
process |
| 1156 * @param errorListener the error listener that will be informed of any errors
that are found | 1155 * @param errorListener the error listener that will be informed of any errors
that are found |
| 1157 * during the parse | 1156 * during the parse |
| 1158 */ | 1157 */ |
| 1159 IncrementalParser(Source source, TokenMap tokenMap, AnalysisErrorListener erro
rListener) { | 1158 IncrementalParser(Source source, TokenMap tokenMap, AnalysisErrorListener erro
rListener) { |
| 1160 this._source = source; | 1159 this._source = source; |
| 1161 this._tokenMap = tokenMap; | 1160 this._tokenMap = tokenMap; |
| 1162 this._errorListener = errorListener; | 1161 this._errorListener = errorListener; |
| 1163 } | 1162 } |
| 1164 | 1163 |
| 1165 /** | 1164 /** |
| 1165 * Return the node in the AST structure that contains the revised content. |
| 1166 * |
| 1167 * @return the updated node |
| 1168 */ |
| 1169 ASTNode get updatedNode => _updatedNode; |
| 1170 |
| 1171 /** |
| 1166 * Given a range of tokens that were re-scanned, re-parse the minimum number o
f tokens to produce | 1172 * Given a range of tokens that were re-scanned, re-parse the minimum number o
f tokens to produce |
| 1167 * a consistent AST structure. The range is represented by the first and last
tokens in the range. | 1173 * a consistent AST structure. The range is represented by the first and last
tokens in the range. |
| 1168 * The tokens are assumed to be contained in the same token stream. | 1174 * The tokens are assumed to be contained in the same token stream. |
| 1169 * | 1175 * |
| 1170 * @param leftToken the token in the new token stream immediately to the left
of the range of | 1176 * @param leftToken the token in the new token stream immediately to the left
of the range of |
| 1171 * tokens that were inserted | 1177 * tokens that were inserted |
| 1172 * @param rightToken the token in the new token stream immediately to the righ
t of the range of | 1178 * @param rightToken the token in the new token stream immediately to the righ
t of the range of |
| 1173 * tokens that were inserted | 1179 * tokens that were inserted |
| 1174 * @param originalStart the offset in the original source of the first charact
er that was modified | 1180 * @param originalStart the offset in the original source of the first charact
er that was modified |
| 1175 * @param originalEnd the offset in the original source of the last character
that was modified | 1181 * @param originalEnd the offset in the original source of the last character
that was modified |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 return null; | 1220 return null; |
| 1215 } | 1221 } |
| 1216 if (advanceToParent) { | 1222 if (advanceToParent) { |
| 1217 newNode = null; | 1223 newNode = null; |
| 1218 oldNode = parent; | 1224 oldNode = parent; |
| 1219 originalOffset = oldNode.offset; | 1225 originalOffset = oldNode.offset; |
| 1220 parseToken = findTokenAt(parseToken, originalOffset); | 1226 parseToken = findTokenAt(parseToken, originalOffset); |
| 1221 parser.currentToken = parseToken; | 1227 parser.currentToken = parseToken; |
| 1222 } | 1228 } |
| 1223 } | 1229 } |
| 1230 _updatedNode = newNode; |
| 1224 if (identical(oldNode, originalStructure)) { | 1231 if (identical(oldNode, originalStructure)) { |
| 1225 ResolutionCopier.copyResolutionData(oldNode, newNode); | 1232 ResolutionCopier.copyResolutionData(oldNode, newNode); |
| 1226 return newNode as ASTNode; | 1233 return newNode as ASTNode; |
| 1227 } | 1234 } |
| 1228 ResolutionCopier.copyResolutionData(oldNode, newNode); | 1235 ResolutionCopier.copyResolutionData(oldNode, newNode); |
| 1229 IncrementalASTCloner cloner = new IncrementalASTCloner(oldNode, newNode, _to
kenMap); | 1236 IncrementalASTCloner cloner = new IncrementalASTCloner(oldNode, newNode, _to
kenMap); |
| 1230 return originalStructure.accept(cloner) as ASTNode; | 1237 return originalStructure.accept(cloner) as ASTNode; |
| 1231 } | 1238 } |
| 1232 | 1239 |
| 1233 /** | 1240 /** |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1248 * no such token. | 1255 * no such token. |
| 1249 * | 1256 * |
| 1250 * @param firstToken the token from which the search is to begin | 1257 * @param firstToken the token from which the search is to begin |
| 1251 * @param offset the offset of the token to be returned | 1258 * @param offset the offset of the token to be returned |
| 1252 * @return the token with the given offset | 1259 * @return the token with the given offset |
| 1253 */ | 1260 */ |
| 1254 Token findTokenAt(Token firstToken, int offset) { | 1261 Token findTokenAt(Token firstToken, int offset) { |
| 1255 while (firstToken.offset > offset && firstToken.type != TokenType.EOF) { | 1262 while (firstToken.offset > offset && firstToken.type != TokenType.EOF) { |
| 1256 firstToken = firstToken.previous; | 1263 firstToken = firstToken.previous; |
| 1257 } | 1264 } |
| 1258 if (firstToken.offset == offset) { | 1265 return firstToken; |
| 1259 return firstToken; | |
| 1260 } | |
| 1261 return null; | |
| 1262 } | 1266 } |
| 1263 } | 1267 } |
| 1264 | 1268 |
| 1265 /** | 1269 /** |
| 1266 * Instances of the class `InsufficientContextException` represent a situation i
n which an AST | 1270 * Instances of the class `InsufficientContextException` represent a situation i
n which an AST |
| 1267 * node cannot be re-parsed because there is not enough context to know how to r
e-parse the node. | 1271 * node cannot be re-parsed because there is not enough context to know how to r
e-parse the node. |
| 1268 * Clients can attempt to re-parse the parent of the node. | 1272 * Clients can attempt to re-parse the parent of the node. |
| 1269 */ | 1273 */ |
| 1270 class InsufficientContextException extends IncrementalParseException { | 1274 class InsufficientContextException extends IncrementalParseException { |
| 1271 /** | 1275 /** |
| (...skipping 8020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9292 if ("\n" == separator) { | 9296 if ("\n" == separator) { |
| 9293 _writer.print("\n"); | 9297 _writer.print("\n"); |
| 9294 indent(); | 9298 indent(); |
| 9295 } else if (i > 0) { | 9299 } else if (i > 0) { |
| 9296 _writer.print(separator); | 9300 _writer.print(separator); |
| 9297 } | 9301 } |
| 9298 _writer.print(tokens[i].lexeme); | 9302 _writer.print(tokens[i].lexeme); |
| 9299 } | 9303 } |
| 9300 } | 9304 } |
| 9301 } | 9305 } |
| OLD | NEW |