mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:17:55 +00:00
Revert "Parts must start with 'part of'" and "Attempt to fix VM build"
This reverts r13961 and r13963. Review URL: https://codereview.chromium.org//11233061 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@13967 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
0f11f4baa0
commit
6254729761
|
@ -4,7 +4,6 @@
|
|||
|
||||
package com.google.dart.compiler;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
@ -712,50 +711,36 @@ public class DartCompiler {
|
|||
|
||||
// check that all sourced units have no directives
|
||||
for (DartUnit unit : lib.getUnits()) {
|
||||
// don't need to check a unit that hasn't changed
|
||||
if (unit.isDiet()) {
|
||||
// don't need to check a unit that hasn't changed
|
||||
continue;
|
||||
}
|
||||
// ignore library unit
|
||||
DartSource unitSource = (DartSource) unit.getSourceInfo().getSource();
|
||||
if (isLibrarySelfUnit(lib, unitSource)) {
|
||||
continue;
|
||||
}
|
||||
// analyze directives
|
||||
List<DartDirective> directives = unit.getDirectives();
|
||||
if (directives.isEmpty()) {
|
||||
// TODO(scheglov) Remove after http://code.google.com/p/dart/issues/detail?id=6121
|
||||
if (!StringUtils.startsWith(lib.getName(), "dart:")) {
|
||||
context.onError(new DartCompilationError(unitSource,
|
||||
DartCompilerErrorCode.MISSING_PART_OF_DIRECTIVE));
|
||||
if (invalidDirectivesForPart(unit.getDirectives())) {
|
||||
// find corresponding source node for this unit
|
||||
for (LibraryNode sourceNode : lib.getSourcePaths()) {
|
||||
if (sourceNode == lib.getSelfSourcePath()) {
|
||||
// skip the special synthetic selfSourcePath node
|
||||
continue;
|
||||
}
|
||||
DartSource dartSource = (DartSource) unit.getSourceInfo().getSource();
|
||||
// check for directives
|
||||
if (dartSource.getRelativePath().equals(sourceNode.getText())) {
|
||||
context.onError(new DartCompilationError(unit.getDirectives().get(0),
|
||||
DartCompilerErrorCode.ILLEGAL_DIRECTIVES_IN_SOURCED_UNIT,
|
||||
Elements.getRelativeSourcePath(dartSource, lib.getSource())));
|
||||
}
|
||||
}
|
||||
} else if (directives.get(0) instanceof DartPartOfDirective) {
|
||||
DartPartOfDirective directive = (DartPartOfDirective) directives.get(0);
|
||||
String dirName = directive.getLibraryName();
|
||||
if (!Objects.equal(dirName, lib.getName())) {
|
||||
context.onError(new DartCompilationError(directive,
|
||||
DartCompilerErrorCode.WRONG_PART_OF_NAME, lib.getName(), dirName));
|
||||
}
|
||||
} else {
|
||||
context.onError(new DartCompilationError(directives.get(0),
|
||||
DartCompilerErrorCode.ILLEGAL_DIRECTIVES_IN_SOURCED_UNIT,
|
||||
Elements.getRelativeSourcePath(unitSource, lib.getSource())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isLibrarySelfUnit(LibraryUnit lib, DartSource unitSource) {
|
||||
String unitRelativePath = unitSource.getRelativePath();
|
||||
for (LibraryNode sourceNode : lib.getSourcePaths()) {
|
||||
if (unitRelativePath.equals(sourceNode.getText())) {
|
||||
if (sourceNode == lib.getSelfSourcePath()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private boolean invalidDirectivesForPart(List<DartDirective> directives) {
|
||||
int size = directives.size();
|
||||
if (size == 1) {
|
||||
return !(directives.get(0) instanceof DartPartOfDirective);
|
||||
}
|
||||
return false;
|
||||
return size > 0;
|
||||
}
|
||||
|
||||
private void setEntryPoint() {
|
||||
|
|
|
@ -17,16 +17,12 @@ public enum DartCompilerErrorCode implements ErrorCode {
|
|||
ENTRY_POINT_METHOD_MAY_NOT_BE_SETTER(ErrorSeverity.WARNING,
|
||||
"Entry point \"%s\" may not be a setter"),
|
||||
ILLEGAL_DIRECTIVES_IN_SOURCED_UNIT("This part was included by %s via a "
|
||||
+ "part directive, so cannot itself contain directives other than a 'part of' directive"),
|
||||
+ "part directive, so cannot itself contain directives other than a part of directive"),
|
||||
IO("Input/Output error: %s"),
|
||||
MIRRORS_NOT_FULLY_IMPLEMENTED(ErrorSeverity.WARNING, "dart:mirrors is not fully implemented yet"),
|
||||
MISSING_LIBRARY_DIRECTIVE("a library which is imported is missing a library directive: %s"),
|
||||
MISSING_SOURCE("Cannot find referenced source: %s"),
|
||||
MISSING_PART_OF_DIRECTIVE("Missing 'part of' directive"),
|
||||
UNIT_WAS_ALREADY_INCLUDED("Unit '%s' was already included"),
|
||||
WRONG_PART_OF_NAME(
|
||||
ErrorSeverity.WARNING,
|
||||
"This part was included by '%s' via a 'part' directive, but uses name '%s' in 'part of' directive");
|
||||
UNIT_WAS_ALREADY_INCLUDED("Unit '%s' was already included");
|
||||
private final ErrorSeverity severity;
|
||||
private final String message;
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import com.google.dart.compiler.parser.DartParser;
|
|||
import com.google.dart.compiler.resolver.CoreTypeProvider;
|
||||
import com.google.dart.compiler.resolver.CoreTypeProviderImplementation;
|
||||
import com.google.dart.compiler.resolver.Element;
|
||||
import com.google.dart.compiler.resolver.ElementKind;
|
||||
import com.google.dart.compiler.resolver.LibraryElement;
|
||||
import com.google.dart.compiler.resolver.MemberBuilder;
|
||||
import com.google.dart.compiler.resolver.Resolver;
|
||||
|
@ -96,11 +95,7 @@ class DeltaAnalyzer {
|
|||
Scope scope = libraryUnit.getElement().getScope();
|
||||
for (Element member : enclosingLibrary.getMembers()) {
|
||||
if (member.getSourceInfo().getSource() != originalSource) {
|
||||
String name = member.getName();
|
||||
if (ElementKind.of(member) == ElementKind.LIBRARY) {
|
||||
name = "__library_" + ((LibraryElement) member).getLibraryUnit().getName();
|
||||
}
|
||||
scope.declareElement(name, member);
|
||||
scope.declareElement(member.getName(), member);
|
||||
}
|
||||
}
|
||||
return scope;
|
||||
|
|
|
@ -27,6 +27,7 @@ public class Scope {
|
|||
private final String name;
|
||||
private List<LabelElement> labels;
|
||||
private LibraryElement library;
|
||||
private boolean stateProgress;
|
||||
private boolean stateReady;
|
||||
|
||||
@VisibleForTesting
|
||||
|
|
|
@ -13,7 +13,7 @@ import com.google.dart.compiler.ast.LibraryUnit;
|
|||
public class CodeCompletionParseTest extends CompilerTestCase {
|
||||
|
||||
public void test1() throws Exception {
|
||||
AnalyzeLibraryResult result = analyzeLibrary(makeCode(
|
||||
AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode(
|
||||
"class CellLocation {",
|
||||
" int _field1;",
|
||||
" String _field2;",
|
||||
|
@ -29,7 +29,7 @@ public class CodeCompletionParseTest extends CompilerTestCase {
|
|||
}
|
||||
|
||||
public void test2() throws Exception {
|
||||
AnalyzeLibraryResult result = analyzeLibrary(makeCode(
|
||||
AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode(
|
||||
"doFoo() {",
|
||||
" new ", // cursor
|
||||
"}"));
|
||||
|
@ -38,7 +38,7 @@ public class CodeCompletionParseTest extends CompilerTestCase {
|
|||
}
|
||||
|
||||
public void test3() throws Exception {
|
||||
AnalyzeLibraryResult result = analyzeLibrary(makeCode(
|
||||
AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode(
|
||||
"class Foo {",
|
||||
" static final Bar b = const ", // cursor
|
||||
"}",
|
||||
|
@ -51,7 +51,7 @@ public class CodeCompletionParseTest extends CompilerTestCase {
|
|||
}
|
||||
|
||||
public void test4() throws Exception {
|
||||
AnalyzeLibraryResult result = analyzeLibrary(makeCode(
|
||||
AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode(
|
||||
"foo() {",
|
||||
" int SEED;",
|
||||
" for (int i = 0; i < S)", // cursor before )
|
||||
|
@ -61,7 +61,7 @@ public class CodeCompletionParseTest extends CompilerTestCase {
|
|||
}
|
||||
|
||||
public void test5() throws Exception {
|
||||
AnalyzeLibraryResult result = analyzeLibrary(makeCode(
|
||||
AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode(
|
||||
"ckass Sunflower {",
|
||||
" static final int SEED_RADIUS = 2;",
|
||||
" static final int SCALE_FACTOR = 4;",
|
||||
|
@ -73,7 +73,7 @@ public class CodeCompletionParseTest extends CompilerTestCase {
|
|||
}
|
||||
|
||||
public void test6() throws Exception {
|
||||
AnalyzeLibraryResult result = analyzeLibrary(makeCode(
|
||||
AnalyzeLibraryResult result = analyzeLibrary("foo", makeCode(
|
||||
"class Sunflower {",
|
||||
" static final int SEED_RADIUS = 2;",
|
||||
" static final int SCALE_FACTOR = 4;",
|
||||
|
|
|
@ -19,7 +19,6 @@ import com.google.dart.compiler.ast.DartUnit;
|
|||
import com.google.dart.compiler.ast.LibraryUnit;
|
||||
import com.google.dart.compiler.common.ErrorExpectation;
|
||||
import com.google.dart.compiler.common.SourceInfo;
|
||||
import com.google.dart.compiler.end2end.inc.MemoryLibrarySource;
|
||||
import com.google.dart.compiler.parser.DartParser;
|
||||
import com.google.dart.compiler.parser.DartParserRunner;
|
||||
import com.google.dart.compiler.resolver.Element;
|
||||
|
@ -188,9 +187,10 @@ public abstract class CompilerTestCase extends TestCase {
|
|||
}
|
||||
|
||||
protected AnalyzeLibraryResult analyzeLibrary(String... lines) throws Exception {
|
||||
String name = getName();
|
||||
testSource = makeCode(lines);
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(testSource);
|
||||
testUnit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(name, testSource);
|
||||
testUnit = libraryResult.getLibraryUnitResult().getUnit(name);
|
||||
return libraryResult;
|
||||
}
|
||||
|
||||
|
@ -199,24 +199,26 @@ public abstract class CompilerTestCase extends TestCase {
|
|||
* <p>
|
||||
* <b>Note:</b> if the IDE changes how it calls analyzeLibrary, this should
|
||||
* be changed to match.
|
||||
* @param code the Dart code to parse/analyze
|
||||
*
|
||||
* @param name the name to use for the source file
|
||||
* @param code the Dart code to parse/analyze
|
||||
* @return an {@link AnalyzeLibraryResult} containing the {@link LibraryUnit}
|
||||
* and all the errors/warnings generated from the supplied code
|
||||
* @throws Exception
|
||||
*/
|
||||
protected AnalyzeLibraryResult analyzeLibrary(String code)
|
||||
protected AnalyzeLibraryResult analyzeLibrary(String name, String code)
|
||||
throws Exception {
|
||||
AnalyzeLibraryResult result = new AnalyzeLibraryResult();
|
||||
result.source = code;
|
||||
// Prepare library.
|
||||
MemoryLibrarySource lib = new MemoryLibrarySource("Test.dart");
|
||||
lib.setContent("Test.dart", code);
|
||||
MockLibrarySource lib = new MockLibrarySource();
|
||||
// Prepare unit.
|
||||
Map<URI, DartUnit> testUnits = Maps.newHashMap();
|
||||
{
|
||||
DartSource src = lib.getSourceFor("Test.dart");
|
||||
DartSource src = new DartSourceTest(name, code, lib);
|
||||
DartUnit unit = makeParser(src, code, result).parseUnit();
|
||||
// Remember unit.
|
||||
lib.addSource(src);
|
||||
testUnits.put(src.getUri(), unit);
|
||||
}
|
||||
DartArtifactProvider provider = new MockArtifactProvider();
|
||||
|
|
|
@ -4,10 +4,8 @@
|
|||
|
||||
package com.google.dart.compiler;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.dart.compiler.ast.DartUnit;
|
||||
import com.google.dart.compiler.ast.LibraryUnit;
|
||||
import com.google.dart.compiler.end2end.inc.MemoryLibrarySource;
|
||||
import com.google.dart.compiler.resolver.ClassElement;
|
||||
import com.google.dart.compiler.resolver.Element;
|
||||
import com.google.dart.compiler.resolver.LibraryElement;
|
||||
|
@ -15,6 +13,7 @@ import com.google.dart.compiler.resolver.MethodElement;
|
|||
import com.google.dart.compiler.testing.TestCompilerConfiguration;
|
||||
import com.google.dart.compiler.testing.TestCompilerContext;
|
||||
import com.google.dart.compiler.testing.TestDartArtifactProvider;
|
||||
import com.google.dart.compiler.testing.TestLibrarySource;
|
||||
import com.google.dart.compiler.util.DartSourceString;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -27,13 +26,10 @@ public class DeltaAnalyzerTest extends TestCase {
|
|||
private final DartArtifactProvider provider = new TestDartArtifactProvider();
|
||||
|
||||
public void testNoChangeSingleFile() throws IOException {
|
||||
MemoryLibrarySource librarySource = new MemoryLibrarySource("App.dart");
|
||||
librarySource.setContent("App.dart", "library App; part 'before.dart';");
|
||||
librarySource.setContent("before.dart",
|
||||
Joiner.on("\n").join(new String[] {
|
||||
"part of App;",
|
||||
TestLibrarySource librarySource = new TestLibrarySource(getName());
|
||||
librarySource.addSource("before.dart",
|
||||
"class Foo {}",
|
||||
"m() {}"}));
|
||||
"m() {}");
|
||||
DartUnit change = analyzeNoChange(librarySource);
|
||||
assertEquals(2, change.getTopLevelNodes().size());
|
||||
ClassElement cls = (ClassElement) change.getTopLevelNodes().get(0).getElement();
|
||||
|
@ -49,17 +45,12 @@ public class DeltaAnalyzerTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testNoChangeTwoFiles() throws IOException {
|
||||
MemoryLibrarySource librarySource = new MemoryLibrarySource("App.dart");
|
||||
librarySource.setContent("App.dart", "library App; part 'before.dart'; part 'common.dart';");
|
||||
librarySource.setContent("before.dart",
|
||||
Joiner.on("\n").join(new String[] {
|
||||
"part of App;",
|
||||
TestLibrarySource librarySource = new TestLibrarySource(getName());
|
||||
librarySource.addSource("before.dart",
|
||||
"class Foo extends Bar {}",
|
||||
"m() {}"}));
|
||||
librarySource.setContent("common.dart",
|
||||
Joiner.on("\n").join(new String[] {
|
||||
"part of App;",
|
||||
"class Bar {}"}));
|
||||
"m() {}");
|
||||
librarySource.addSource("common.dart",
|
||||
"class Bar {}");
|
||||
DartUnit change = analyzeNoChange(librarySource);
|
||||
assertEquals(2, change.getTopLevelNodes().size());
|
||||
ClassElement cls = (ClassElement) change.getTopLevelNodes().get(0).getElement();
|
||||
|
@ -76,14 +67,12 @@ public class DeltaAnalyzerTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testChangeSingleFile() throws IOException {
|
||||
MemoryLibrarySource librarySource = new MemoryLibrarySource("App.dart");
|
||||
librarySource.setContent("App.dart", "library App;");
|
||||
librarySource.setContent(
|
||||
"before.dart",
|
||||
Joiner.on("\n").join(new String[] {"part of App;", "class Foo {}", "m() {}"}));
|
||||
TestLibrarySource librarySource = new TestLibrarySource(getName());
|
||||
librarySource.addSource("before.dart",
|
||||
"class Foo {}",
|
||||
"m() {}");
|
||||
DartSource sourceBefore = librarySource.getSourceFor("before.dart");
|
||||
DartSource sourceAfter = new DartSourceString("after.dart", Joiner.on("\n").join(
|
||||
new String[] {"part of App;", "class Foo {}", ""}));
|
||||
DartSource sourceAfter = new DartSourceString("after.dart", "class Foo {}");
|
||||
DartUnit change = analyze(librarySource, sourceBefore, sourceAfter);
|
||||
assertEquals(1, change.getTopLevelNodes().size());
|
||||
Element element = change.getLibrary().getElement().lookupLocalElement("m");
|
||||
|
@ -96,19 +85,14 @@ public class DeltaAnalyzerTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testChangeTwoFiles() throws IOException {
|
||||
MemoryLibrarySource librarySource = new MemoryLibrarySource("App.dart");
|
||||
librarySource.setContent("App.dart", "library App; part 'before.dart'; part 'common.dart';");
|
||||
librarySource.setContent("before.dart",
|
||||
Joiner.on("\n").join(new String[] {
|
||||
"part of App;",
|
||||
TestLibrarySource librarySource = new TestLibrarySource(getName());
|
||||
librarySource.addSource("before.dart",
|
||||
"class Foo extends Bar {}",
|
||||
"m() {}"}));
|
||||
librarySource.setContent("common.dart",
|
||||
Joiner.on("\n").join(new String[] {
|
||||
"part of App;",
|
||||
"class Bar {}"}));
|
||||
"m() {}");
|
||||
librarySource.addSource("common.dart",
|
||||
"class Bar {}");
|
||||
DartSource sourceBefore = librarySource.getSourceFor("before.dart");
|
||||
DartSource sourceAfter = new DartSourceString("after.dart", "part of App; class Foo extends Bar {}");
|
||||
DartSource sourceAfter = new DartSourceString("after.dart", "class Foo extends Bar {}");
|
||||
DartUnit change = analyze(librarySource, sourceBefore, sourceAfter);
|
||||
assertEquals(1, change.getTopLevelNodes().size());
|
||||
assertNull(change.getLibrary().getElement().lookupLocalElement("m"));
|
||||
|
|
270
compiler/javatests/com/google/dart/compiler/IdeTest.java
Normal file
270
compiler/javatests/com/google/dart/compiler/IdeTest.java
Normal file
|
@ -0,0 +1,270 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
package com.google.dart.compiler;
|
||||
|
||||
import com.google.dart.compiler.ast.DartClass;
|
||||
import com.google.dart.compiler.ast.DartExprStmt;
|
||||
import com.google.dart.compiler.ast.DartExpression;
|
||||
import com.google.dart.compiler.ast.DartIdentifier;
|
||||
import com.google.dart.compiler.ast.DartMethodDefinition;
|
||||
import com.google.dart.compiler.ast.DartNode;
|
||||
import com.google.dart.compiler.ast.DartPropertyAccess;
|
||||
import com.google.dart.compiler.ast.DartReturnStatement;
|
||||
import com.google.dart.compiler.ast.DartStatement;
|
||||
import com.google.dart.compiler.ast.DartUnit;
|
||||
import com.google.dart.compiler.ast.DartUnqualifiedInvocation;
|
||||
import com.google.dart.compiler.ast.LibraryUnit;
|
||||
import com.google.dart.compiler.resolver.ClassElement;
|
||||
import com.google.dart.compiler.resolver.CoreTypeProvider;
|
||||
import com.google.dart.compiler.resolver.CoreTypeProviderImplementation;
|
||||
import com.google.dart.compiler.resolver.Element;
|
||||
import com.google.dart.compiler.resolver.FieldElement;
|
||||
import com.google.dart.compiler.resolver.MethodElement;
|
||||
import com.google.dart.compiler.resolver.Scope;
|
||||
import com.google.dart.compiler.testing.TestCompilerConfiguration;
|
||||
import com.google.dart.compiler.testing.TestCompilerContext;
|
||||
import com.google.dart.compiler.testing.TestCompilerContext.EventKind;
|
||||
import com.google.dart.compiler.testing.TestDartArtifactProvider;
|
||||
import com.google.dart.compiler.testing.TestLibrarySource;
|
||||
import com.google.dart.compiler.type.FunctionType;
|
||||
import com.google.dart.compiler.type.InterfaceType;
|
||||
import com.google.dart.compiler.type.Type;
|
||||
import com.google.dart.compiler.type.TypeAnalyzer;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Test of the IDE API in DartCompiler.
|
||||
*/
|
||||
public class IdeTest extends TestCase {
|
||||
|
||||
private final TestCompilerContext context = new TestCompilerContext(EventKind.ERROR,
|
||||
EventKind.TYPE_ERROR) {
|
||||
@Override
|
||||
protected void handleEvent(DartCompilationError event, EventKind kind) {
|
||||
super.handleEvent(event, kind);
|
||||
// For debugging:
|
||||
// System.err.println(event);
|
||||
}
|
||||
};
|
||||
|
||||
private final DartCompilerListener listener = context;
|
||||
|
||||
private final DartArtifactProvider provider = new TestDartArtifactProvider();
|
||||
|
||||
private final CompilerConfiguration config = new TestCompilerConfiguration();
|
||||
|
||||
public void testAnalyseNoSemicolonPropertyAccess() {
|
||||
DartUnit unit =
|
||||
analyzeUnit(
|
||||
"no_semicolon_property_access",
|
||||
"class Foo {",
|
||||
" int i;",
|
||||
" void foo() {",
|
||||
" i.y", // Missing semicolon.
|
||||
" }",
|
||||
"}");
|
||||
assertEquals("errorCount", 1, context.getErrorCount()); // Missing semicolon.
|
||||
assertEquals("typeErrorCount", 1, context.getTypeErrorCount()); // No member named "y".
|
||||
DartExprStmt statement = (DartExprStmt) firstStatementOfMethod(unit, "Foo", "foo");
|
||||
FieldElement element = (FieldElement) qualifierElement(statement.getExpression());
|
||||
assertEquals("int", element.getType().getElement().getName());
|
||||
}
|
||||
|
||||
public void testAnalyseNoSemicolonBrokenPropertyAccess() {
|
||||
DartUnit unit =
|
||||
analyzeUnit(
|
||||
"no_semicolon_broken_property_access",
|
||||
"class Foo {",
|
||||
" int i;",
|
||||
" void foo() {",
|
||||
" i.", // Syntax error and missing semicolon.
|
||||
" }",
|
||||
"}");
|
||||
// Expected identifier and missing semicolon
|
||||
assertEquals("errorCount", 2, context.getErrorCount());
|
||||
assertEquals("typeErrorCount", 1, context.getTypeErrorCount()); // No member named "".
|
||||
DartExprStmt statement = (DartExprStmt) firstStatementOfMethod(unit, "Foo", "foo");
|
||||
FieldElement element = (FieldElement) qualifierElement(statement.getExpression());
|
||||
assertEquals("int", element.getType().getElement().getName());
|
||||
}
|
||||
|
||||
public void testAnalyseBrokenPropertyAccess() {
|
||||
DartUnit unit =
|
||||
analyzeUnit(
|
||||
"broken_property_access",
|
||||
"class Foo {",
|
||||
" int i;",
|
||||
" void foo() {",
|
||||
" i.;", // Syntax error here.
|
||||
" }",
|
||||
"}");
|
||||
assertEquals("errorCount", 1, context.getErrorCount()); // Expected identifier.
|
||||
assertEquals("typeErrorCount", 1, context.getTypeErrorCount()); // No member named "".
|
||||
DartExprStmt statement = (DartExprStmt) firstStatementOfMethod(unit, "Foo", "foo");
|
||||
FieldElement element = (FieldElement) qualifierElement(statement.getExpression());
|
||||
assertEquals("int", element.getType().getElement().getName());
|
||||
}
|
||||
|
||||
public void testAnalyseNoSemicolonIdentifier() {
|
||||
DartUnit unit =
|
||||
analyzeUnit(
|
||||
"no_semicolon_identifier",
|
||||
"class Foo {",
|
||||
" int i;",
|
||||
" void foo() {",
|
||||
" i", // Missing semicolon.
|
||||
" }",
|
||||
"}");
|
||||
assertEquals("errorCount", 1, context.getErrorCount()); // Missing semicolon.
|
||||
assertEquals("typeErrorCount", 0, context.getTypeErrorCount());
|
||||
DartExprStmt statement = (DartExprStmt) firstStatementOfMethod(unit, "Foo", "foo");
|
||||
FieldElement field = (FieldElement) targetElement(statement.getExpression());
|
||||
assertEquals("int", field.getType().getElement().getName());
|
||||
}
|
||||
|
||||
public void testAnalyseNoSemicolonMethodCall() {
|
||||
DartUnit unit =
|
||||
analyzeUnit(
|
||||
"no_semicolon_method_call",
|
||||
"class Foo {",
|
||||
" int i () { return 0; }",
|
||||
" void foo() {",
|
||||
" i()", // Missing semicolon.
|
||||
" }",
|
||||
"}");
|
||||
assertEquals("errorCount", 1, context.getErrorCount()); // Missing semicolon.
|
||||
assertEquals("typeErrorCount", 0, context.getTypeErrorCount());
|
||||
DartExprStmt statement = (DartExprStmt) firstStatementOfMethod(unit, "Foo", "foo");
|
||||
DartExpression expression = statement.getExpression();
|
||||
DartUnqualifiedInvocation invocation = (DartUnqualifiedInvocation) expression;
|
||||
MethodElement method = (MethodElement) targetElement(invocation.getTarget());
|
||||
assertEquals("i", method.getName());
|
||||
FunctionType type = (FunctionType) method.getType();
|
||||
assertEquals("int", type.getReturnType().getElement().getName());
|
||||
}
|
||||
|
||||
public void testAnalyseVoidKeyword() {
|
||||
DartUnit unit =
|
||||
analyzeUnit(
|
||||
"void_keyword",
|
||||
"class Foo {",
|
||||
" Function voidFunction;",
|
||||
" void foo() {",
|
||||
" void", // Missing semicolon and keyword
|
||||
" }",
|
||||
"}");
|
||||
// Expected identifier and missing semicolon.
|
||||
assertEquals("errorCount", 2, context.getErrorCount());
|
||||
// You can't use 'void' as a member name. It might be the beginning of a variable declaration
|
||||
// so it isn't an error in and of itself.
|
||||
assertEquals("typeErrorCount", 0, context.getTypeErrorCount());
|
||||
DartExprStmt statement = (DartExprStmt) firstStatementOfMethod(unit, "Foo", "foo");
|
||||
DartIdentifier expression = (DartIdentifier) statement.getExpression();
|
||||
assertEquals("", expression.getName());
|
||||
}
|
||||
|
||||
public void testAnalyseVoidKeywordPropertyAccess() {
|
||||
DartUnit unit =
|
||||
analyzeUnit(
|
||||
"void_keyword_property_access",
|
||||
"class Foo {",
|
||||
" Function voidFunction;",
|
||||
" void foo() {",
|
||||
" this.void", // Missing semicolon and keyword
|
||||
" }",
|
||||
"}");
|
||||
// Expected identifier and missing semicolon.
|
||||
assertEquals("errorCount", 2, context.getErrorCount());
|
||||
assertEquals("typeErrorCount", 1, context.getTypeErrorCount());
|
||||
DartExprStmt statement = (DartExprStmt) firstStatementOfMethod(unit, "Foo", "foo");
|
||||
DartPropertyAccess expression = (DartPropertyAccess) statement.getExpression();
|
||||
assertEquals("", expression.getPropertyName());
|
||||
}
|
||||
|
||||
public void testReturnIntTypeAnalysis() {
|
||||
DartUnit unit =
|
||||
analyzeUnit(
|
||||
"return_int_type_analysis",
|
||||
"class Foo {",
|
||||
" int i;",
|
||||
" int foo() {",
|
||||
" return i;",
|
||||
" }",
|
||||
"}");
|
||||
Scope unitScope = unit.getLibrary().getElement().getScope();
|
||||
CoreTypeProvider typeProvider = new CoreTypeProviderImplementation(unitScope, context);
|
||||
DartClass classNode = getClassOfUnit(unit, "Foo");
|
||||
DartReturnStatement rtnStmt = (DartReturnStatement) firstStatementOfMethod(unit, "Foo", "foo");
|
||||
ClassElement classElement = classNode.getElement();
|
||||
InterfaceType definingType = classElement.getType();
|
||||
Type type = TypeAnalyzer.analyze(rtnStmt.getValue(), typeProvider, context, definingType);
|
||||
assertNotNull(type);
|
||||
assertEquals("int", type.getElement().getName());
|
||||
}
|
||||
|
||||
private Element targetElement(DartExpression expression) {
|
||||
DartIdentifier identifier = (DartIdentifier) expression;
|
||||
Element element = identifier.getElement();
|
||||
assertNotNull(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
private Element qualifierElement(DartExpression node) {
|
||||
DartPropertyAccess propertyAccess = (DartPropertyAccess) node;
|
||||
DartIdentifier identifier = (DartIdentifier) propertyAccess.getQualifier();
|
||||
Element element = identifier.getElement();
|
||||
assertNotNull(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
private DartClass getClassOfUnit(DartUnit unit, String cls) {
|
||||
DartClass dartClass = null;
|
||||
for (DartNode node : unit.getTopLevelNodes()) {
|
||||
DartClass classNode = (DartClass) node;
|
||||
if (node instanceof DartClass) {
|
||||
if (classNode.getName().getName().equals(cls)) {
|
||||
dartClass = classNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
assertNotNull(dartClass);
|
||||
return dartClass;
|
||||
}
|
||||
|
||||
private DartStatement firstStatementOfMethod(DartUnit unit, String cls, String member) {
|
||||
DartClass classNode = getClassOfUnit(unit, cls);
|
||||
for (DartNode memberNode : classNode.getMembers()) {
|
||||
if (memberNode instanceof DartMethodDefinition) {
|
||||
DartMethodDefinition methodNode = (DartMethodDefinition) memberNode;
|
||||
if (methodNode.getName() instanceof DartIdentifier) {
|
||||
DartIdentifier methodName = (DartIdentifier) methodNode.getName();
|
||||
if (methodName.getName().equals(member)) {
|
||||
return methodNode.getFunction().getBody().getStatements().get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fail();
|
||||
return null;
|
||||
}
|
||||
|
||||
private DartUnit analyzeUnit(String name, String... sourceLines) throws AssertionError {
|
||||
TestLibrarySource lib = new TestLibrarySource(name);
|
||||
lib.addSource(name + ".dart", sourceLines);
|
||||
LibraryUnit libraryUnit;
|
||||
try {
|
||||
libraryUnit = DartCompiler.analyzeLibrary(lib, null, config, provider, listener);
|
||||
assertNotNull("libraryUnit == null", libraryUnit);
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
DartUnit unit = libraryUnit.getUnit(name + ".dart");
|
||||
assertNotNull("unit == null", unit);
|
||||
return unit;
|
||||
}
|
||||
}
|
24
compiler/javatests/com/google/dart/compiler/IdeTests.java
Normal file
24
compiler/javatests/com/google/dart/compiler/IdeTests.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
package com.google.dart.compiler;
|
||||
|
||||
import junit.extensions.TestSetup;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class IdeTests extends TestSetup {
|
||||
|
||||
public IdeTests(Test test) {
|
||||
super(test);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("IDE/dartc integration test suite.");
|
||||
suite.addTestSuite(IdeTest.class);
|
||||
suite.addTestSuite(DeltaAnalyzerTest.class);
|
||||
suite.addTestSuite(CodeCompletionParseTest.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
|
@ -91,9 +91,9 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"part 'B.dart';",
|
||||
"part 'C.dart';",
|
||||
""));
|
||||
appSource.setContent("A.dart", "part of application;");
|
||||
appSource.setContent("B.dart", "part of application;");
|
||||
appSource.setContent("C.dart", "part of application;");
|
||||
appSource.setContent("A.dart", "");
|
||||
appSource.setContent("B.dart", "");
|
||||
appSource.setContent("C.dart", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -114,7 +114,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"B.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class A {",
|
||||
" int not_hole;",
|
||||
"}",
|
||||
|
@ -123,7 +122,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"C.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class B extends A {",
|
||||
" int bar() {",
|
||||
" return super.not_hole;", // qualified reference
|
||||
|
@ -137,7 +135,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"int not_hole;",
|
||||
""));
|
||||
compile();
|
||||
|
@ -160,7 +157,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"B.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class A {",
|
||||
" int foo() {",
|
||||
" return hole;", // no such field
|
||||
|
@ -168,13 +164,12 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"}",
|
||||
""));
|
||||
compile();
|
||||
assertErrors(errors, errEx(TypeErrorCode.CANNOT_BE_RESOLVED, 5, 12, 4));
|
||||
assertErrors(errors, errEx(TypeErrorCode.CANNOT_BE_RESOLVED, 4, 12, 4));
|
||||
// Update units and compile.
|
||||
appSource.setContent(
|
||||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"int hole;",
|
||||
""));
|
||||
compile();
|
||||
|
@ -195,7 +190,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"B.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class A {",
|
||||
" foo() {}",
|
||||
"}",
|
||||
|
@ -204,7 +198,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"C.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class B extends A {",
|
||||
" int bar() {",
|
||||
" foo();", // unqualified invocation
|
||||
|
@ -219,7 +212,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"foo() {}",
|
||||
""));
|
||||
compile();
|
||||
|
@ -234,7 +226,7 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
Thread.sleep(5);
|
||||
// Remove top-level foo(), so invocation of foo() in B should be bound to the super class.
|
||||
{
|
||||
appSource.setContent("A.dart", "part of application;");
|
||||
appSource.setContent("A.dart", "");
|
||||
compile();
|
||||
// B should be compiled because it also declares foo(), so produces "shadow" conflict.
|
||||
// C should be compiled because it has unqualified invocation which was declared in A.
|
||||
|
@ -253,7 +245,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"B.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class A {",
|
||||
" foo() {}",
|
||||
"}",
|
||||
|
@ -262,7 +253,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"C.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class B extends A {",
|
||||
" int bar() {",
|
||||
" super.foo();", // qualified invocation
|
||||
|
@ -277,7 +267,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"foo() {}",
|
||||
""));
|
||||
compile();
|
||||
|
@ -299,7 +288,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"B.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class A {",
|
||||
" var foo;",
|
||||
"}",
|
||||
|
@ -308,7 +296,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"C.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class B extends A {",
|
||||
" int bar() {",
|
||||
" foo = 0;", // unqualified access
|
||||
|
@ -323,7 +310,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"var foo;",
|
||||
""));
|
||||
compile();
|
||||
|
@ -338,7 +324,7 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
Thread.sleep(5);
|
||||
// Remove top-level "foo", so access to "foo" in B should be bound to the super class.
|
||||
{
|
||||
appSource.setContent("A.dart", "part of application;");
|
||||
appSource.setContent("A.dart", "");
|
||||
compile();
|
||||
// B should be compiled because it also declares "foo", so produces "shadow" conflict.
|
||||
// C should be compiled because it has unqualified access which was declared in A.
|
||||
|
@ -357,7 +343,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"B.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class A {",
|
||||
" var foo;",
|
||||
"}",
|
||||
|
@ -366,7 +351,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"C.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class B extends A {",
|
||||
" int bar() {",
|
||||
" super.foo = 0;", // qualified access
|
||||
|
@ -381,7 +365,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"var foo;",
|
||||
""));
|
||||
compile();
|
||||
|
@ -399,7 +382,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"B.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"methodB() {",
|
||||
" var symbolDependency_foo;",
|
||||
"}"));
|
||||
|
@ -410,7 +392,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"var symbolDependency_foo;"));
|
||||
compile();
|
||||
// Now there is top-level declarations conflict between A and B.
|
||||
|
@ -425,19 +406,17 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"var duplicate;"));
|
||||
appSource.setContent(
|
||||
"B.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"bar() {",
|
||||
" var duplicate;",
|
||||
"}"));
|
||||
compile();
|
||||
// Update units and compile.
|
||||
appSource.setContent("A.dart", "part of application;");
|
||||
appSource.setContent("A.dart", "");
|
||||
compile();
|
||||
// Top-level declaration in A was removed, so no conflict.
|
||||
// So:
|
||||
|
@ -455,13 +434,11 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"var duplicate;"));
|
||||
appSource.setContent(
|
||||
"B.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"bar() {",
|
||||
" var duplicate;",
|
||||
"}"));
|
||||
|
@ -488,7 +465,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class A {",
|
||||
"}",
|
||||
""));
|
||||
|
@ -496,7 +472,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"B.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class B extends A {",
|
||||
" foo() {",
|
||||
" var bar;",
|
||||
|
@ -510,7 +485,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"class A {",
|
||||
" var bar;",
|
||||
"}",
|
||||
|
@ -526,7 +500,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"var conflict;",
|
||||
""));
|
||||
compile();
|
||||
|
@ -536,7 +509,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"B.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
"var conflict;",
|
||||
""));
|
||||
compile();
|
||||
|
@ -544,8 +516,8 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
// Both A and B have errors.
|
||||
assertErrors(
|
||||
errors,
|
||||
errEx("A.dart", ResolverErrorCode.DUPLICATE_TOP_LEVEL_DECLARATION, 3, 5, 8),
|
||||
errEx("B.dart", ResolverErrorCode.DUPLICATE_TOP_LEVEL_DECLARATION, 3, 5, 8));
|
||||
errEx("A.dart", ResolverErrorCode.DUPLICATE_TOP_LEVEL_DECLARATION, 2, 5, 8),
|
||||
errEx("B.dart", ResolverErrorCode.DUPLICATE_TOP_LEVEL_DECLARATION, 2, 5, 8));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -825,7 +797,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of application;",
|
||||
""));
|
||||
appSource.setContent(
|
||||
APP,
|
||||
|
@ -1506,74 +1477,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
assertErrors(errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Part should have one and only one directive - "part of".
|
||||
*/
|
||||
public void test_partDirectives_otherThenPartOf() throws Exception {
|
||||
appSource.setContent(
|
||||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"library A;",
|
||||
""));
|
||||
appSource.setContent(
|
||||
APP,
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"library application;",
|
||||
"part 'A.dart';",
|
||||
""));
|
||||
// do compile
|
||||
compile();
|
||||
assertErrors(errors, errEx(DartCompilerErrorCode.ILLEGAL_DIRECTIVES_IN_SOURCED_UNIT, 2, 1, 10));
|
||||
}
|
||||
|
||||
/**
|
||||
* Part should have one and only one directive - "part of".
|
||||
*/
|
||||
public void test_partDirectives_noPartOf() throws Exception {
|
||||
appSource.setContent(
|
||||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
""));
|
||||
appSource.setContent(
|
||||
APP,
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"library application;",
|
||||
"part 'A.dart';",
|
||||
""));
|
||||
// do compile
|
||||
compile();
|
||||
assertErrors(errors, errEx(DartCompilerErrorCode.MISSING_PART_OF_DIRECTIVE, -1, -1, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Part should have one and only one directive - "part of".
|
||||
*/
|
||||
public void test_partDirectives_wrongNameInPartOf() throws Exception {
|
||||
appSource.setContent(
|
||||
"A.dart",
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"part of Z;",
|
||||
""));
|
||||
appSource.setContent(
|
||||
APP,
|
||||
makeCode(
|
||||
"// filler filler filler filler filler filler filler filler filler filler filler",
|
||||
"library application;",
|
||||
"part 'A.dart';",
|
||||
""));
|
||||
// do compile
|
||||
compile();
|
||||
assertErrors(
|
||||
errors,
|
||||
errEx(DartCompilerErrorCode.WRONG_PART_OF_NAME, 2, 1, 10),
|
||||
errEx(TypeErrorCode.CANNOT_BE_RESOLVED, 2, 9, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Internals of Dart use "dart-ext:" import scheme, and these libraries are allowed to use
|
||||
* "native". New import syntax.
|
||||
|
@ -1593,7 +1496,7 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
|
|||
compile();
|
||||
assertErrors(errors);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Internals of Dart use "dart-ext:" import scheme, and these libraries are allowed to use
|
||||
* "native". Obsolete import syntax.
|
||||
|
|
|
@ -22,20 +22,17 @@ import java.util.Map;
|
|||
public class MemoryLibrarySource implements LibrarySource {
|
||||
public static final String IO_EXCEPTION_CONTENT = "simulate-IOException";
|
||||
private final String libName;
|
||||
private final Map<String, DartSource> sourceMap;
|
||||
private final Map<String, String> sourceContentMap;
|
||||
private final Map<String, Long> sourceLastModifiedMap;
|
||||
|
||||
public MemoryLibrarySource(String libName) {
|
||||
this.libName = libName;
|
||||
sourceMap = Maps.newHashMap();
|
||||
sourceContentMap = Maps.newHashMap();
|
||||
sourceLastModifiedMap = Maps.newHashMap();
|
||||
}
|
||||
|
||||
private MemoryLibrarySource(String libName, MemoryLibrarySource parent) {
|
||||
this.libName = libName;
|
||||
sourceMap = parent.sourceMap;
|
||||
sourceContentMap = parent.sourceContentMap;
|
||||
sourceLastModifiedMap = parent.sourceLastModifiedMap;
|
||||
}
|
||||
|
@ -78,33 +75,17 @@ public class MemoryLibrarySource implements LibrarySource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public LibrarySource getImportFor(String relPath) throws IOException {
|
||||
if (!sourceContentMap.containsKey(relPath)) {
|
||||
return null;
|
||||
}
|
||||
public LibrarySource getImportFor(final String relPath) throws IOException {
|
||||
return new MemoryLibrarySource(relPath, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DartSource getSourceFor(final String relPath) {
|
||||
DartSource result;
|
||||
// check cache
|
||||
{
|
||||
result = sourceMap.get(relPath);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// prepare content
|
||||
final String content = sourceContentMap.get(relPath);
|
||||
final Long sourceLastModified = sourceLastModifiedMap.get(relPath);
|
||||
// may be does not exist
|
||||
if (content == null) {
|
||||
return null;
|
||||
}
|
||||
// Return fake UrlDateSource with in-memory content.
|
||||
final URI uri = URI.create(relPath);
|
||||
result = new UrlDartSource(uri, relPath, this) {
|
||||
return new UrlDartSource(uri, relPath, this) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return relPath;
|
||||
|
@ -130,15 +111,12 @@ public class MemoryLibrarySource implements LibrarySource {
|
|||
return new StringReader(content);
|
||||
}
|
||||
};
|
||||
sourceMap.put(relPath, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given content for the source.
|
||||
*/
|
||||
public void setContent(String relPath, String content) {
|
||||
sourceMap.remove(relPath);
|
||||
sourceContentMap.put(relPath, content);
|
||||
sourceLastModifiedMap.put(relPath, System.currentTimeMillis());
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
library myApp;
|
||||
|
||||
import "some.lib.dart";
|
||||
part "my.dart";
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
var x = 0, y = 1;
|
||||
void fn() { /* ... */ }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
library myApp;
|
||||
|
||||
import "some.lib.dart";
|
||||
part "my.dart";
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Spoo<T> {
|
||||
Spoo() { }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
library myApp;
|
||||
|
||||
import "some.lib.dart";
|
||||
part "my.dart";
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
library myAppPref;
|
||||
|
||||
import "some.prefixable.lib.dart" as prefix;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
library myAppUnPref;
|
||||
|
||||
import "some.prefixable.lib.dart";
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class QualifierBase {
|
||||
Other5 other5;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class QualifierBase {
|
||||
Other6 other6;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other0 {
|
||||
static int value() { return 42; }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other0 {
|
||||
static int value() { return 42; }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other0 {
|
||||
static int value() { return 42; }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other0 {
|
||||
static int value() { return 42; }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other0 {
|
||||
static int value() { return 42; }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other0 {
|
||||
static int value() { return 42; }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other0 {
|
||||
static int value() { return 42; }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other0 {
|
||||
static int value() { return 42; }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other1 {
|
||||
static Function FN;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
|
||||
class Other1 {
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class IntBag {
|
||||
int contents;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class IntBag {
|
||||
int contents;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other3 {
|
||||
static int field;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other3 {
|
||||
static int field;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other3 {
|
||||
static int field;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other4 {
|
||||
static int field;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other4 {
|
||||
static int field;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other4 {
|
||||
static int field;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other5 {
|
||||
int field;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other5 {
|
||||
int field;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other6 {
|
||||
Other6() { }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other6 {
|
||||
Other6() { }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Other6 {
|
||||
Other6() { }
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of myApp;
|
||||
|
||||
class Baz {
|
||||
SomeClass2 sc2;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of some_lib;
|
||||
|
||||
interface SomeClass default SomeClassImpl {
|
||||
SomeClass(arg);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of some_lib;
|
||||
|
||||
interface SomeClass default SomeClassImpl {
|
||||
SomeClass(arg);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of some_lib;
|
||||
|
||||
interface SomeClass default SomeClassImpl {
|
||||
SomeClass(arg);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of someimpl_dart;
|
||||
|
||||
class SomeClassImpl implements SomeClass {
|
||||
String message_;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of someimpl_dart;
|
||||
|
||||
class SomeClassImpl implements SomeClass {
|
||||
String message_;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
part of someimpl_dart;
|
||||
|
||||
class SomeClassImpl implements SomeClass {
|
||||
String message_;
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
package com.google.dart.compiler.resolver;
|
||||
|
||||
import static com.google.dart.compiler.common.ErrorExpectation.assertErrors;
|
||||
import static com.google.dart.compiler.common.ErrorExpectation.errEx;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.dart.compiler.CompilerTestCase;
|
||||
|
@ -36,6 +34,9 @@ import com.google.dart.compiler.type.FunctionAliasType;
|
|||
import com.google.dart.compiler.type.Type;
|
||||
import com.google.dart.compiler.type.TypeVariable;
|
||||
|
||||
import static com.google.dart.compiler.common.ErrorExpectation.assertErrors;
|
||||
import static com.google.dart.compiler.common.ErrorExpectation.errEx;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -48,6 +49,7 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
|
||||
public void test_parameters_withFunctionAlias() throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"Test.dart",
|
||||
"typedef List<T> TypeAlias<T, U extends List<T>>(List<T> arg, U u);");
|
||||
assertErrors(libraryResult.getCompilationErrors());
|
||||
DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
|
||||
|
@ -73,10 +75,10 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
* This test succeeds if no exceptions are thrown.
|
||||
*/
|
||||
public void test_recursiveTypes() throws Exception {
|
||||
analyzeLibrary(
|
||||
analyzeLibrary("test.dart", Joiner.on("\n").join(
|
||||
"class A extends A implements A {}",
|
||||
"class B extends C {}",
|
||||
"class C extends B {}");
|
||||
"class C extends B {}"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,14 +87,16 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
*/
|
||||
public void test_resolution_on_class_decls() throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"class A {}",
|
||||
"interface B<T> default C {}",
|
||||
"class C<T> extends A implements B<T> {}",
|
||||
"class D extends C<int> {}",
|
||||
"class E implements C<int> {}",
|
||||
"class F<T extends A> {}",
|
||||
"class G extends F<C<int>> {}",
|
||||
"interface H<T> default C<T> {}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"class A {}",
|
||||
"interface B<T> default C {}",
|
||||
"class C<T> extends A implements B<T> {}",
|
||||
"class D extends C<int> {}",
|
||||
"class E implements C<int> {}",
|
||||
"class F<T extends A> {}",
|
||||
"class G extends F<C<int>> {}",
|
||||
"interface H<T> default C<T> {}"));
|
||||
assertErrors(libraryResult.getCompilationErrors());
|
||||
DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
|
||||
List<DartNode> nodes = unit.getTopLevelNodes();
|
||||
|
@ -214,13 +218,15 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
*/
|
||||
public void test_resolveConstructor_implicit() throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"class F {",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new F();",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"class F {",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new F();",
|
||||
" }",
|
||||
"}"));
|
||||
assertErrors(libraryResult.getCompilationErrors());
|
||||
DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
|
||||
DartNewExpression newExpression = findNodeBySource(unit, "new F()");
|
||||
|
@ -231,13 +237,15 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
|
||||
public void test_resolveConstructor_noSuchConstructor() throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"class A {",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new A.foo();",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"class A {",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new A.foo();",
|
||||
" }",
|
||||
"}"));
|
||||
assertErrors(
|
||||
libraryResult.getErrors(),
|
||||
errEx(ResolverErrorCode.NEW_EXPRESSION_NOT_CONSTRUCTOR, 5, 11, 3));
|
||||
|
@ -249,27 +257,31 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
|
||||
public void test_resolveConstructor_super_implicitDefault() throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"// filler filler filler filler filler filler filler filler filler filler",
|
||||
"class A {",
|
||||
"}",
|
||||
"class B extends A {",
|
||||
" B() : super() {}",
|
||||
"}",
|
||||
"");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"// filler filler filler filler filler filler filler filler filler filler",
|
||||
"class A {",
|
||||
"}",
|
||||
"class B extends A {",
|
||||
" B() : super() {}",
|
||||
"}",
|
||||
""));
|
||||
assertErrors(libraryResult.getErrors());
|
||||
}
|
||||
|
||||
public void test_superMethodInvocation_inConstructorInitializer() throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"// filler filler filler filler filler filler filler filler filler filler",
|
||||
"class A {",
|
||||
" foo() {}",
|
||||
"}",
|
||||
"class B extends A {",
|
||||
" var x;",
|
||||
" B() : x = super.foo() {}",
|
||||
"}",
|
||||
"");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"// filler filler filler filler filler filler filler filler filler filler",
|
||||
"class A {",
|
||||
" foo() {}",
|
||||
"}",
|
||||
"class B extends A {",
|
||||
" var x;",
|
||||
" B() : x = super.foo() {}",
|
||||
"}",
|
||||
""));
|
||||
assertErrors(
|
||||
libraryResult.getErrors(),
|
||||
errEx(ResolverErrorCode.SUPER_METHOD_INVOCATION_IN_CONSTRUCTOR_INITIALIZER, 7, 13, 11));
|
||||
|
@ -281,15 +293,17 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
public void test_resolveInterfaceConstructor_implicitDefault_noInterface_noFactory()
|
||||
throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"interface I default F {",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I();",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"interface I default F {",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I();",
|
||||
" }",
|
||||
"}"));
|
||||
assertErrors(libraryResult.getCompilationErrors());
|
||||
DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
|
||||
DartNewExpression newExpression = findNodeBySource(unit, "new I()");
|
||||
|
@ -304,15 +318,17 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
public void test_resolveInterfaceConstructor_implicitDefault_hasInterface_noFactory()
|
||||
throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"interface I default F {",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I();",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"interface I default F {",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I();",
|
||||
" }",
|
||||
"}"));
|
||||
assertErrors(libraryResult.getCompilationErrors());
|
||||
DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
|
||||
DartNewExpression newExpression = findNodeBySource(unit, "new I()");
|
||||
|
@ -327,16 +343,18 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
public void test_resolveInterfaceConstructor_implicitDefault_noInterface_hasFactory()
|
||||
throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"interface I default F {",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" F();",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I();",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"interface I default F {",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" F();",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I();",
|
||||
" }",
|
||||
"}"));
|
||||
assertErrors(libraryResult.getCompilationErrors());
|
||||
DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
|
||||
DartNewExpression newExpression = findNodeBySource(unit, "new I()");
|
||||
|
@ -349,17 +367,19 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
*/
|
||||
public void test_resolveInterfaceConstructor_const() throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"interface I default F {",
|
||||
" I(int x);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" F(int y) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" const I(0);",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"interface I default F {",
|
||||
" I(int x);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" F(int y) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" const I(0);",
|
||||
" }",
|
||||
"}"));
|
||||
assertErrors(
|
||||
libraryResult.getCompilationErrors(),
|
||||
errEx(ResolverErrorCode.CONST_AND_NONCONST_CONSTRUCTOR, 9, 5, 10));
|
||||
|
@ -383,18 +403,20 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
public void test_resolveInterfaceConstructor_whenFactoryImplementsInterface_nameIsIdentifier()
|
||||
throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"interface I default F {",
|
||||
" I(int x);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" F(int y) {}",
|
||||
" factory I(int y) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I(0);",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"interface I default F {",
|
||||
" I(int x);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" F(int y) {}",
|
||||
" factory I(int y) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I(0);",
|
||||
" }",
|
||||
"}"));
|
||||
assertErrors(libraryResult.getCompilationErrors());
|
||||
DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
|
||||
DartNewExpression newExpression = findNodeBySource(unit, "new I(0)");
|
||||
|
@ -420,18 +442,20 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
public void test_resolveInterfaceConstructor_whenFactoryImplementsInterface_nameIsQualified()
|
||||
throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"interface I default F {",
|
||||
" I.foo(int x);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" F.foo(int y) {}",
|
||||
" factory I.foo(int y) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I.foo(0);",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"interface I default F {",
|
||||
" I.foo(int x);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" F.foo(int y) {}",
|
||||
" factory I.foo(int y) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I.foo(0);",
|
||||
" }",
|
||||
"}"));
|
||||
assertErrors(libraryResult.getCompilationErrors());
|
||||
DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
|
||||
// "new I.foo()" - good
|
||||
|
@ -460,19 +484,21 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
public void test_resolveInterfaceConstructor_whenFactoryImplementsInterface_negative()
|
||||
throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"interface I default F {",
|
||||
" I(int x);",
|
||||
" I.foo(int x);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" factory I.foo(int x) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I(0);",
|
||||
" new I.foo(0);",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"interface I default F {",
|
||||
" I(int x);",
|
||||
" I.foo(int x);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" factory I.foo(int x) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I(0);",
|
||||
" new I.foo(0);",
|
||||
" }",
|
||||
"}"));
|
||||
// Check errors.
|
||||
{
|
||||
List<DartCompilationError> errors = libraryResult.getCompilationErrors();
|
||||
|
@ -523,21 +549,23 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
*/
|
||||
public void test_resolveInterfaceConstructor_noFactoryImplementsInterface() throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"interface I default F {",
|
||||
" I(int x);",
|
||||
" I.foo(int x);",
|
||||
"}",
|
||||
"class F {",
|
||||
" F.foo(int y) {}",
|
||||
" factory I(int y) {}",
|
||||
" factory I.foo(int y) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I(0);",
|
||||
" new I.foo(0);",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"interface I default F {",
|
||||
" I(int x);",
|
||||
" I.foo(int x);",
|
||||
"}",
|
||||
"class F {",
|
||||
" F.foo(int y) {}",
|
||||
" factory I(int y) {}",
|
||||
" factory I.foo(int y) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I(0);",
|
||||
" new I.foo(0);",
|
||||
" }",
|
||||
"}"));
|
||||
assertErrors(libraryResult.getCompilationErrors());
|
||||
DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
|
||||
// "new I()"
|
||||
|
@ -572,16 +600,18 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
public void test_resolveInterfaceConstructor_noFactoryImplementsInterface_negative()
|
||||
throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"interface I default F {",
|
||||
" I.foo(int x);",
|
||||
"}",
|
||||
"class F {",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I.foo(0);",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"interface I default F {",
|
||||
" I.foo(int x);",
|
||||
"}",
|
||||
"class F {",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I.foo(0);",
|
||||
" }",
|
||||
"}"));
|
||||
// Check errors.
|
||||
{
|
||||
List<DartCompilationError> errors = libraryResult.getCompilationErrors();
|
||||
|
@ -613,17 +643,19 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
public void test_resolveInterfaceConstructor_hasByName_negative_notSameNumberOfRequiredParameters()
|
||||
throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"interface I default F {",
|
||||
" I.foo(int x);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" factory F.foo() {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I.foo();",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"interface I default F {",
|
||||
" I.foo(int x);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" factory F.foo() {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I.foo();",
|
||||
" }",
|
||||
"}"));
|
||||
assertErrors(libraryResult.getTypeErrors());
|
||||
// Check errors.
|
||||
{
|
||||
|
@ -660,23 +692,25 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
public void test_resolveInterfaceConstructor_hasByName_negative_notSameNamedParameters()
|
||||
throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"interface I default F {",
|
||||
" I.foo(int a, [int b, int c]);",
|
||||
" I.bar(int a, [int b, int c]);",
|
||||
" I.baz(int a, [int b]);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" factory F.foo(int any, [int b = 1]) {}",
|
||||
" factory F.bar(int any, [int c = 1, int b = 2]) {}",
|
||||
" factory F.baz(int any, [int c = 1]) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I.foo(0);",
|
||||
" new I.bar(0);",
|
||||
" new I.baz(0);",
|
||||
" }",
|
||||
"}");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"interface I default F {",
|
||||
" I.foo(int a, [int b, int c]);",
|
||||
" I.bar(int a, [int b, int c]);",
|
||||
" I.baz(int a, [int b]);",
|
||||
"}",
|
||||
"class F implements I {",
|
||||
" factory F.foo(int any, [int b = 1]) {}",
|
||||
" factory F.bar(int any, [int c = 1, int b = 2]) {}",
|
||||
" factory F.baz(int any, [int c = 1]) {}",
|
||||
"}",
|
||||
"class Test {",
|
||||
" foo() {",
|
||||
" new I.foo(0);",
|
||||
" new I.bar(0);",
|
||||
" new I.baz(0);",
|
||||
" }",
|
||||
"}"));
|
||||
assertErrors(libraryResult.getTypeErrors());
|
||||
// Check errors.
|
||||
{
|
||||
|
@ -755,21 +789,23 @@ public class ResolverCompilerTest extends CompilerTestCase {
|
|||
*/
|
||||
public void test_setElement_forName_inDeclarations() throws Exception {
|
||||
AnalyzeLibraryResult libraryResult = analyzeLibrary(
|
||||
"// filler filler filler filler filler filler filler filler filler filler",
|
||||
"class A<B extends A> {",
|
||||
" var a1;",
|
||||
" get a2() {}",
|
||||
" A() {}",
|
||||
"}",
|
||||
"var c;",
|
||||
"d(e) {",
|
||||
" var f;",
|
||||
" g() {};",
|
||||
" () {} ();",
|
||||
" h: d(0);",
|
||||
"}",
|
||||
"typedef i();",
|
||||
"");
|
||||
"Test.dart",
|
||||
Joiner.on("\n").join(
|
||||
"// filler filler filler filler filler filler filler filler filler filler",
|
||||
"class A<B extends A> {",
|
||||
" var a1;",
|
||||
" get a2() {}",
|
||||
" A() {}",
|
||||
"}",
|
||||
"var c;",
|
||||
"d(e) {",
|
||||
" var f;",
|
||||
" g() {};",
|
||||
" () {} ();",
|
||||
" h: d(0);",
|
||||
"}",
|
||||
"typedef i();",
|
||||
""));
|
||||
assertErrors(libraryResult.getErrors());
|
||||
DartUnit unit = libraryResult.getLibraryUnitResult().getUnits().iterator().next();
|
||||
// in class A
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,10 +2,10 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library compiler;
|
||||
#library('compiler');
|
||||
|
||||
import 'dart:uri';
|
||||
import 'implementation/apiimpl.dart';
|
||||
#import('dart:uri');
|
||||
#import('implementation/apiimpl.dart');
|
||||
|
||||
// Unless explicitly allowed, passing [:null:] for any argument to the
|
||||
// methods of library will result in a NullPointerException being
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart2js;
|
||||
|
||||
class CodeBuffer implements StringBuffer {
|
||||
StringBuffer buffer;
|
||||
List<CodeBufferMarker> markers;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library colors;
|
||||
#library('colors');
|
||||
|
||||
const String GREEN_COLOR = '\u001b[32m';
|
||||
const String RED_COLOR = '\u001b[31m';
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart2js;
|
||||
|
||||
/**
|
||||
* The [ConstantHandler] keeps track of compile-time constants,
|
||||
* initializations of global and static fields, and default values of
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart2js;
|
||||
|
||||
|
||||
/**
|
||||
* If true, print a warning for each method that was resolved, but not
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart2js;
|
||||
|
||||
interface Operation {
|
||||
final SourceString name;
|
||||
bool isUserDefinable();
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart2js;
|
||||
|
||||
const DART_CONSTANT_SYSTEM = const DartConstantSystem();
|
||||
|
||||
class BitNotOperation implements UnaryOperation {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart2js;
|
||||
|
||||
abstract class ConstantVisitor<R> {
|
||||
R visitSentinel(SentinelConstant constant);
|
||||
R visitFunction(FunctionConstant constant);
|
||||
|
|
|
@ -2,17 +2,17 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library dart2js;
|
||||
#library('dart2js');
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:uri';
|
||||
import 'dart:utf';
|
||||
#import('dart:io');
|
||||
#import('dart:uri');
|
||||
#import('dart:utf');
|
||||
|
||||
import '../compiler.dart' as api;
|
||||
import 'colors.dart' as colors;
|
||||
import 'source_file.dart';
|
||||
import 'filenames.dart';
|
||||
import 'util/uri_extras.dart';
|
||||
#import('../compiler.dart', prefix: 'api');
|
||||
#import('colors.dart', prefix: 'colors');
|
||||
#import('source_file.dart');
|
||||
#import('filenames.dart');
|
||||
#import('util/uri_extras.dart');
|
||||
|
||||
const String LIBRARY_ROOT = '../../../..';
|
||||
const String OUTPUT_LANGUAGE_DART = 'Dart';
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart_backend;
|
||||
|
||||
class ElementAst {
|
||||
final Node ast;
|
||||
final TreeElements treeElements;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart_backend;
|
||||
|
||||
String emitCode(
|
||||
Unparser unparser,
|
||||
Map<LibraryElement, String> imports,
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart_backend;
|
||||
|
||||
class LocalPlaceholder {
|
||||
final String identifier;
|
||||
final Set<Node> nodes;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart_backend;
|
||||
|
||||
Function get _compareNodes =>
|
||||
compareBy((n) => n.getBeginToken().charOffset);
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart_backend;
|
||||
|
||||
class CloningVisitor implements Visitor<Node> {
|
||||
final TreeElements originalTreeElements;
|
||||
final TreeElementMapping cloneTreeElements;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of parser;
|
||||
|
||||
abstract class DiagnosticListener {
|
||||
// TODO(karlklose): replace cancel with better error reporting mechanism.
|
||||
void cancel(String reason, {node, token, instruction, element});
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart2js;
|
||||
|
||||
class EnqueueTask extends CompilerTask {
|
||||
final Enqueuer codegen;
|
||||
final Enqueuer resolution;
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library filenames;
|
||||
#library('filenames');
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:uri';
|
||||
#import('dart:io');
|
||||
#import('dart:uri');
|
||||
|
||||
// TODO(ahe): This library should be replaced by a general
|
||||
// path-munging library.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js;
|
||||
|
||||
abstract class NodeVisitor<T> {
|
||||
T visitProgram(Program node);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library precedence;
|
||||
#library("precedence");
|
||||
|
||||
const EXPRESSION = 0;
|
||||
const ASSIGNMENT = EXPRESSION + 1;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js;
|
||||
|
||||
class Printer implements NodeVisitor {
|
||||
final bool shouldCompressOutput;
|
||||
leg.Compiler compiler;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js_backend;
|
||||
|
||||
typedef void Recompile(Element element);
|
||||
|
||||
class ReturnInfo {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js_backend;
|
||||
|
||||
class ConstantEmitter implements ConstantVisitor {
|
||||
final Compiler compiler;
|
||||
final Namer namer;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js_backend;
|
||||
|
||||
const JAVA_SCRIPT_CONSTANT_SYSTEM = const JavaScriptConstantSystem();
|
||||
|
||||
class JavaScriptBitNotOperation extends BitNotOperation {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js_backend;
|
||||
|
||||
/**
|
||||
* A function element that represents a closure call. The signature is copied
|
||||
* from the given element.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js_backend;
|
||||
|
||||
class CodeEmitterNoEvalTask extends CodeEmitterTask {
|
||||
CodeEmitterNoEvalTask(Compiler compiler,
|
||||
Namer namer,
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js_backend;
|
||||
|
||||
/**
|
||||
* Assigns JavaScript identifiers to Dart variables, class-names and members.
|
||||
*/
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js_backend;
|
||||
|
||||
class NativeEmitter {
|
||||
|
||||
CodeEmitterTask emitter;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js_helper;
|
||||
|
||||
// This class has no constructor. This is on purpose since the instantiation
|
||||
// is shortcut by the compiler.
|
||||
class ConstantMap<V> implements Map<String, V> {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#library('dart:_interceptors');
|
||||
|
||||
import 'dart:coreimpl';
|
||||
#import('dart:coreimpl');
|
||||
|
||||
add$1(var receiver, var value) {
|
||||
if (isJsArray(receiver)) {
|
||||
|
|
|
@ -18,54 +18,54 @@
|
|||
* sockets, processes, HTTP servers and clients, and more.
|
||||
*/
|
||||
#library("dart:io");
|
||||
import "dart:coreimpl";
|
||||
import "dart:math";
|
||||
import "dart:isolate";
|
||||
#import("dart:coreimpl");
|
||||
#import("dart:math");
|
||||
#import("dart:isolate");
|
||||
// TODO(ahe): Should Leg support this library?
|
||||
// #import("dart:nativewrappers");
|
||||
import "dart:uri";
|
||||
import "dart:crypto";
|
||||
import "dart:utf";
|
||||
part '../../../../runtime/bin/buffer_list.dart';
|
||||
#import("dart:uri");
|
||||
#import("dart:crypto");
|
||||
#import("dart:utf");
|
||||
#source('../../../../runtime/bin/buffer_list.dart');
|
||||
// Uses native keyword.
|
||||
//#source('../../../../runtime/bin/common.dart');
|
||||
part '../../../../runtime/bin/chunked_stream.dart';
|
||||
part '../../../../runtime/bin/directory.dart';
|
||||
#source('../../../../runtime/bin/chunked_stream.dart');
|
||||
#source('../../../../runtime/bin/directory.dart');
|
||||
// Uses native keyword.
|
||||
// #source('../../../../runtime/bin/directory_impl.dart');
|
||||
// Uses native keyword.
|
||||
// #source('../../../../runtime/bin/eventhandler.dart');
|
||||
part '../../../../runtime/bin/file.dart';
|
||||
#source('../../../../runtime/bin/file.dart');
|
||||
// Uses native keyword.
|
||||
// #source('../../../../runtime/bin/file_impl.dart');
|
||||
part '../../../../runtime/bin/http.dart';
|
||||
part '../../../../runtime/bin/http_impl.dart';
|
||||
part '../../../../runtime/bin/http_parser.dart';
|
||||
part '../../../../runtime/bin/http_utils.dart';
|
||||
part '../../../../runtime/bin/input_stream.dart';
|
||||
part '../../../../runtime/bin/list_stream.dart';
|
||||
part '../../../../runtime/bin/list_stream_impl.dart';
|
||||
part '../../../../runtime/bin/output_stream.dart';
|
||||
part '../../../../runtime/bin/path.dart';
|
||||
part '../../../../runtime/bin/path_impl.dart';
|
||||
part '../../../../runtime/bin/platform.dart';
|
||||
#source('../../../../runtime/bin/http.dart');
|
||||
#source('../../../../runtime/bin/http_impl.dart');
|
||||
#source('../../../../runtime/bin/http_parser.dart');
|
||||
#source('../../../../runtime/bin/http_utils.dart');
|
||||
#source('../../../../runtime/bin/input_stream.dart');
|
||||
#source('../../../../runtime/bin/list_stream.dart');
|
||||
#source('../../../../runtime/bin/list_stream_impl.dart');
|
||||
#source('../../../../runtime/bin/output_stream.dart');
|
||||
#source('../../../../runtime/bin/path.dart');
|
||||
#source('../../../../runtime/bin/path_impl.dart');
|
||||
#source('../../../../runtime/bin/platform.dart');
|
||||
// Uses native keyword.
|
||||
// #source('../../../../runtime/bin/platform_impl.dart');
|
||||
part '../../../../runtime/bin/process.dart';
|
||||
#source('../../../../runtime/bin/process.dart');
|
||||
// Uses native keyword.
|
||||
// #source('../../../../runtime/bin/process_impl.dart');
|
||||
part '../../../../runtime/bin/socket.dart';
|
||||
#source('../../../../runtime/bin/socket.dart');
|
||||
// Uses native keyword.
|
||||
// #source('../../../../runtime/bin/socket_impl.dart');
|
||||
part '../../../../runtime/bin/socket_stream.dart';
|
||||
part '../../../../runtime/bin/socket_stream_impl.dart';
|
||||
#source('../../../../runtime/bin/socket_stream.dart');
|
||||
#source('../../../../runtime/bin/socket_stream_impl.dart');
|
||||
// Uses native keyword.
|
||||
// #source('../../../../runtime/bin/stdio.dart');
|
||||
part '../../../../runtime/bin/stream_util.dart';
|
||||
part '../../../../runtime/bin/string_stream.dart';
|
||||
part '../../../../runtime/bin/timer_impl.dart';
|
||||
part '../../../../runtime/bin/websocket.dart';
|
||||
part '../../../../runtime/bin/websocket_impl.dart';
|
||||
#source('../../../../runtime/bin/stream_util.dart');
|
||||
#source('../../../../runtime/bin/string_stream.dart');
|
||||
#source('../../../../runtime/bin/timer_impl.dart');
|
||||
#source('../../../../runtime/bin/websocket.dart');
|
||||
#source('../../../../runtime/bin/websocket_impl.dart');
|
||||
|
||||
/**
|
||||
* An [OSError] object holds information about an error from the
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Patch file for the dart:isolate library.
|
||||
|
||||
import "dart:uri";
|
||||
#import("dart:uri");
|
||||
|
||||
/**
|
||||
* Called by the compiler to support switching
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library js_helper;
|
||||
#library('dart:_js_helper');
|
||||
|
||||
import 'dart:coreimpl';
|
||||
#import('dart:coreimpl');
|
||||
|
||||
part 'constant_map.dart';
|
||||
part 'native_helper.dart';
|
||||
part 'regexp_helper.dart';
|
||||
part 'string_helper.dart';
|
||||
#source('constant_map.dart');
|
||||
#source('native_helper.dart');
|
||||
#source('regexp_helper.dart');
|
||||
#source('string_helper.dart');
|
||||
|
||||
// Performance critical helper methods.
|
||||
add(var a, var b) => (a is num && b is num)
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
#library("dart:mirrors");
|
||||
|
||||
import "dart:isolate";
|
||||
#import("dart:isolate");
|
||||
|
||||
part "../../../mirrors/mirrors.dart";
|
||||
#source("../../../mirrors/mirrors.dart");
|
||||
|
||||
/**
|
||||
* Stub class for the mirror system.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js_helper;
|
||||
|
||||
String typeNameInChrome(obj) {
|
||||
String name = JS('String', "#.constructor.name", obj);
|
||||
if (name == 'Window') return 'DOMWindow';
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js_helper;
|
||||
|
||||
List regExpExec(JSSyntaxRegExp regExp, String str) {
|
||||
var nativeRegExp = regExpGetNative(regExp);
|
||||
var result = JS('List', r'#.exec(#)', nativeRegExp, str);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of js_helper;
|
||||
|
||||
class StringMatch implements Match {
|
||||
const StringMatch(int this._start,
|
||||
String this.str,
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart2js;
|
||||
|
||||
/**
|
||||
* [CompilerTask] for loading libraries and setting up the import/export scopes.
|
||||
*/
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of resolution;
|
||||
|
||||
abstract class TreeElements {
|
||||
Element operator[](Node node);
|
||||
Selector getSelector(Send send);
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of dart2js;
|
||||
|
||||
abstract class ResolvedVisitor<R> extends Visitor<R> {
|
||||
TreeElements elements;
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of scanner_implementation;
|
||||
|
||||
abstract
|
||||
class ArrayBasedScanner<S extends SourceString> extends AbstractScanner<S> {
|
||||
int get charOffset => byteOffset + extraCharOffset;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of parser;
|
||||
|
||||
/**
|
||||
* Scanner that reads from a byte array and creates tokens that points
|
||||
* to the same array.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of parser;
|
||||
|
||||
/**
|
||||
* An abstract string representation.
|
||||
*/
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of scanner;
|
||||
|
||||
class ClassElementParser extends PartialParser {
|
||||
ClassElementParser(Listener listener) : super(listener);
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of scanner;
|
||||
|
||||
/**
|
||||
* A keyword in the Dart programming language.
|
||||
*/
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of scanner;
|
||||
|
||||
const bool VERBOSE = false;
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of scanner;
|
||||
|
||||
/**
|
||||
* An event generating parser of Dart programs. This parser expects
|
||||
* all tokens in a linked list (aka a token stream).
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of scanner;
|
||||
|
||||
class ParserTask extends CompilerTask {
|
||||
ParserTask(Compiler compiler) : super(compiler);
|
||||
String get name => 'Parser';
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of scanner;
|
||||
|
||||
class PartialParser extends Parser {
|
||||
PartialParser(Listener listener) : super(listener);
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue