Code cleanup.
diff --git a/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/parser/PreferenceDrivenProtobufParser_doParse_Test.java b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/parser/PreferenceDrivenProtobufParser_doParse_Test.java
index b8173ad..c360142 100644
--- a/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/parser/PreferenceDrivenProtobufParser_doParse_Test.java
+++ b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/parser/PreferenceDrivenProtobufParser_doParse_Test.java
@@ -9,7 +9,6 @@
package com.google.eclipse.protobuf.ui.parser;
import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
-import static com.google.eclipse.protobuf.ui.Internals.plugInInjector;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.*;
@@ -23,6 +22,7 @@
import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.parser.NonProto2Protobuf;
import com.google.eclipse.protobuf.protobuf.Protobuf;
+import com.google.eclipse.protobuf.ui.ProtobufPlugIn;
/**
* Tests for <code>{@link PreferenceDrivenProtobufParser#doParse(String, CharStream, NodeModelBuilder, int)}</code>.
@@ -39,7 +39,7 @@
proto1 = proto.toString();
}
- @Rule public XtextRule xtext = createWith(plugInInjector());
+ @Rule public XtextRule xtext = createWith(ProtobufPlugIn.injector());
private IPreferenceStore store;
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/Internals.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/ProtobufPlugIn.java
similarity index 77%
rename from com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/Internals.java
rename to com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/ProtobufPlugIn.java
index 084654b..b8cf323 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/Internals.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/ProtobufPlugIn.java
@@ -14,10 +14,14 @@
/**
* @author alruiz@google.com (Alex Ruiz)
*/
-public final class Internals {
+public final class ProtobufPlugIn {
private static final String LANGUAGE_NAME = "com.google.eclipse.protobuf.Protobuf";
- public static Injector plugInInjector() {
+ public static <T> T getInstance(Class<T> type) {
+ return injector().getInstance(type);
+ }
+
+ public static Injector injector() {
return ProtobufActivator.getInstance().getInjector(languageName());
}
@@ -25,5 +29,5 @@
return LANGUAGE_NAME;
}
- private Internals() {}
+ private ProtobufPlugIn() {}
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/ValidateOnActivation.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/ValidateOnActivation.java
index 80eec59..38da096 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/ValidateOnActivation.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/ValidateOnActivation.java
@@ -9,7 +9,6 @@
*/
package com.google.eclipse.protobuf.ui.validation;
-import static com.google.eclipse.protobuf.ui.Internals.plugInInjector;
import static com.google.eclipse.protobuf.ui.preferences.general.core.GeneralPreferences.generalPreferences;
import static com.google.eclipse.protobuf.ui.validation.Validation.validate;
@@ -17,6 +16,7 @@
import org.eclipse.ui.*;
import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
+import com.google.eclipse.protobuf.ui.ProtobufPlugIn;
import com.google.eclipse.protobuf.ui.preferences.general.core.GeneralPreferences;
import com.google.eclipse.protobuf.ui.util.Resources;
@@ -45,12 +45,12 @@
}
private IProject projectFrom(IEditorPart editor) {
- Resources resources = plugInInjector().getInstance(Resources.class);
+ Resources resources = ProtobufPlugIn.getInstance(Resources.class);
return resources.project(editor);
}
private boolean shouldValidateEditor(IProject project) {
- IPreferenceStoreAccess storeAccess = plugInInjector().getInstance(IPreferenceStoreAccess.class);
+ IPreferenceStoreAccess storeAccess = ProtobufPlugIn.getInstance(IPreferenceStoreAccess.class);
GeneralPreferences preferences = generalPreferences(storeAccess, project);
return preferences.validateFilesOnActivation().getValue();
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/Validation.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/Validation.java
index 9e89547..477a07b 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/Validation.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/validation/Validation.java
@@ -9,7 +9,7 @@
package com.google.eclipse.protobuf.ui.validation;
import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.IMPORT__IMPORT_URI;
-import static com.google.eclipse.protobuf.ui.Internals.*;
+import static com.google.eclipse.protobuf.ui.ProtobufPlugIn.languageName;
import static org.eclipse.xtext.EcoreUtil2.getAllContentsOfType;
import java.util.List;
@@ -27,6 +27,7 @@
import com.google.eclipse.protobuf.conversion.STRINGValueConverter;
import com.google.eclipse.protobuf.model.util.INodes;
import com.google.eclipse.protobuf.protobuf.Import;
+import com.google.eclipse.protobuf.ui.ProtobufPlugIn;
/**
* @author alruiz@google.com (Alex Ruiz)
@@ -111,12 +112,12 @@
if (text == null) {
return null;
}
- STRINGValueConverter converter = plugInInjector().getInstance(STRINGValueConverter.class);
+ STRINGValueConverter converter = ProtobufPlugIn.getInstance(STRINGValueConverter.class);
return converter.toValue(text, node);
}
private static INodes nodes() {
- return plugInInjector().getInstance(INodes.class);
+ return ProtobufPlugIn.getInstance(INodes.class);
}
private Validation() {}