Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartElementLocator.java

Issue 10582003: Issue 1355. Support for call(). Tweaks for element locator and rename refactoring (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Check target range Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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) {
441 int start = node.getSourceInfo().getOffset();
442 int length = node.getSourceInfo().getLength();
443 int end = start + length;
444 if (start <= startOffset && endOffset <= end) {
445 wordRegion = new Region(start, length);
446 NodeElement invocationElement = node.getElement();
447 if (invocationElement != null && node.getTarget() != null
448 && node.getTarget().getElement() != invocationElement) {
449 findElementFor(invocationElement);
450 }
451 }
452 }
453 return null;
454 }
455
435 /** 456 /**
436 * Compute a region that represents the portion of the string literal between the opening and 457 * Compute a region that represents the portion of the string literal between the opening and
437 * closing quotes. 458 * closing quotes.
438 * 459 *
439 * @param nodeStart the index of the first character of the string literal 460 * @param nodeStart the index of the first character of the string literal
440 * @param nodeLength the length of the string literal (including quotes) 461 * @param nodeLength the length of the string literal (including quotes)
441 * @return the region that was computed 462 * @return the region that was computed
442 */ 463 */
443 private IRegion computeInternalStringRegion(int nodeStart, int nodeLength) { 464 private IRegion computeInternalStringRegion(int nodeStart, int nodeLength) {
444 int start = nodeStart; 465 int start = nodeStart;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 */ 562 */
542 private String getFileName(DartLibrary library, String uri) { 563 private String getFileName(DartLibrary library, String uri) {
543 int index = uri.lastIndexOf('/'); 564 int index = uri.lastIndexOf('/');
544 if (index >= 0) { 565 if (index >= 0) {
545 return uri.substring(index + 1); 566 return uri.substring(index + 1);
546 } 567 }
547 return uri; 568 return uri;
548 } 569 }
549 570
550 } 571 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698