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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartLibraryImpl.java

Issue 10827286: Fix for issue 4429 - remove #resource directive (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartLibraryImpl.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartLibraryImpl.java (revision 10526)
+++ editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartLibraryImpl.java (working copy)
@@ -21,7 +21,6 @@
import com.google.dart.compiler.UrlLibrarySource;
import com.google.dart.compiler.ast.DartImportDirective;
import com.google.dart.compiler.ast.DartLibraryDirective;
-import com.google.dart.compiler.ast.DartResourceDirective;
import com.google.dart.compiler.ast.DartSourceDirective;
import com.google.dart.compiler.ast.DartStringLiteral;
import com.google.dart.compiler.ast.DartUnit;
@@ -54,7 +53,6 @@
import com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities;
import com.google.dart.tools.core.utilities.general.SourceUtilities;
import com.google.dart.tools.core.utilities.io.FileUtilities;
-import com.google.dart.tools.core.utilities.net.URIUtilities;
import com.google.dart.tools.core.utilities.resource.IFileUtilities;
import com.google.dart.tools.core.utilities.resource.IProjectUtilities;
import com.google.dart.tools.core.workingcopy.WorkingCopyOwner;
@@ -82,11 +80,10 @@
import java.util.Set;
/**
- * Instances of the class <code>DartLibraryImpl</code> implement an object that represents a Dart
- * library.
+ * Instances of the class <code>DartLibraryImpl</code> implement an object that represents a Dart library.
*/
-public class DartLibraryImpl extends OpenableElementImpl implements DartLibrary,
- CompilationUnitContainer {
+public class DartLibraryImpl extends OpenableElementImpl
+ implements DartLibrary, CompilationUnitContainer {
public static final DartLibraryImpl[] EMPTY_LIBRARY_ARRAY = new DartLibraryImpl[0];
/**
@@ -99,8 +96,9 @@
* @throws DartModelException if the transitive compilation units cannot be determined for some
* reason
*/
- private static void addCompilationUnitsTransitively(DartLibrary library,
- Set<CompilationUnit> units, Set<DartLibrary> libraries) throws DartModelException {
+ private static void addCompilationUnitsTransitively(
+ DartLibrary library, Set<CompilationUnit> units, Set<DartLibrary> libraries)
+ throws DartModelException {
if (!libraries.contains(library)) {
libraries.add(library);
@@ -191,8 +189,8 @@
* Initialize a newly created library to be contained in the given project.
*
* @param project the project containing this library (not <code>null</code>)
- * @param libraryFile the file containing the children of this library or <code>null</code> if
- * this is not part of the workspace
+ * @param libraryFile the file containing the children of this library or <code>null</code> if this is
+ * not part of the workspace
* @param sourceFile the library source file
*/
public DartLibraryImpl(DartProjectImpl project, IFile libraryFile, LibrarySource sourceFile) {
@@ -304,8 +302,8 @@
if (this == o) {
return true;
}
- return o instanceof DartLibraryImpl
- && getElementName().equals(((DartLibraryImpl) o).getElementName());
+ return o instanceof DartLibraryImpl && getElementName().equals(
+ ((DartLibraryImpl) o).getElementName());
}
@Override
@@ -549,8 +547,8 @@
}
/**
- * Return the URI of the library file that defines this library, or <code>null</code> if there is
- * no such file or if the URI for the file cannot be determined for some reason.
+ * Return the URI of the library file that defines this library, or <code>null</code> if there is no
+ * such file or if the URI for the file cannot be determined for some reason.
*
* @return the URI of the library file that defines this library
*/
@@ -579,8 +577,9 @@
try {
children = getChildren();
} catch (DartModelException e) {
- DartCore.logError("Could not determine whether " + getDisplayName()
- + " contains a main() method", e);
+ DartCore.logError(
+ "Could not determine whether " + getDisplayName() + " contains a main() method",
+ e);
return false;
}
for (DartElement child : children) {
@@ -590,8 +589,10 @@
try {
functions = unit.getChildrenOfType(DartFunction.class);
} catch (DartModelException e) {
- DartCore.logError("Could not determine whether " + unit.getElementName() + " in "
- + getDisplayName() + " contains a main() method", e);
+ DartCore.logError(
+ "Could not determine whether " + unit.getElementName() + " in " + getDisplayName()
+ + " contains a main() method",
+ e);
continue;
}
for (DartFunction funct : functions) {
@@ -628,8 +629,8 @@
}
/**
- * Answer <code>true</code> if the receiver directly or indirectly imports the dart:dom_deprecated
- * or dart:html libraries
+ * Answer <code>true</code> if the receiver directly or indirectly imports the dart:dom_deprecated or
+ * dart:html libraries
*/
public boolean isOrImportsBrowserLibrary() {
List<DartLibrary> visited = new ArrayList<DartLibrary>(10);
@@ -699,9 +700,8 @@
topLevel ? "true" : null);
DartElementDeltaImpl delta = new DartElementDeltaImpl(this);
delta.changed(DartElementDelta.F_TOP_LEVEL);
- DartModelManager.getInstance().getDeltaProcessor().fire(
- delta,
- ElementChangedEvent.POST_CHANGE);
+ DartModelManager.getInstance()
+ .getDeltaProcessor().fire(delta, ElementChangedEvent.POST_CHANGE);
} catch (CoreException exception) {
// Ignore
}
@@ -783,9 +783,8 @@
try {
librarySource = sourceFile.getImportFor(relativePath);
} catch (Exception exception) {
- DartCore.logError(
- "Failed to resolve import " + relativePath + " in " + sourceFile.getUri(),
- exception);
+ DartCore.logError("Failed to resolve import " + relativePath + " in "
+ + sourceFile.getUri(), exception);
return null;
}
if (librarySource == null) {
@@ -872,25 +871,6 @@
}
@Override
- public Void visitResourceDirective(DartResourceDirective node) {
- String relativePath = getRelativePath(node.getResourceUri());
- if (relativePath == null) {
- return null;
- }
- DartSource source = sourceFile.getSourceFor(relativePath);
- if (source == null) {
- return null;
- }
- URI uri = URIUtilities.makeAbsolute(source.getUri());
- try {
- children.add(new DartResourceImpl(DartLibraryImpl.this, uri));
- } catch (Exception exception) {
- // Ignore invalid directives
- }
- return null;
- }
-
- @Override
public Void visitSourceDirective(DartSourceDirective node) {
String relativePath = getRelativePath(node.getSourceUri());
if (relativePath == null || relativePath.length() == 0) {
@@ -965,8 +945,8 @@
}
@Override
- protected DartElement getHandleFromMemento(String token, MementoTokenizer tokenizer,
- WorkingCopyOwner owner) {
+ protected DartElement getHandleFromMemento(
+ String token, MementoTokenizer tokenizer, WorkingCopyOwner owner) {
switch (token.charAt(0)) {
case MEMENTO_DELIMITER_COMPILATION_UNIT:
if (!tokenizer.hasMoreTokens()) {
@@ -999,8 +979,8 @@
return this;
}
String htmlPath = tokenizer.nextToken();
- HTMLFileImpl file = new HTMLFileImpl(this, libraryFile.getProject().getFile(
- new Path(htmlPath)));
+ HTMLFileImpl file = new HTMLFileImpl(this, libraryFile.getProject().getFile(new Path(
+ htmlPath)));
return file.getHandleFromMemento(tokenizer, owner);
case MEMENTO_DELIMITER_RESOURCE:
if (!tokenizer.hasMoreTokens()) {
@@ -1052,8 +1032,9 @@
* prevent superclass method from trying to open the parent of an external library.
*/
@Override
- protected void openAncestors(HashMap<DartElement, DartElementInfo> newElements,
- IProgressMonitor monitor) throws DartModelException {
+ protected void openAncestors(
+ HashMap<DartElement, DartElementInfo> newElements, IProgressMonitor monitor)
+ throws DartModelException {
if (getParent().exists()) {
super.openAncestors(newElements, monitor);
}
@@ -1071,8 +1052,8 @@
*
* @param directiveName the name of the directive (with the leading pound sign)
* @param file the file to reference in the directive
- * @param monitor the progress monitor used to provide feedback to the user, or <code>null</code>
- * if no feedback is desired
+ * @param monitor the progress monitor used to provide feedback to the user, or <code>null</code> if
+ * no feedback is desired
* @return <code>true</code> if the change was saved to disk, requiring the model to be updated
* @throws DartModelException if the directive cannot be added
*/
@@ -1084,15 +1065,17 @@
monitor);
boolean hadUnsavedChanges = workingCopy.hasUnsavedChanges();
Buffer buffer = workingCopy.getBuffer();
- String relativePath = libraryFile.getLocation().removeLastSegments(1).toFile().toURI().relativize(
- file.toURI()).getPath();
+ String relativePath = libraryFile.getLocation()
+ .removeLastSegments(1).toFile().toURI().relativize(file.toURI()).getPath();
int insertionPoint = SourceUtilities.findInsertionPointForSource(
buffer.getContents(),
directiveName,
relativePath);
// TODO(brianwilkerson) This won't add a blank line if this is the first directive of its kind.
- buffer.replace(insertionPoint, 0, directiveName + "('" + relativePath + "');"
- + SourceUtilities.LINE_SEPARATOR);
+ buffer.replace(
+ insertionPoint,
+ 0,
+ directiveName + "('" + relativePath + "');" + SourceUtilities.LINE_SEPARATOR);
workingCopy.makeConsistent(monitor);
if (!hadUnsavedChanges) {
@@ -1137,8 +1120,9 @@
try {
children = getChildren();
} catch (DartModelException e) {
- DartCore.logError("Could not determine if " + getDisplayName()
- + " has an HTML file referencing it", e);
+ DartCore.logError(
+ "Could not determine if " + getDisplayName() + " has an HTML file referencing it",
+ e);
return false;
}
for (DartElement child : children) {
@@ -1148,8 +1132,10 @@
try {
referencedLibraries = htmlFile.getReferencedLibraries();
} catch (DartModelException e) {
- DartCore.logError("Could not determine if " + htmlFile.getElementName() + " references "
- + getDisplayName(), e);
+ DartCore.logError(
+ "Could not determine if " + htmlFile.getElementName() + " references "
+ + getDisplayName(),
+ e);
continue;
}
for (DartLibrary lib : referencedLibraries) {
@@ -1173,10 +1159,8 @@
try {
if (sourceFile != null) {
fileName = sourceFile.getName();
- return DartCompilerUtilities.parseSource(
- fileName,
- FileUtilities.getContents(sourceFile.getSourceReader()),
- null);
+ return DartCompilerUtilities.parseSource(fileName, FileUtilities.getContents(
+ sourceFile.getSourceReader()), null);
}
if (libraryFile != null && libraryFile.exists()) {
fileName = libraryFile.getName();

Powered by Google App Engine
This is Rietveld 408576698