OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express |
11 * or implied. See the License for the specific language governing permissions a nd limitations under | 11 * or implied. See the License for the specific language governing permissions a nd limitations under |
12 * the License. | 12 * the License. |
13 */ | 13 */ |
14 package com.google.dart.tools.core.utilities.ast; | 14 package com.google.dart.tools.core.utilities.ast; |
15 | 15 |
16 import com.google.common.base.Objects; | 16 import com.google.common.base.Objects; |
17 import com.google.dart.compiler.DartSource; | 17 import com.google.dart.compiler.DartSource; |
18 import com.google.dart.compiler.LibrarySource; | 18 import com.google.dart.compiler.LibrarySource; |
19 import com.google.dart.compiler.ast.ASTVisitor; | 19 import com.google.dart.compiler.ast.ASTVisitor; |
20 import com.google.dart.compiler.ast.DartArrayAccess; | 20 import com.google.dart.compiler.ast.DartArrayAccess; |
21 import com.google.dart.compiler.ast.DartBinaryExpression; | 21 import com.google.dart.compiler.ast.DartBinaryExpression; |
22 import com.google.dart.compiler.ast.DartExpression; | 22 import com.google.dart.compiler.ast.DartExpression; |
23 import com.google.dart.compiler.ast.DartIdentifier; | 23 import com.google.dart.compiler.ast.DartIdentifier; |
24 import com.google.dart.compiler.ast.DartImportDirective; | 24 import com.google.dart.compiler.ast.DartImportDirective; |
25 import com.google.dart.compiler.ast.DartNode; | 25 import com.google.dart.compiler.ast.DartNode; |
26 import com.google.dart.compiler.ast.DartResourceDirective; | 26 import com.google.dart.compiler.ast.DartResourceDirective; |
27 import com.google.dart.compiler.ast.DartSourceDirective; | 27 import com.google.dart.compiler.ast.DartSourceDirective; |
28 import com.google.dart.compiler.ast.DartStringLiteral; | 28 import com.google.dart.compiler.ast.DartStringLiteral; |
29 import com.google.dart.compiler.ast.DartUnaryExpression; | 29 import com.google.dart.compiler.ast.DartUnaryExpression; |
30 import com.google.dart.compiler.ast.DartUnqualifiedInvocation; | |
30 import com.google.dart.compiler.resolver.Element; | 31 import com.google.dart.compiler.resolver.Element; |
31 import com.google.dart.compiler.resolver.ElementKind; | 32 import com.google.dart.compiler.resolver.ElementKind; |
32 import com.google.dart.compiler.resolver.LibraryElement; | 33 import com.google.dart.compiler.resolver.LibraryElement; |
34 import com.google.dart.compiler.resolver.NodeElement; | |
33 import com.google.dart.compiler.resolver.VariableElement; | 35 import com.google.dart.compiler.resolver.VariableElement; |
34 import com.google.dart.tools.core.DartCore; | 36 import com.google.dart.tools.core.DartCore; |
35 import com.google.dart.tools.core.internal.util.SourceRangeUtils; | 37 import com.google.dart.tools.core.internal.util.SourceRangeUtils; |
36 import com.google.dart.tools.core.model.CompilationUnit; | 38 import com.google.dart.tools.core.model.CompilationUnit; |
37 import com.google.dart.tools.core.model.DartElement; | 39 import com.google.dart.tools.core.model.DartElement; |
38 import com.google.dart.tools.core.model.DartImport; | 40 import com.google.dart.tools.core.model.DartImport; |
39 import com.google.dart.tools.core.model.DartLibrary; | 41 import com.google.dart.tools.core.model.DartLibrary; |
40 import com.google.dart.tools.core.model.DartModelException; | 42 import com.google.dart.tools.core.model.DartModelException; |
41 import com.google.dart.tools.core.model.DartResource; | 43 import com.google.dart.tools.core.model.DartResource; |
42 import com.google.dart.tools.core.model.SourceRange; | 44 import com.google.dart.tools.core.model.SourceRange; |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 DartExpression operand = node.getArg(); | 427 DartExpression operand = node.getArg(); |
426 wordRegion = computeOperatorRegion(start, operand.getSourceInfo().getOff set() - 1); | 428 wordRegion = computeOperatorRegion(start, operand.getSourceInfo().getOff set() - 1); |
427 Element targetSymbol = node.getElement(); | 429 Element targetSymbol = node.getElement(); |
428 findElementFor(targetSymbol); | 430 findElementFor(targetSymbol); |
429 throw new DartElementFoundException(); | 431 throw new DartElementFoundException(); |
430 } | 432 } |
431 } | 433 } |
432 return null; | 434 return null; |
433 } | 435 } |
434 | 436 |
437 @Override | |
438 public Void visitUnqualifiedInvocation(DartUnqualifiedInvocation node) { | |
439 super.visitUnqualifiedInvocation(node); | |
440 if (foundElement == null) { | |
Brian Wilkerson
2012/06/18 20:46:18
This doesn't test to ensure that the node is withi
| |
441 NodeElement invocationElement = node.getElement(); | |
442 if (invocationElement != null && node.getTarget() != null | |
443 && node.getTarget().getElement() != invocationElement) { | |
444 findElementFor(invocationElement); | |
445 } | |
446 } | |
447 return null; | |
448 } | |
449 | |
435 /** | 450 /** |
436 * Compute a region that represents the portion of the string literal between the opening and | 451 * Compute a region that represents the portion of the string literal between the opening and |
437 * closing quotes. | 452 * closing quotes. |
438 * | 453 * |
439 * @param nodeStart the index of the first character of the string literal | 454 * @param nodeStart the index of the first character of the string literal |
440 * @param nodeLength the length of the string literal (including quotes) | 455 * @param nodeLength the length of the string literal (including quotes) |
441 * @return the region that was computed | 456 * @return the region that was computed |
442 */ | 457 */ |
443 private IRegion computeInternalStringRegion(int nodeStart, int nodeLength) { | 458 private IRegion computeInternalStringRegion(int nodeStart, int nodeLength) { |
444 int start = nodeStart; | 459 int start = nodeStart; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 */ | 556 */ |
542 private String getFileName(DartLibrary library, String uri) { | 557 private String getFileName(DartLibrary library, String uri) { |
543 int index = uri.lastIndexOf('/'); | 558 int index = uri.lastIndexOf('/'); |
544 if (index >= 0) { | 559 if (index >= 0) { |
545 return uri.substring(index + 1); | 560 return uri.substring(index + 1); |
546 } | 561 } |
547 return uri; | 562 return uri; |
548 } | 563 } |
549 | 564 |
550 } | 565 } |
OLD | NEW |