Fixed:
[Issue 195] Unresolved URIs of imported platform resources should be
checked also against the file system.
[Issue 196] Imports of files outside the workspace should perform
lookup in same directory.
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/AbstractTestModule.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/AbstractTestModule.java
index 6e24620..ab743eb 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/AbstractTestModule.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/AbstractTestModule.java
@@ -16,7 +16,7 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public abstract class AbstractTestModule extends AbstractModule {
- protected <T> void createAndBindMock(Class<T> classToMock) {
+ protected <T> void mockAndBind(Class<T> classToMock) {
binder().bind(classToMock).toInstance(mock(classToMock));
}
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/IntegrationTestModule.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/IntegrationTestModule.java
index deac9ca..beafd75 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/IntegrationTestModule.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/IntegrationTestModule.java
@@ -33,7 +33,7 @@
@Override protected void configure() {
binder().bind(IFileUriResolver.class).to(FileUriResolver.class);
- createAndBindMock(EReference.class);
+ mockAndBind(EReference.class);
}
private static class FileUriResolver implements IFileUriResolver {
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/editor/ModelObjectDefinitionNavigator_navigateToDefinition_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/editor/ModelObjectDefinitionNavigator_navigateToDefinition_Test.java
index 8ca1d1f..c4372a0 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/editor/ModelObjectDefinitionNavigator_navigateToDefinition_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/editor/ModelObjectDefinitionNavigator_navigateToDefinition_Test.java
@@ -56,8 +56,8 @@
private static class TestModule extends AbstractTestModule {
@Override protected void configure() {
- createAndBindMock(ModelObjectLocationLookup.class);
- createAndBindMock(IURIEditorOpener.class);
+ mockAndBind(ModelObjectLocationLookup.class);
+ mockAndBind(IURIEditorOpener.class);
}
}
}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/MultipleDirectoriesFileResolverStrategy_resolveUri_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/MultipleDirectoriesFileResolverStrategy_resolveUri_Test.java
new file mode 100644
index 0000000..43f4279
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/MultipleDirectoriesFileResolverStrategy_resolveUri_Test.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.scoping;
+
+import static com.google.eclipse.protobuf.junit.core.UnitTestModule.unitTestModule;
+import static com.google.eclipse.protobuf.junit.core.XtextRule.overrideRuntimeModuleWith;
+import static java.util.Collections.singletonList;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.*;
+
+import org.eclipse.emf.common.util.URI;
+import org.junit.*;
+
+import com.google.eclipse.protobuf.junit.core.*;
+import com.google.eclipse.protobuf.ui.preferences.StringPreference;
+import com.google.eclipse.protobuf.ui.preferences.paths.core.PathsPreferences;
+import com.google.eclipse.protobuf.ui.util.Uris;
+import com.google.inject.Inject;
+
+/**
+ * Tests for <code>{@link MultipleDirectoriesFileResolverStrategy#resolveUri(String, URI, Iterable)}</code>.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class MultipleDirectoriesFileResolverStrategy_resolveUri_Test {
+ private static URI declaringResourceUri;
+
+ @BeforeClass public static void setUpOnce() {
+ declaringResourceUri = URI.createURI("platform:/resource/project/src/test.proto");
+ }
+
+ @Rule public XtextRule xtext = overrideRuntimeModuleWith(unitTestModule(), new TestModule());
+
+ @Inject private PathMapping mapping;
+ @Inject private Uris uris;
+ @Inject private MultipleDirectoriesFileResolverStrategy resolver;
+
+ private StringPreference directoryPaths;
+ private PathsPreferences preferences;
+ private Iterable<PathsPreferences> allPreferences;
+
+ @Before public void setUp() {
+ directoryPaths = mock(StringPreference.class);
+ preferences = mock(PathsPreferences.class);
+ allPreferences = singletonList(preferences);
+ when(preferences.directoryPaths()).thenReturn(directoryPaths);
+ }
+
+ @Test public void should_resolve_platform_resource_URI() {
+ String expected = "platform:/resource/src/protos/imported.proto";
+ when(directoryPaths.getValue()).thenReturn("${workspace_loc:/src/protos}");
+ when(uris.exists(URI.createURI(expected))).thenReturn(true);
+ String resolved = resolver.resolveUri("imported.proto", declaringResourceUri, allPreferences);
+ assertThat(resolved, equalTo(expected));
+ }
+
+ @Test public void should_resolve_file_URI() {
+ String expected = "file:/usr/local/project/src/protos/imported.proto";
+ when(directoryPaths.getValue()).thenReturn("/usr/local/project/src/protos");
+ when(uris.exists(URI.createURI(expected))).thenReturn(true);
+ String resolved = resolver.resolveUri("imported.proto", declaringResourceUri, allPreferences);
+ assertThat(resolved, equalTo(expected));
+ }
+
+ @Test public void should_fall_back_to_file_system_if_platform_resource_URI_cannot_be_resolved() {
+ String expected = "file:/usr/local/project/src/protos/imported.proto";
+ when(directoryPaths.getValue()).thenReturn("${workspace_loc:/src/protos}");
+ // try the first time as resource platform
+ when(uris.exists(URI.createURI("platform:/resource/src/protos/imported.proto"))).thenReturn(false);
+ when(mapping.directoryLocation("/src/protos")).thenReturn("/usr/local/project/src/protos");
+ // try again, but in the file system this time
+ when(uris.exists(URI.createURI(expected))).thenReturn(true);
+ String resolved = resolver.resolveUri("imported.proto", declaringResourceUri, allPreferences);
+ assertThat(resolved, equalTo(expected));
+ }
+
+ @Test public void should_return_null_if_platform_resource_URI_cannot_be_resolved() {
+ when(directoryPaths.getValue()).thenReturn("${workspace_loc:/src/protos}");
+ when(uris.exists(any(URI.class))).thenReturn(false);
+ String resolved = resolver.resolveUri("imported.proto", declaringResourceUri, allPreferences);
+ assertNull(resolved);
+ }
+
+ @Test public void should_return_null_if_file_URI_cannot_be_resolved() {
+ when(directoryPaths.getValue()).thenReturn("/usr/local/project/src/protos");
+ when(uris.exists(any(URI.class))).thenReturn(false);
+ String resolved = resolver.resolveUri("imported.proto", declaringResourceUri, allPreferences);
+ assertNull(resolved);
+ }
+
+ private static class TestModule extends AbstractTestModule {
+ @Override protected void configure() {
+ mockAndBind(Uris.class);
+ mockAndBind(PathMapping.class);
+ }
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolverStrategy_resolveUri_withPlatformResourceUri_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolverStrategy_resolveUri_withPlatformResourceUri_Test.java
index ae2d5bb..6da6c3f 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolverStrategy_resolveUri_withPlatformResourceUri_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/scoping/SingleDirectoryFileResolverStrategy_resolveUri_withPlatformResourceUri_Test.java
@@ -14,14 +14,13 @@
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.*;
-import com.google.eclipse.protobuf.junit.core.*;
-import com.google.eclipse.protobuf.ui.preferences.paths.core.PathsPreferences;
-import com.google.eclipse.protobuf.ui.util.Uris;
-import com.google.inject.Inject;
-
import org.eclipse.emf.common.util.URI;
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.*;
+import com.google.eclipse.protobuf.ui.util.Uris;
+import com.google.inject.Inject;
+
/**
* Tests for <code>{@link SingleDirectoryFileResolverStrategy#resolveUri(String, URI, Iterable)}</code>.
*
@@ -69,7 +68,6 @@
private static class TestModule extends AbstractTestModule {
@Override protected void configure() {
- createAndBindMock(PathsPreferences.class);
binder().bind(Uris.class).toInstance(UrisStub.instance());
}
}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_exists_withFile_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_exists_withFile_Test.java
new file mode 100644
index 0000000..4e4c18e
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_exists_withFile_Test.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.util;
+
+import static com.google.eclipse.protobuf.junit.core.UnitTestModule.unitTestModule;
+import static com.google.eclipse.protobuf.junit.core.XtextRule.overrideRuntimeModuleWith;
+import static org.junit.Assert.*;
+
+import java.io.*;
+
+import org.eclipse.emf.common.util.URI;
+import org.junit.*;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.inject.Inject;
+
+/**
+ * Tests for <code>{@link Uris#exists(URI)}</code>
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class Uris_exists_withFile_Test {
+ @Rule public TemporaryFolder folder = new TemporaryFolder();
+ @Rule public XtextRule xtext = overrideRuntimeModuleWith(unitTestModule());
+
+ @Inject private Uris uris;
+
+ @Test public void should_return_true_if_file_resource_exists() throws IOException {
+ File file = folder.newFile("existing_file.txt");
+ URI fileUri = URI.createFileURI(file.getAbsolutePath());
+ assertTrue(uris.exists(fileUri));
+ }
+
+ @Test public void should_return_false_if_file_resource_does_not_exist() {
+ URI fileUri = URI.createFileURI("/usr/local/not_existing_file.txt");
+ assertFalse(uris.exists(fileUri));
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_exists_withPlatformResource_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_exists_withPlatformResource_Test.java
new file mode 100644
index 0000000..7bc6301
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_exists_withPlatformResource_Test.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.util;
+
+import static com.google.eclipse.protobuf.junit.core.UnitTestModule.unitTestModule;
+import static com.google.eclipse.protobuf.junit.core.XtextRule.overrideRuntimeModuleWith;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+import org.eclipse.emf.common.util.URI;
+import org.junit.*;
+
+import com.google.eclipse.protobuf.junit.core.*;
+import com.google.inject.Inject;
+
+/**
+ * Tests for <code>{@link Uris#exists(URI)}</code>
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class Uris_exists_withPlatformResource_Test {
+ private static URI resourceUri;
+
+ @BeforeClass public static void setUpOnce() {
+ resourceUri = URI.createURI("platform:/resource/project/src/protos/test.proto");
+ }
+
+ @Rule public XtextRule xtext = overrideRuntimeModuleWith(unitTestModule(), new TestModule());
+
+ @Inject private Resources resources;
+ @Inject private Uris uris;
+
+ @Test public void should_return_true_if_platform_resource_exists() {
+ when(resources.fileExists(resourceUri)).thenReturn(true);
+ assertTrue(uris.exists(resourceUri));
+ }
+
+ @Test public void should_return_false_if_platform_resource_does_not_exist() {
+ when(resources.fileExists(resourceUri)).thenReturn(false);
+ assertFalse(uris.exists(resourceUri));
+ }
+
+ private static class TestModule extends AbstractTestModule {
+ @Override protected void configure() {
+ mockAndBind(Resources.class);
+ }
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_prefixOf_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_prefixOf_Test.java
new file mode 100644
index 0000000..e6d65da
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_prefixOf_Test.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.util;
+
+import static com.google.eclipse.protobuf.junit.core.UnitTestModule.unitTestModule;
+import static com.google.eclipse.protobuf.junit.core.XtextRule.overrideRuntimeModuleWith;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+import org.eclipse.emf.common.util.URI;
+import org.junit.*;
+
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.inject.Inject;
+
+/**
+ * Tests for <code>{@link Uris#prefixOf(URI)}</code>
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class Uris_prefixOf_Test {
+ @Rule public XtextRule xtext = overrideRuntimeModuleWith(unitTestModule());
+
+ @Inject private Uris uris;
+
+ @Test public void should_return_prefix_of_file_URI() {
+ URI uri = URI.createURI("file:/usr/local/project/src/protos/test.proto");
+ assertThat(uris.prefixOf(uri), equalTo("file:"));
+ }
+
+ @Test public void should_return_prefix_of_platform_resource_URI() {
+ URI uri = URI.createURI("platform:/resource/project/src/protos/test.proto");
+ assertThat(uris.prefixOf(uri), equalTo("platform:/resource"));
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_segmentsWithoutFileName_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_segmentsWithoutFileName_Test.java
new file mode 100644
index 0000000..4ed9ecd
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Uris_segmentsWithoutFileName_Test.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.util;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static com.google.eclipse.protobuf.junit.core.UnitTestModule.unitTestModule;
+import static com.google.eclipse.protobuf.junit.core.XtextRule.overrideRuntimeModuleWith;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.eclipse.emf.common.util.URI;
+import org.junit.*;
+
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.inject.Inject;
+
+/**
+ * Tests for <code>{@link Uris#segmentsWithoutFileName(URI)}</code>
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class Uris_segmentsWithoutFileName_Test {
+ @Rule public XtextRule xtext = overrideRuntimeModuleWith(unitTestModule());
+
+ @Inject private Uris uris;
+
+ @Test public void should_remove_last_segment_if_URI_refers_to_file() {
+ URI uri = URI.createURI("file:/usr/local/project/src/protos/test.proto");
+ List<String> expected = newArrayList("usr", "local", "project", "src", "protos");
+ assertThat(uris.segmentsWithoutFileName(uri), equalTo(expected));
+ }
+
+ @Test public void should_remove_first_and_last_segments_if_URI_refers_to_platform_resource() {
+ URI uri = URI.createURI("platform:/resource/project/src/protos/test.proto");
+ List<String> expected = newArrayList("project", "src", "protos");
+ assertThat(uris.segmentsWithoutFileName(uri), equalTo(expected));
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/UriEditorInputs.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/UriEditorInputs.java
index 5adf27f..c829f0f 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/UriEditorInputs.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/UriEditorInputs.java
@@ -8,8 +8,6 @@
*/
package com.google.eclipse.protobuf.ui.editor.model;
-import static com.google.eclipse.protobuf.ui.util.Resources.URI_SCHEME_FOR_FILES;
-
import java.io.File;
import java.net.URI;
@@ -21,6 +19,8 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton class UriEditorInputs {
+ private static final String URI_SCHEME_FOR_FILES = "file";
+
File fileFrom(IURIEditorInput input) {
URI uri = input.getURI();
String scheme = uri.getScheme();
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/MultipleDirectoriesFileResolverStrategy.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/MultipleDirectoriesFileResolverStrategy.java
index e32b856..21364a1 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/MultipleDirectoriesFileResolverStrategy.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/scoping/MultipleDirectoriesFileResolverStrategy.java
@@ -13,17 +13,15 @@
import static com.google.eclipse.protobuf.ui.util.Uris.*;
import static org.eclipse.core.runtime.IPath.SEPARATOR;
+import java.util.List;
+
+import org.eclipse.emf.common.util.URI;
+
import com.google.eclipse.protobuf.ui.preferences.paths.core.*;
import com.google.eclipse.protobuf.ui.util.Uris;
import com.google.inject.Inject;
-import org.eclipse.emf.common.util.URI;
-
-import java.util.List;
-
/**
- * TODO test
- *
* @author alruiz@google.com (Alex Ruiz)
*/
class MultipleDirectoriesFileResolverStrategy implements FileResolverStrategy {
@@ -43,7 +41,7 @@
private String resolveUri(String importUri, URI declaringResourceUri, PathsPreferences preferences) {
String directoryPaths = preferences.directoryPaths().getValue();
- List<String> fileSystemDirectories = newArrayList();
+ List<String> unresolvedWorkspacePaths = newArrayList();
for (String importRoot : splitCsv(directoryPaths)) {
DirectoryPath path = DirectoryPath.parse(importRoot, preferences.getProject());
String resolved = resolveUri(importUri, path);
@@ -51,10 +49,10 @@
return resolved;
}
if (path.isWorkspacePath()) {
- fileSystemDirectories.add(path.value());
+ unresolvedWorkspacePaths.add(path.value());
}
}
- for (String root : fileSystemDirectories) {
+ for (String root : unresolvedWorkspacePaths) {
String directoryLocation = mapping.directoryLocation(root);
String resolved = resolveUriInFileSystem(importUri, directoryLocation);
if (resolved != null) {
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Resources.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Resources.java
index 35aa444..d3e94d3 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Resources.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Resources.java
@@ -11,8 +11,7 @@
import static com.google.eclipse.protobuf.ui.util.Workbenches.activeWorkbenchPage;
import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.*;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.*;
@@ -29,16 +28,11 @@
@Singleton public class Resources {
private static final IViewReference[] NO_VIEW_REFERENCES = new IViewReference[0];
- public static final String URI_SCHEME_FOR_FILES = "file";
-
/**
* Returns the project that contains the resource at the given URI.
- *
- * @param resourceUri
- * the given URI.
- * @return the project that contains the resource at the given URI, or
- * {@code null} if the resource at the given URI is not in a
- * workspace.
+ * @param resourceUri the given URI.
+ * @return the project that contains the resource at the given URI, or {@code null} if the resource at the given URI
+ * is not in a workspace.
*/
public IProject project(URI resourceUri) {
IFile file = file(resourceUri);
@@ -69,11 +63,8 @@
/**
* Indicates whether the given URI belongs to an existing file.
- *
- * @param fileUri
- * the URI to check, as a {@code String}.
- * @return {@code true} if the given URI belongs to an existing file,
- * {@code false} otherwise.
+ * @param fileUri the URI to check, as a {@code String}.
+ * @return {@code true} if the given URI belongs to an existing file, {@code false} otherwise.
*/
public boolean fileExists(URI fileUri) {
IFile file = file(fileUri);
@@ -82,11 +73,9 @@
/**
* Returns a handle to a workspace file identified by the given URI.
- *
- * @param uri
- * the given URI.
+ * @param uri the given URI.
* @return a handle to a workspace file identified by the given URI or
- * {@code null} if the URI does not belong to a workspace file.
+ * {@code null} if the URI does not belong to a workspace file.
*/
public IFile file(URI uri) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
@@ -96,9 +85,7 @@
/**
* Returns the project owning the file displayed in the given editor.
- *
- * @param editor
- * the given editor.
+ * @param editor the given editor.
* @return the project owning the file displayed in the given editor.
*/
public IProject project(IEditorPart editor) {
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Uris.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Uris.java
index 8f10cc7..a7d3527 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Uris.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Uris.java
@@ -11,18 +11,16 @@
import static com.google.common.collect.Lists.newArrayList;
import static java.util.Collections.*;
-import com.google.inject.*;
-
-import org.eclipse.emf.common.util.URI;
-
import java.io.File;
import java.util.List;
+import org.eclipse.emf.common.util.URI;
+
+import com.google.inject.*;
+
/**
* Utility methods related to URIs.
*
- * TODO test
- *
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class Uris {