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

Side by Side Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/context/AnalysisContextImplTest.java

Issue 214603014: Trunk CL for r=34540 (Closed) Base URL: https://dart.googlecode.com/svn/trunk/dart
Patch Set: Created 6 years, 8 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
« no previous file with comments | « editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/task/ParseHtmlTask.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.engine.internal.context; 14 package com.google.dart.engine.internal.context;
15 15
16 import com.google.dart.engine.EngineTestCase; 16 import com.google.dart.engine.EngineTestCase;
17 import com.google.dart.engine.ast.CompilationUnit; 17 import com.google.dart.engine.ast.CompilationUnit;
18 import com.google.dart.engine.ast.ImportDirective;
18 import com.google.dart.engine.ast.SimpleIdentifier; 19 import com.google.dart.engine.ast.SimpleIdentifier;
19 import com.google.dart.engine.ast.TopLevelVariableDeclaration; 20 import com.google.dart.engine.ast.TopLevelVariableDeclaration;
20 import com.google.dart.engine.context.AnalysisContextFactory; 21 import com.google.dart.engine.context.AnalysisContextFactory;
21 import com.google.dart.engine.context.AnalysisException; 22 import com.google.dart.engine.context.AnalysisException;
22 import com.google.dart.engine.context.AnalysisOptions; 23 import com.google.dart.engine.context.AnalysisOptions;
23 import com.google.dart.engine.context.ChangeNotice; 24 import com.google.dart.engine.context.ChangeNotice;
24 import com.google.dart.engine.context.ChangeSet; 25 import com.google.dart.engine.context.ChangeSet;
25 import com.google.dart.engine.element.ClassElement; 26 import com.google.dart.engine.element.ClassElement;
26 import com.google.dart.engine.element.CompilationUnitElement; 27 import com.google.dart.engine.element.CompilationUnitElement;
27 import com.google.dart.engine.element.Element; 28 import com.google.dart.engine.element.Element;
28 import com.google.dart.engine.element.ElementLocation; 29 import com.google.dart.engine.element.ElementLocation;
29 import com.google.dart.engine.element.HtmlElement; 30 import com.google.dart.engine.element.HtmlElement;
30 import com.google.dart.engine.element.LibraryElement; 31 import com.google.dart.engine.element.LibraryElement;
31 import com.google.dart.engine.element.PropertyAccessorElement; 32 import com.google.dart.engine.element.PropertyAccessorElement;
32 import com.google.dart.engine.error.AnalysisError; 33 import com.google.dart.engine.error.AnalysisError;
34 import com.google.dart.engine.html.ast.HtmlScriptTagNode;
33 import com.google.dart.engine.html.ast.HtmlUnit; 35 import com.google.dart.engine.html.ast.HtmlUnit;
36 import com.google.dart.engine.html.ast.XmlTagNode;
34 import com.google.dart.engine.internal.cache.DartEntry; 37 import com.google.dart.engine.internal.cache.DartEntry;
35 import com.google.dart.engine.internal.scope.Namespace; 38 import com.google.dart.engine.internal.scope.Namespace;
36 import com.google.dart.engine.internal.task.ResolveDartLibraryTask; 39 import com.google.dart.engine.internal.task.ResolveDartLibraryTask;
37 import com.google.dart.engine.sdk.DirectoryBasedDartSdk; 40 import com.google.dart.engine.sdk.DirectoryBasedDartSdk;
38 import com.google.dart.engine.source.DartUriResolver; 41 import com.google.dart.engine.source.DartUriResolver;
39 import com.google.dart.engine.source.FileBasedSource; 42 import com.google.dart.engine.source.FileBasedSource;
40 import com.google.dart.engine.source.FileUriResolver; 43 import com.google.dart.engine.source.FileUriResolver;
41 import com.google.dart.engine.source.Source; 44 import com.google.dart.engine.source.Source;
42 import com.google.dart.engine.source.SourceContainer; 45 import com.google.dart.engine.source.SourceContainer;
43 import com.google.dart.engine.source.SourceFactory; 46 import com.google.dart.engine.source.SourceFactory;
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 // Expected result 865 // Expected result
863 } 866 }
864 } 867 }
865 868
866 public void test_parseHtmlUnit_noErrors() throws Exception { 869 public void test_parseHtmlUnit_noErrors() throws Exception {
867 Source source = addSource("/lib.html", "<html></html>"); 870 Source source = addSource("/lib.html", "<html></html>");
868 HtmlUnit unit = context.parseHtmlUnit(source); 871 HtmlUnit unit = context.parseHtmlUnit(source);
869 assertNotNull(unit); 872 assertNotNull(unit);
870 } 873 }
871 874
875 public void test_parseHtmlUnit_resolveDirectives() throws Exception {
876 Source libSource = addSource("/lib.dart", createSource(//
877 "library lib;",
878 "class ClassA {}"));
879 Source source = addSource("/lib.html", createSource(//
880 "<html>",
881 "<head>",
882 " <script type='application/dart'>",
883 " import 'lib.dart';",
884 " ClassA v = null;",
885 " </script>",
886 "</head>",
887 "<body>",
888 "</body>",
889 "</html>"));
890 HtmlUnit unit = context.parseHtmlUnit(source);
891 // import directive should be resolved
892 XmlTagNode htmlNode = unit.getTagNodes().get(0);
893 XmlTagNode headNode = htmlNode.getTagNodes().get(0);
894 HtmlScriptTagNode scriptNode = (HtmlScriptTagNode) headNode.getTagNodes().ge t(0);
895 CompilationUnit script = scriptNode.getScript();
896 ImportDirective importNode = (ImportDirective) script.getDirectives().get(0) ;
897 assertNotNull(importNode.getUriContent());
898 assertEquals(libSource, importNode.getSource());
899 }
900
872 public void test_performAnalysisTask_changeLibraryContents() throws Exception { 901 public void test_performAnalysisTask_changeLibraryContents() throws Exception {
873 Source libSource = addSource("/test.dart", "library lib; part 'test-part.dar t';"); 902 Source libSource = addSource("/test.dart", "library lib; part 'test-part.dar t';");
874 Source partSource = addSource("/test-part.dart", "part of lib;"); 903 Source partSource = addSource("/test-part.dart", "part of lib;");
875 analyzeAll_assertFinished(); 904 analyzeAll_assertFinished();
876 assertNotNull("library resolved 1", context.getResolvedCompilationUnit(libSo urce, libSource)); 905 assertNotNull("library resolved 1", context.getResolvedCompilationUnit(libSo urce, libSource));
877 assertNotNull("part resolved 1", context.getResolvedCompilationUnit(partSour ce, libSource)); 906 assertNotNull("part resolved 1", context.getResolvedCompilationUnit(partSour ce, libSource));
878 // update and analyze #1 907 // update and analyze #1
879 context.setContents(libSource, "library lib;"); 908 context.setContents(libSource, "library lib;");
880 assertNull("library changed 2", context.getResolvedCompilationUnit(libSource , libSource)); 909 assertNull("library changed 2", context.getResolvedCompilationUnit(libSource , libSource));
881 assertNull("part changed 2", context.getResolvedCompilationUnit(partSource, libSource)); 910 assertNull("part changed 2", context.getResolvedCompilationUnit(partSource, libSource));
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 return (Source[]) field.get(context2); 1328 return (Source[]) field.get(context2);
1300 } 1329 }
1301 1330
1302 private void setIncrementalAnalysisCache(AnalysisContextImpl context2, 1331 private void setIncrementalAnalysisCache(AnalysisContextImpl context2,
1303 IncrementalAnalysisCache incrementalCache) throws Exception { 1332 IncrementalAnalysisCache incrementalCache) throws Exception {
1304 Field field = AnalysisContextImpl.class.getDeclaredField("incrementalAnalysi sCache"); 1333 Field field = AnalysisContextImpl.class.getDeclaredField("incrementalAnalysi sCache");
1305 field.setAccessible(true); 1334 field.setAccessible(true);
1306 field.set(context2, incrementalCache); 1335 field.set(context2, incrementalCache);
1307 } 1336 }
1308 } 1337 }
OLDNEW
« no previous file with comments | « editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/task/ParseHtmlTask.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698