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

Unified Diff: dart/compiler/java/com/google/dart/compiler/DartCompiler.java

Issue 11233061: Revert "Parts must start with 'part of'" and "Attempt to fix VM build" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/compiler/java/com/google/dart/compiler/DartCompilerErrorCode.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/compiler/java/com/google/dart/compiler/DartCompiler.java
diff --git a/dart/compiler/java/com/google/dart/compiler/DartCompiler.java b/dart/compiler/java/com/google/dart/compiler/DartCompiler.java
index 2ff7554df0bf477d93cd0505e469ec8e97ffeb0c..c044940b433c925ca9e7c016cef3fa48a449bfa9 100644
--- a/dart/compiler/java/com/google/dart/compiler/DartCompiler.java
+++ b/dart/compiler/java/com/google/dart/compiler/DartCompiler.java
@@ -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));
- }
- } 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));
+ 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 {
- 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() {
« no previous file with comments | « no previous file | dart/compiler/java/com/google/dart/compiler/DartCompilerErrorCode.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698