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

Side by Side Diff: dart/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/ResolutionCopierTest.java

Issue 56933002: Version 0.8.10.1 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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) 2013, the Dart project authors. 2 * Copyright (c) 2013, 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
(...skipping 11 matching lines...) Expand all
22 import com.google.dart.engine.ast.BooleanLiteral; 22 import com.google.dart.engine.ast.BooleanLiteral;
23 import com.google.dart.engine.ast.CascadeExpression; 23 import com.google.dart.engine.ast.CascadeExpression;
24 import com.google.dart.engine.ast.CompilationUnit; 24 import com.google.dart.engine.ast.CompilationUnit;
25 import com.google.dart.engine.ast.ConditionalExpression; 25 import com.google.dart.engine.ast.ConditionalExpression;
26 import com.google.dart.engine.ast.ConstructorDeclaration; 26 import com.google.dart.engine.ast.ConstructorDeclaration;
27 import com.google.dart.engine.ast.ConstructorName; 27 import com.google.dart.engine.ast.ConstructorName;
28 import com.google.dart.engine.ast.DoubleLiteral; 28 import com.google.dart.engine.ast.DoubleLiteral;
29 import com.google.dart.engine.ast.ExportDirective; 29 import com.google.dart.engine.ast.ExportDirective;
30 import com.google.dart.engine.ast.FunctionExpression; 30 import com.google.dart.engine.ast.FunctionExpression;
31 import com.google.dart.engine.ast.FunctionExpressionInvocation; 31 import com.google.dart.engine.ast.FunctionExpressionInvocation;
32 import com.google.dart.engine.ast.ImportDirective;
32 import com.google.dart.engine.ast.IndexExpression; 33 import com.google.dart.engine.ast.IndexExpression;
33 import com.google.dart.engine.ast.InstanceCreationExpression; 34 import com.google.dart.engine.ast.InstanceCreationExpression;
34 import com.google.dart.engine.ast.IntegerLiteral; 35 import com.google.dart.engine.ast.IntegerLiteral;
35 import com.google.dart.engine.ast.IsExpression; 36 import com.google.dart.engine.ast.IsExpression;
36 import com.google.dart.engine.ast.LibraryIdentifier; 37 import com.google.dart.engine.ast.LibraryIdentifier;
37 import com.google.dart.engine.ast.ListLiteral; 38 import com.google.dart.engine.ast.ListLiteral;
38 import com.google.dart.engine.ast.MapLiteral; 39 import com.google.dart.engine.ast.MapLiteral;
39 import com.google.dart.engine.ast.MethodInvocation; 40 import com.google.dart.engine.ast.MethodInvocation;
40 import com.google.dart.engine.ast.NamedExpression; 41 import com.google.dart.engine.ast.NamedExpression;
41 import com.google.dart.engine.ast.NullLiteral; 42 import com.google.dart.engine.ast.NullLiteral;
(...skipping 11 matching lines...) Expand all
53 import com.google.dart.engine.ast.StringInterpolation; 54 import com.google.dart.engine.ast.StringInterpolation;
54 import com.google.dart.engine.ast.SuperConstructorInvocation; 55 import com.google.dart.engine.ast.SuperConstructorInvocation;
55 import com.google.dart.engine.ast.SuperExpression; 56 import com.google.dart.engine.ast.SuperExpression;
56 import com.google.dart.engine.ast.SymbolLiteral; 57 import com.google.dart.engine.ast.SymbolLiteral;
57 import com.google.dart.engine.ast.ThisExpression; 58 import com.google.dart.engine.ast.ThisExpression;
58 import com.google.dart.engine.ast.ThrowExpression; 59 import com.google.dart.engine.ast.ThrowExpression;
59 import com.google.dart.engine.ast.TypeName; 60 import com.google.dart.engine.ast.TypeName;
60 import com.google.dart.engine.element.CompilationUnitElement; 61 import com.google.dart.engine.element.CompilationUnitElement;
61 import com.google.dart.engine.element.ConstructorElement; 62 import com.google.dart.engine.element.ConstructorElement;
62 import com.google.dart.engine.element.Element; 63 import com.google.dart.engine.element.Element;
64 import com.google.dart.engine.element.ExportElement;
65 import com.google.dart.engine.element.ImportElement;
63 import com.google.dart.engine.element.LibraryElement; 66 import com.google.dart.engine.element.LibraryElement;
64 import com.google.dart.engine.element.MethodElement; 67 import com.google.dart.engine.element.MethodElement;
65 import com.google.dart.engine.internal.element.AuxiliaryElements; 68 import com.google.dart.engine.internal.element.AuxiliaryElements;
66 import com.google.dart.engine.internal.element.CompilationUnitElementImpl; 69 import com.google.dart.engine.internal.element.CompilationUnitElementImpl;
70 import com.google.dart.engine.internal.element.ExportElementImpl;
71 import com.google.dart.engine.internal.element.ImportElementImpl;
67 import com.google.dart.engine.internal.element.LibraryElementImpl; 72 import com.google.dart.engine.internal.element.LibraryElementImpl;
68 import com.google.dart.engine.scanner.Keyword; 73 import com.google.dart.engine.scanner.Keyword;
69 import com.google.dart.engine.scanner.TokenType; 74 import com.google.dart.engine.scanner.TokenType;
70 import com.google.dart.engine.type.Type; 75 import com.google.dart.engine.type.Type;
71 76
72 import static com.google.dart.engine.ast.ASTFactory.annotation; 77 import static com.google.dart.engine.ast.ASTFactory.annotation;
73 import static com.google.dart.engine.ast.ASTFactory.argumentDefinitionTest; 78 import static com.google.dart.engine.ast.ASTFactory.argumentDefinitionTest;
74 import static com.google.dart.engine.ast.ASTFactory.asExpression; 79 import static com.google.dart.engine.ast.ASTFactory.asExpression;
75 import static com.google.dart.engine.ast.ASTFactory.assignmentExpression; 80 import static com.google.dart.engine.ast.ASTFactory.assignmentExpression;
76 import static com.google.dart.engine.ast.ASTFactory.binaryExpression; 81 import static com.google.dart.engine.ast.ASTFactory.binaryExpression;
77 import static com.google.dart.engine.ast.ASTFactory.booleanLiteral; 82 import static com.google.dart.engine.ast.ASTFactory.booleanLiteral;
78 import static com.google.dart.engine.ast.ASTFactory.cascadeExpression; 83 import static com.google.dart.engine.ast.ASTFactory.cascadeExpression;
79 import static com.google.dart.engine.ast.ASTFactory.compilationUnit; 84 import static com.google.dart.engine.ast.ASTFactory.compilationUnit;
80 import static com.google.dart.engine.ast.ASTFactory.conditionalExpression; 85 import static com.google.dart.engine.ast.ASTFactory.conditionalExpression;
81 import static com.google.dart.engine.ast.ASTFactory.constructorDeclaration; 86 import static com.google.dart.engine.ast.ASTFactory.constructorDeclaration;
82 import static com.google.dart.engine.ast.ASTFactory.constructorName; 87 import static com.google.dart.engine.ast.ASTFactory.constructorName;
83 import static com.google.dart.engine.ast.ASTFactory.doubleLiteral; 88 import static com.google.dart.engine.ast.ASTFactory.doubleLiteral;
84 import static com.google.dart.engine.ast.ASTFactory.emptyFunctionBody; 89 import static com.google.dart.engine.ast.ASTFactory.emptyFunctionBody;
85 import static com.google.dart.engine.ast.ASTFactory.exportDirective; 90 import static com.google.dart.engine.ast.ASTFactory.exportDirective;
86 import static com.google.dart.engine.ast.ASTFactory.formalParameterList; 91 import static com.google.dart.engine.ast.ASTFactory.formalParameterList;
87 import static com.google.dart.engine.ast.ASTFactory.functionExpression; 92 import static com.google.dart.engine.ast.ASTFactory.functionExpression;
88 import static com.google.dart.engine.ast.ASTFactory.functionExpressionInvocation ; 93 import static com.google.dart.engine.ast.ASTFactory.functionExpressionInvocation ;
89 import static com.google.dart.engine.ast.ASTFactory.identifier; 94 import static com.google.dart.engine.ast.ASTFactory.identifier;
95 import static com.google.dart.engine.ast.ASTFactory.importDirective;
90 import static com.google.dart.engine.ast.ASTFactory.indexExpression; 96 import static com.google.dart.engine.ast.ASTFactory.indexExpression;
91 import static com.google.dart.engine.ast.ASTFactory.instanceCreationExpression; 97 import static com.google.dart.engine.ast.ASTFactory.instanceCreationExpression;
92 import static com.google.dart.engine.ast.ASTFactory.integer; 98 import static com.google.dart.engine.ast.ASTFactory.integer;
93 import static com.google.dart.engine.ast.ASTFactory.interpolationString; 99 import static com.google.dart.engine.ast.ASTFactory.interpolationString;
94 import static com.google.dart.engine.ast.ASTFactory.isExpression; 100 import static com.google.dart.engine.ast.ASTFactory.isExpression;
95 import static com.google.dart.engine.ast.ASTFactory.libraryIdentifier; 101 import static com.google.dart.engine.ast.ASTFactory.libraryIdentifier;
96 import static com.google.dart.engine.ast.ASTFactory.listLiteral; 102 import static com.google.dart.engine.ast.ASTFactory.listLiteral;
97 import static com.google.dart.engine.ast.ASTFactory.mapLiteral; 103 import static com.google.dart.engine.ast.ASTFactory.mapLiteral;
98 import static com.google.dart.engine.ast.ASTFactory.methodInvocation; 104 import static com.google.dart.engine.ast.ASTFactory.methodInvocation;
99 import static com.google.dart.engine.ast.ASTFactory.namedExpression; 105 import static com.google.dart.engine.ast.ASTFactory.namedExpression;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 fromNode.setStaticType(staticType); 300 fromNode.setStaticType(staticType);
295 DoubleLiteral toNode = doubleLiteral(1.0); 301 DoubleLiteral toNode = doubleLiteral(1.0);
296 302
297 ResolutionCopier.copyResolutionData(fromNode, toNode); 303 ResolutionCopier.copyResolutionData(fromNode, toNode);
298 assertSame(propagatedType, toNode.getPropagatedType()); 304 assertSame(propagatedType, toNode.getPropagatedType());
299 assertSame(staticType, toNode.getStaticType()); 305 assertSame(staticType, toNode.getStaticType());
300 } 306 }
301 307
302 public void test_visitExportDirective() { 308 public void test_visitExportDirective() {
303 ExportDirective fromNode = exportDirective("dart:uri"); 309 ExportDirective fromNode = exportDirective("dart:uri");
304 LibraryElement element = new LibraryElementImpl(null, libraryIdentifier("lib ")); 310 ExportElement element = new ExportElementImpl();
305 fromNode.setElement(element); 311 fromNode.setElement(element);
306 ExportDirective toNode = exportDirective("dart:uri"); 312 ExportDirective toNode = exportDirective("dart:uri");
307 313
308 ResolutionCopier.copyResolutionData(fromNode, toNode); 314 ResolutionCopier.copyResolutionData(fromNode, toNode);
309 assertSame(element, toNode.getElement()); 315 assertSame(element, toNode.getElement());
310 } 316 }
311 317
312 public void test_visitFunctionExpression() { 318 public void test_visitFunctionExpression() {
313 FunctionExpression fromNode = functionExpression(formalParameterList(), empt yFunctionBody()); 319 FunctionExpression fromNode = functionExpression(formalParameterList(), empt yFunctionBody());
314 MethodElement element = methodElement("m", classElement("C").getType()); 320 MethodElement element = methodElement("m", classElement("C").getType());
(...skipping 22 matching lines...) Expand all
337 fromNode.setStaticType(staticType); 343 fromNode.setStaticType(staticType);
338 FunctionExpressionInvocation toNode = functionExpressionInvocation(identifie r("f")); 344 FunctionExpressionInvocation toNode = functionExpressionInvocation(identifie r("f"));
339 345
340 ResolutionCopier.copyResolutionData(fromNode, toNode); 346 ResolutionCopier.copyResolutionData(fromNode, toNode);
341 assertSame(propagatedElement, toNode.getPropagatedElement()); 347 assertSame(propagatedElement, toNode.getPropagatedElement());
342 assertSame(propagatedType, toNode.getPropagatedType()); 348 assertSame(propagatedType, toNode.getPropagatedType());
343 assertSame(staticElement, toNode.getStaticElement()); 349 assertSame(staticElement, toNode.getStaticElement());
344 assertSame(staticType, toNode.getStaticType()); 350 assertSame(staticType, toNode.getStaticType());
345 } 351 }
346 352
353 public void test_visitImportDirective() {
354 ImportDirective fromNode = importDirective("dart:uri", null);
355 ImportElement element = new ImportElementImpl();
356 fromNode.setElement(element);
357 ImportDirective toNode = importDirective("dart:uri", null);
358
359 ResolutionCopier.copyResolutionData(fromNode, toNode);
360 assertSame(element, toNode.getElement());
361 }
362
347 public void test_visitIndexExpression() { 363 public void test_visitIndexExpression() {
348 IndexExpression fromNode = indexExpression(identifier("a"), integer(0L)); 364 IndexExpression fromNode = indexExpression(identifier("a"), integer(0L));
349 MethodElement propagatedElement = methodElement("m", classElement("C").getTy pe()); 365 MethodElement propagatedElement = methodElement("m", classElement("C").getTy pe());
350 MethodElement staticElement = methodElement("m", classElement("C").getType() ); 366 MethodElement staticElement = methodElement("m", classElement("C").getType() );
351 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(staticElement, p ropagatedElement); 367 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(staticElement, p ropagatedElement);
352 fromNode.setAuxiliaryElements(auxiliaryElements); 368 fromNode.setAuxiliaryElements(auxiliaryElements);
353 fromNode.setPropagatedElement(propagatedElement); 369 fromNode.setPropagatedElement(propagatedElement);
354 Type propagatedType = classElement("C").getType(); 370 Type propagatedType = classElement("C").getType();
355 fromNode.setPropagatedType(propagatedType); 371 fromNode.setPropagatedType(propagatedType);
356 fromNode.setStaticElement(staticElement); 372 fromNode.setStaticElement(staticElement);
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 public void test_visitTypeName() { 736 public void test_visitTypeName() {
721 TypeName fromNode = typeName("C"); 737 TypeName fromNode = typeName("C");
722 Type type = classElement("C").getType(); 738 Type type = classElement("C").getType();
723 fromNode.setType(type); 739 fromNode.setType(type);
724 TypeName toNode = typeName("C"); 740 TypeName toNode = typeName("C");
725 741
726 ResolutionCopier.copyResolutionData(fromNode, toNode); 742 ResolutionCopier.copyResolutionData(fromNode, toNode);
727 assertSame(type, toNode.getType()); 743 assertSame(type, toNode.getType());
728 } 744 }
729 } 745 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698