Revert "Added namespace support to scoping."
This change caused the following tests to fail.
com.google.eclipse.protobuf.naming.NameResolver_nameOf_Test
com.google.eclipse.protobuf.validation.ImportValidator_checkUnknownSyntaxImports_withNonProto2Imports_Tests
com.google.eclipse.protobuf.validation.ProtobufJavaValidator_checkOnlyOnePackageDefinition_Test
com.google.eclipse.protobuf.model.util.Packages_addPackageNameSegments_Test
This reverts commit 4d53754dd76572a85bd84a7847285d7458897e99.
Change-Id: I1417ec7a6f6390bab7291d4d269a2afd4e6ef0fb
diff --git a/com.google.eclipse.protobuf.generator/META-INF/MANIFEST.MF b/com.google.eclipse.protobuf.generator/META-INF/MANIFEST.MF
index bb2b6b6..173239d 100644
--- a/com.google.eclipse.protobuf.generator/META-INF/MANIFEST.MF
+++ b/com.google.eclipse.protobuf.generator/META-INF/MANIFEST.MF
@@ -21,4 +21,3 @@
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: com.google.eclipse.protobuf
-Import-Package: com.google.eclipse.protobuf.scoping
diff --git a/com.google.eclipse.protobuf.generator/bin/.project b/com.google.eclipse.protobuf.generator/bin/.project
new file mode 100644
index 0000000..de89a7e
--- /dev/null
+++ b/com.google.eclipse.protobuf.generator/bin/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>com.google.eclipse.protobuf.generator</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ </natures>
+</projectDescription>
diff --git a/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/GenerateProtobuf.mwe2 b/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/GenerateProtobuf.mwe2
index 473a016..097852b 100644
--- a/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/GenerateProtobuf.mwe2
+++ b/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/GenerateProtobuf.mwe2
@@ -42,14 +42,14 @@
uri = grammarURI
fileExtensions = file.extensions
- // Java APIto access grammar elements (required by several other fragments)
+ // Java API to access grammar elements (required by several other fragments)
fragment = grammarAccess.GrammarAccessFragment {}
- // generates Java APIfor the generated EPackages
+ // generates Java API for the generated EPackages
fragment = ecore.EMFGeneratorFragment {
// referencedGenModels = "uri to genmodel, uri to next genmodel"
}
-
+
// Serializer 2.0
fragment = serializer.SerializerFragment {
generateStub = false
@@ -58,7 +58,7 @@
// the serialization component
// fragment = parseTreeConstructor.ParseTreeConstructorFragment {}
- // a custom ResourceFactory for use with EMF
+ // a custom ResourceFactory for use with EMF
fragment = resourceFactory.ResourceFactoryFragment {
fileExtensions = file.extensions
}
@@ -70,7 +70,7 @@
// }
}
- // java-based APIfor validation
+ // java-based API for validation
fragment = validation.JavaValidatorFragment {
// composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
@@ -81,41 +81,41 @@
// fragment = scoping.ImportURIScopingFragment {}
// fragment = exporting.SimpleNamesFragment {}
- // scoping and exporting API
- fragment = scoping.ProtobufImportNamespacesScopingFragment {}
+ // scoping and exporting API
+ fragment = scoping.ImportNamespacesScopingFragment {}
fragment = exporting.QualifiedNamesFragment {}
fragment = builder.BuilderIntegrationFragment {}
- // formatter API
+ // formatter API
fragment = formatting.FormatterFragment {}
- // labeling API
+ // labeling API
fragment = labeling.LabelProviderFragment {}
- // outline API
+ // outline API
fragment = outline.OutlineTreeProviderFragment {}
fragment = outline.QuickOutlineFragment {}
- // quickfix API
+ // quickfix API
fragment = quickfix.QuickfixProviderFragment {}
// rename refactoring
fragment = refactoring.RefactorElementNameFragment {}
- // content assist API
+ // content assist API
fragment = contentAssist.JavaBasedContentAssistFragment {}
- // generates a more lightweight Antlr parser and lexer tailored for content assist
+ // generates a more lightweight Antlr parser and lexer tailored for content assist
fragment = parser.antlr.XtextAntlrUiGeneratorFragment {
// options = {
// backtrack = true
// }
}
- // project wizard (optional)
+ // project wizard (optional)
// fragment = projectWizard.SimpleProjectWizardFragment {
- // generatorProjectName = "${projectName}.generator"
- // modelFileExtension = file.extensions
+ // generatorProjectName = "${projectName}.generator"
+ // modelFileExtension = file.extensions
// }
}
}
diff --git a/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/Protobuf.xtext b/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/Protobuf.xtext
index 2b99ea7..2a39ba6 100644
--- a/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/Protobuf.xtext
+++ b/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/Protobuf.xtext
@@ -24,7 +24,7 @@
Package | Import | Option | ComplexType | TypeExtension | Service;
Package:
- 'package' importedNamespace=PackageName (';')+;
+ 'package' name=PackageName (';')+;
PackageName:
IdOrReservedWord ('.' IdOrReservedWord)*;
diff --git a/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/scoping/ProtobufImportNamespacesScopingFragment.java b/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/scoping/ProtobufImportNamespacesScopingFragment.java
deleted file mode 100644
index 497b6cc..0000000
--- a/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/scoping/ProtobufImportNamespacesScopingFragment.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2016 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.scoping;
-
-import org.eclipse.xtext.generator.scoping.AbstractScopingFragment;
-import org.eclipse.xtext.scoping.IGlobalScopeProvider;
-import org.eclipse.xtext.scoping.IScopeProvider;
-
-public class ProtobufImportNamespacesScopingFragment extends AbstractScopingFragment {
- @Override
- protected Class<? extends IGlobalScopeProvider> getGlobalScopeProvider() {
- return ProtobufImportUriGlobalScopeProvider.class;
- }
-
- @Override
- protected Class<? extends IScopeProvider> getLocalScopeProvider() {
- return ProtobufImportedNamespaceAwareLocalScopeProvider.class;
- }
-}
diff --git a/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/scoping/ProtobufImportNamespacesScopingFragment.xpt b/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/scoping/ProtobufImportNamespacesScopingFragment.xpt
deleted file mode 100644
index 23c6cc5..0000000
--- a/com.google.eclipse.protobuf.generator/src/com/google/eclipse/protobuf/scoping/ProtobufImportNamespacesScopingFragment.xpt
+++ /dev/null
@@ -1,23 +0,0 @@
-«REM»
-/*******************************************************************************
- * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others.
- * 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
- *
- *******************************************************************************/
-«ENDREM»
-
-«IMPORT org::eclipse::xtext»
-
-
-«DEFINE addToPluginXmlRt(String scopeProviderSuperClassName, Boolean generateStub, Boolean generateXtendStub) FOR Grammar»«ENDDEFINE»
-
-«DEFINE addToPluginXmlUi(String scopeProviderSuperClassName, Boolean generateStub, Boolean generateXtendStub) FOR Grammar»«ENDDEFINE»
-
-«DEFINE addToStandaloneSetup(String scopeProviderSuperClassName, Boolean generateStub, Boolean generateXtendStub) FOR Grammar»«ENDDEFINE»
-
-«DEFINE generate(String scopeProviderSuperClassName, Boolean generateStub, Boolean generateXtendStub) FOR Grammar»
- «EXPAND generator::scoping::AbstractScopingFragment::generateScopeProvider(scopeProviderSuperClassName, generateStub, generateXtendStub)»
-«ENDDEFINE»
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelObjects_packageOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelObjects_packageOf_Test.java
index 043d467..01412d5 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelObjects_packageOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelObjects_packageOf_Test.java
@@ -44,7 +44,7 @@
@Test public void should_return_package_if_proto_has_one() {
MessageField field = xtext.find("id", MessageField.class);
Package aPackage = modelObjects.packageOf(field);
- assertThat(aPackage.getImportedNamespace(), equalTo("person.test"));
+ assertThat(aPackage.getName(), equalTo("person.test"));
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Packages_areRelated_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Packages_areRelated_Test.java
index c9aeec4..2ebfa12 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Packages_areRelated_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Packages_areRelated_Test.java
@@ -49,36 +49,36 @@
"may"
};
p1 = mock(Package.class);
- when(p1.getImportedNamespace()).thenReturn(baseName);
+ when(p1.getName()).thenReturn(baseName);
p2 = mock(Package.class);
}
@Test public void should_return_true_if_packages_are_equal() {
- when(p2.getImportedNamespace()).thenReturn(baseName);
+ when(p2.getName()).thenReturn(baseName);
assertTrue(packages.areRelated(p1, p2));
}
@Test public void should_return_true_second_is_subPackage_of_first() {
for (String name : subpackageNames) {
- when(p2.getImportedNamespace()).thenReturn(name);
+ when(p2.getName()).thenReturn(name);
assertTrue(packages.areRelated(p1, p2));
}
}
@Test public void should_return_true_first_is_subPackage_of_second() {
for (String name : subpackageNames) {
- when(p2.getImportedNamespace()).thenReturn(name);
+ when(p2.getName()).thenReturn(name);
assertTrue(packages.areRelated(p2, p1));
}
}
@Test public void should_return_false_if_second_starts_with_few_segments_of_first_but_is_not_subpackage() {
- when(p2.getImportedNamespace()).thenReturn("may.the.ring");
+ when(p2.getName()).thenReturn("may.the.ring");
assertFalse(packages.areRelated(p1, p2));
}
@Test public void should_return_false_if_names_are_completely_different() {
- when(p2.getImportedNamespace()).thenReturn("peace.dog");
+ when(p2.getName()).thenReturn("peace.dog");
assertFalse(packages.areRelated(p1, p2));
}
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ImportValidator_checkUnknownSyntaxImports_withNonProto2Imports_Tests.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ImportValidator_checkUnknownSyntaxImports_withNonProto2Imports_Tests.java
index 47e4e6c..c8b91bc 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ImportValidator_checkUnknownSyntaxImports_withNonProto2Imports_Tests.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ImportValidator_checkUnknownSyntaxImports_withNonProto2Imports_Tests.java
@@ -10,7 +10,7 @@
import static com.google.eclipse.protobuf.junit.core.IntegrationTestModule.integrationTestModule;
import static com.google.eclipse.protobuf.junit.core.XtextRule.overrideRuntimeModuleWith;
-import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.PACKAGE__IMPORTED_NAMESPACE;
+import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.IMPORT__PATH;
import static com.google.eclipse.protobuf.validation.Messages.importingUnsupportedSyntax;
import static org.eclipse.xtext.validation.ValidationMessageAcceptor.INSIGNIFICANT_INDEX;
import static org.mockito.Mockito.mock;
@@ -104,7 +104,7 @@
private void verifyThatImportingUnknownSyntaxFileCreatedWarning(Import anImport) {
verify(messageAcceptor).acceptWarning(importingUnsupportedSyntax,
anImport,
- PACKAGE__IMPORTED_NAMESPACE,
+ IMPORT__PATH,
INSIGNIFICANT_INDEX,
null,
new String[0]);
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkOnlyOnePackageDefinition_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkOnlyOnePackageDefinition_Test.java
index 5bf5457..df880f4 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkOnlyOnePackageDefinition_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator_checkOnlyOnePackageDefinition_Test.java
@@ -15,7 +15,7 @@
import static com.google.eclipse.protobuf.junit.core.UnitTestModule.unitTestModule;
import static com.google.eclipse.protobuf.junit.core.XtextRule.overrideRuntimeModuleWith;
-import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.PACKAGE__IMPORTED_NAMESPACE;
+import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.PACKAGE__NAME;
import static com.google.eclipse.protobuf.validation.Messages.multiplePackages;
import static com.google.eclipse.protobuf.validation.ProtobufJavaValidator.MORE_THAN_ONE_PACKAGE_ERROR;
@@ -51,7 +51,7 @@
@Test public void should_create_error_if_there_are_more_than_one_package_definitions() {
Package p = xtext.find("com.google.eclipse", Package.class);
validator.checkOnlyOnePackageDefinition(p);
- verify(messageAcceptor).acceptError(multiplePackages, p, PACKAGE__IMPORTED_NAMESPACE, INSIGNIFICANT_INDEX, MORE_THAN_ONE_PACKAGE_ERROR);
+ verify(messageAcceptor).acceptError(multiplePackages, p, PACKAGE__NAME, INSIGNIFICANT_INDEX, MORE_THAN_ONE_PACKAGE_ERROR);
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/ProtobufUiModule.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/ProtobufUiModule.java
index a40d43a..0b90171 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/ProtobufUiModule.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/ProtobufUiModule.java
@@ -43,7 +43,6 @@
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider;
-import org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator;
import org.eclipse.xtext.parser.IParser;
import org.eclipse.xtext.resource.IResourceServiceProvider;
import org.eclipse.xtext.ui.LanguageSpecific;
@@ -54,6 +53,7 @@
import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreInitializer;
import org.eclipse.xtext.ui.editor.syntaxcoloring.AbstractAntlrTokenToAttributeIdMapper;
import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfiguration;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
import org.eclipse.xtext.ui.resource.SimpleResourceSetProvider;
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/hyperlinking/ProtobufHyperlinkDetector.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/hyperlinking/ProtobufHyperlinkDetector.java
index e6b4aa9..c2482ee 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/hyperlinking/ProtobufHyperlinkDetector.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/hyperlinking/ProtobufHyperlinkDetector.java
@@ -8,7 +8,7 @@
*/
package com.google.eclipse.protobuf.ui.editor.hyperlinking;
-import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.PACKAGE__IMPORTED_NAMESPACE;
+import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.IMPORT__PATH;
import com.google.eclipse.protobuf.model.util.INodes;
import com.google.eclipse.protobuf.model.util.Imports;
@@ -71,7 +71,7 @@
if (!imports.isResolved(anImport)) {
return NO_HYPERLINKS;
}
- INode importUriNode = nodes.firstNodeForFeature(anImport, PACKAGE__IMPORTED_NAMESPACE);
+ INode importUriNode = nodes.firstNodeForFeature(anImport, IMPORT__PATH);
if (importUriNode.getLength() == 0) {
return NO_HYPERLINKS;
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java
index b0046aa..95ab1bb 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java
@@ -35,11 +35,10 @@
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor;
-import org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.resource.XtextResource;
-import org.eclipse.xtext.util.CancelIndicator;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightedPositionAcceptor;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator;
import com.google.eclipse.protobuf.model.util.INodes;
import com.google.eclipse.protobuf.model.util.IndexedElements;
@@ -78,11 +77,7 @@
@Inject private INodes nodes;
@Inject private Options options;
- @Override
- public void provideHighlightingFor(
- XtextResource resource,
- IHighlightedPositionAcceptor acceptor,
- CancelIndicator cancelIndicator) {
+ @Override public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
if (resource == null) {
return;
}
@@ -162,8 +157,7 @@
private void highlight(IndexedElement element, IHighlightedPositionAcceptor acceptor) {
highlightName(element, acceptor, DEFAULT_ID);
- highlightFirstFeature(
- element, indexedElements.indexFeatureOf(element), acceptor, MESSAGE_FIELD_INDEX_ID);
+ highlightFirstFeature(element, indexedElements.indexFeatureOf(element), acceptor, MESSAGE_FIELD_INDEX_ID);
highlightOptions(element, acceptor);
if (element instanceof Group) {
highlight((Group) element, acceptor);
@@ -275,18 +269,11 @@
}
private void highlightName(EObject o, IHighlightedPositionAcceptor acceptor, String highlightId) {
- EStructuralFeature feature = o.eClass().getEStructuralFeature("name");
- if (feature == null) {
- feature = o.eClass().getEStructuralFeature("importedNamespace");
- }
- highlightFirstFeature(o, feature, acceptor, highlightId);
+ highlightFirstFeature(o, o.eClass().getEStructuralFeature("name"), acceptor, highlightId);
}
- private void highlightFirstFeature(
- EObject semantic,
- EStructuralFeature feature,
- IHighlightedPositionAcceptor acceptor,
- String highlightId) {
+ private void highlightFirstFeature(EObject semantic, EStructuralFeature feature,
+ IHighlightedPositionAcceptor acceptor, String highlightId) {
INode node = nodes.firstNodeForFeature(semantic, feature);
if (node == null) {
return;
diff --git a/com.google.eclipse.protobuf/META-INF/MANIFEST.MF b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
index e76431d..589dac1 100644
--- a/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
+++ b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
@@ -18,7 +18,8 @@
org.eclipse.xtext,
org.eclipse.xtext.generator;resolution:=optional,
org.eclipse.xtext.ui,
- org.eclipse.xtext.util
+ org.eclipse.xtext.util,
+ com.google.eclipse.protobuf.generator;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.google.eclipse.protobuf,
com.google.eclipse.protobuf.conversion,
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufRuntimeModule.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufRuntimeModule.java
index 378fe86..541b1a1 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufRuntimeModule.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufRuntimeModule.java
@@ -15,6 +15,7 @@
import com.google.eclipse.protobuf.resource.FastXtextResourceSet;
import com.google.eclipse.protobuf.resource.GlobalResourceServiceProvider;
import com.google.eclipse.protobuf.scoping.ExtensionRegistryProvider;
+import com.google.eclipse.protobuf.scoping.ProtobufGlobalScopeProvider;
import com.google.eclipse.protobuf.validation.ProtobufResourceValidator;
import com.google.eclipse.protobuf.validation.ProtobufSyntaxErrorMessageProvider;
import com.google.inject.Binder;
@@ -27,11 +28,11 @@
import org.eclipse.xtext.resource.IGlobalServiceProvider;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceSet;
+import org.eclipse.xtext.scoping.IGlobalScopeProvider;
import org.eclipse.xtext.validation.IResourceValidator;
/**
- * Use this class to register components to be used at runtime / without the Equinox extension
- * registry.
+ * Use this class to register components to be used at runtime / without the Equinox extension registry.
*/
public class ProtobufRuntimeModule extends AbstractProtobufRuntimeModule {
public Class<? extends IGlobalServiceProvider> bindIGlobalServiceProvider() {
@@ -42,8 +43,7 @@
return ProtobufQualifiedNameConverter.class;
}
- @Override
- public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
+ @Override public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
return ProtobufQualifiedNameProvider.class;
}
@@ -55,21 +55,22 @@
return ProtobufSyntaxErrorMessageProvider.class;
}
- @Override
- public Class<? extends IValueConverterService> bindIValueConverterService() {
+ @Override public Class<? extends IValueConverterService> bindIValueConverterService() {
return ProtobufTerminalConverters.class;
}
- @Override
- public Class<? extends XtextResource> bindXtextResource() {
+ @Override public Class<? extends XtextResource> bindXtextResource() {
return ProtobufResource.class;
}
- @Override
- public Class<? extends XtextResourceSet> bindXtextResourceSet() {
+ @Override public Class<? extends XtextResourceSet> bindXtextResourceSet() {
return FastXtextResourceSet.class;
}
+ @Override public Class<? extends IGlobalScopeProvider> bindIGlobalScopeProvider() {
+ return ProtobufGlobalScopeProvider.class;
+ }
+
public void configureExtensionRegistry(Binder binder) {
binder.bind(IExtensionRegistry.class).toProvider(ExtensionRegistryProvider.class);
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Packages.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Packages.java
index 324b9c3..66a57f6 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Packages.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Packages.java
@@ -130,7 +130,7 @@
}
private QualifiedName nameOf(Package p) {
- String name = p.getImportedNamespace();
+ String name = p.getName();
return (isEmpty(name)) ? null : qualifiedNameConverter.toQualifiedName(name);
}
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufGlobalScopeProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufGlobalScopeProvider.java
new file mode 100644
index 0000000..9f10eb0
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufGlobalScopeProvider.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2014 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.scoping;
+
+import com.google.eclipse.protobuf.model.util.Protobufs;
+import com.google.eclipse.protobuf.model.util.Resources;
+import com.google.eclipse.protobuf.protobuf.Import;
+import com.google.eclipse.protobuf.protobuf.Protobuf;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider;
+import org.eclipse.xtext.util.IAcceptor;
+import org.eclipse.xtext.util.IResourceScopeCache;
+
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+
+/**
+ * A global scope provider that reads each {@link Import} in the protobuf file, resolves it, and
+ * caches the result.
+ */
+public class ProtobufGlobalScopeProvider extends ImportUriGlobalScopeProvider {
+ @Inject
+ private IResourceScopeCache cache;
+
+ @Inject
+ private Resources resources;
+
+ @Inject
+ private Protobufs protobufs;
+
+ @Inject
+ private IImportResolver importResolver;
+
+ @Override
+ protected LinkedHashSet<URI> getImportedUris(final Resource resource) {
+ return cache.get(ProtobufGlobalScopeProvider.class.getName(), resource,
+ new Provider<LinkedHashSet<URI>>() {
+ @Override
+ public LinkedHashSet<URI> get() {
+ final LinkedHashSet<URI> uniqueImportURIs = new LinkedHashSet<>(5);
+ IAcceptor<String> collector = createURICollector(resource, uniqueImportURIs);
+ Protobuf protobuf = resources.rootOf(resource);
+ if (protobuf == null) {
+ return uniqueImportURIs;
+ }
+ for (Import anImport : protobufs.importsIn(protobuf)) {
+ collector.accept(importResolver.resolve(anImport));
+ }
+ Iterator<URI> uriIter = uniqueImportURIs.iterator();
+ while (uriIter.hasNext()) {
+ if (!EcoreUtil2.isValidUri(resource, uriIter.next())) {
+ uriIter.remove();
+ }
+ }
+ return uniqueImportURIs;
+ }
+ });
+ }
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufImportUriGlobalScopeProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufImportUriGlobalScopeProvider.java
deleted file mode 100644
index bc84250..0000000
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufImportUriGlobalScopeProvider.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2014 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.scoping;
-
-import com.google.eclipse.protobuf.model.util.Imports;
-import com.google.eclipse.protobuf.model.util.Protobufs;
-import com.google.eclipse.protobuf.model.util.Resources;
-import com.google.eclipse.protobuf.protobuf.Import;
-import com.google.eclipse.protobuf.protobuf.Protobuf;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider;
-import org.eclipse.xtext.util.IResourceScopeCache;
-
-import java.util.LinkedHashSet;
-
-/**
- * A global scope provider that reads each {@link Import} in the protobuf file, resolves it, and
- * caches the result.
- */
-public class ProtobufImportUriGlobalScopeProvider extends ImportUriGlobalScopeProvider {
- @Inject private Protobufs protobufs;
- @Inject private Resources resources;
- @Inject private Imports imports;
- @Inject private IResourceScopeCache cache;
-
- @Override
- protected LinkedHashSet<URI> getImportedUris(final Resource resource) {
- return cache.get(
- ProtobufImportUriGlobalScopeProvider.class.getName(),
- resource,
- new Provider<LinkedHashSet<URI>>() {
- @Override
- public LinkedHashSet<URI> get() {
- LinkedHashSet<URI> importedUris = new LinkedHashSet<>();
- Protobuf protobuf = resources.rootOf(resource);
- if (protobuf == null) {
- return importedUris;
- }
- for (Import singleImport : protobufs.importsIn(protobuf)) {
- resolveImport(importedUris, singleImport);
- }
- return importedUris;
- }
-
- private void addPublicImportedUris(Protobuf protobuf, LinkedHashSet<URI> importedUris) {
- for (Import singleImport : protobufs.publicImportsIn(protobuf)) {
- resolveImport(importedUris, singleImport);
- }
- }
-
- private void resolveImport(LinkedHashSet<URI> importedUris, Import singleImport) {
- if (imports.isResolved(singleImport)) {
- importedUris.add(imports.resolvedUriOf(singleImport));
- Protobuf root = resources.rootOf(imports.importedResource(singleImport));
- if (root != null) {
- addPublicImportedUris(root, importedUris);
- }
- }
- }
- });
- }
-}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufImportedNamespaceAwareLocalScopeProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufImportedNamespaceAwareLocalScopeProvider.java
deleted file mode 100644
index de3ccb1..0000000
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufImportedNamespaceAwareLocalScopeProvider.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2016 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.scoping;
-
-import org.eclipse.xtext.naming.QualifiedName;
-import org.eclipse.xtext.scoping.impl.ImportNormalizer;
-import org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider;
-import org.eclipse.xtext.util.Strings;
-import com.google.eclipse.protobuf.naming.ProtobufQualifiedNameConverter;
-import com.google.inject.Inject;
-
-public class ProtobufImportedNamespaceAwareLocalScopeProvider
- extends ImportedNamespaceAwareLocalScopeProvider {
- @Inject private ProtobufQualifiedNameConverter qualifiedNameConverter;
-
- /**
- * Creates a new {@link ImportNormalizer} for the given namespace.
- *
- * @param namespace the namespace.
- * @param ignoreCase <code>true</code> if the resolver should be case insensitive.
- * @return a new {@link ImportNormalizer} or {@code null} if the namespace cannot be
- * converted to a valid qualified name.
- */
- @Override
- protected ImportNormalizer createImportedNamespaceResolver(
- final String namespace, boolean ignoreCase) {
- if (Strings.isEmpty(namespace)) {
- return null;
- }
- QualifiedName importedNamespace = qualifiedNameConverter.toQualifiedName(namespace);
- if (importedNamespace == null || importedNamespace.isEmpty()) {
- return null;
- }
- return doCreateImportNormalizer(importedNamespace, true, ignoreCase);
- }
-}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
index b164957..3c6e173 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
@@ -11,7 +11,7 @@
import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.MAP_TYPE__KEY_TYPE;
import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.MAP_TYPE__VALUE_TYPE;
import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.MESSAGE_FIELD__MODIFIER;
-import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.PACKAGE__IMPORTED_NAMESPACE;
+import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.PACKAGE__NAME;
import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.SYNTAX__NAME;
import static com.google.eclipse.protobuf.validation.Messages.expectedFieldNumber;
import static com.google.eclipse.protobuf.validation.Messages.expectedSyntaxIdentifier;
@@ -380,7 +380,7 @@
for (ProtobufElement e : root.getElements()) {
if (e == aPackage) {
if (firstFound) {
- error(multiplePackages, aPackage, PACKAGE__IMPORTED_NAMESPACE, MORE_THAN_ONE_PACKAGE_ERROR);
+ error(multiplePackages, aPackage, PACKAGE__NAME, MORE_THAN_ONE_PACKAGE_ERROR);
}
return;
}