Minor code cleanup.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/ProtobufDocumentProvider.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/ProtobufDocumentProvider.java
index fbf009e..096238b 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/ProtobufDocumentProvider.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/model/ProtobufDocumentProvider.java
@@ -11,6 +11,7 @@
import static com.google.eclipse.protobuf.ui.ProtobufUiModule.PLUGIN_ID;
import static com.google.eclipse.protobuf.ui.util.Resources.URI_SCHEME_FOR_FILES;
import static com.google.eclipse.protobuf.util.Closeables.close;
+import static com.google.eclipse.protobuf.util.Encodings.UTF_8;
import static java.util.Collections.singletonMap;
import static org.eclipse.core.runtime.IStatus.ERROR;
import static org.eclipse.emf.common.util.URI.createURI;
@@ -42,8 +43,6 @@
*/
public class ProtobufDocumentProvider extends XtextDocumentProvider {
- private static final String ENCODING = "UTF-8";
-
@Inject private IResourceSetProvider resourceSetProvider;
@Inject private Resources resources;
@@ -69,7 +68,7 @@
FileInfo info = new FileInfo(document, model, null);
info.fModificationStamp = fileInfo.getLastModified();
info.fStatus = status;
- info.fEncoding = ENCODING;
+ info.fEncoding = UTF_8;
cacheEncodingState(input);
return info;
}
@@ -125,14 +124,14 @@
}
private Reader readerFor(InputStream inputStream) throws IOException {
- return new InputStreamReader(inputStream, ENCODING);
+ return new InputStreamReader(inputStream, UTF_8);
}
private XtextResource createResource(String uri, InputStream input) {
ResourceSet resourceSet = resourceSetProvider.get(resources.activeProject());
XtextResource resource = (XtextResource) resourceSet.createResource(createURI(uri), UNSPECIFIED_CONTENT_TYPE);
try {
- resource.load(input, singletonMap(OPTION_ENCODING, ENCODING));
+ resource.load(input, singletonMap(OPTION_ENCODING, UTF_8));
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
index 37706cf..37f3efa 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
@@ -11,6 +11,7 @@
import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.PROPERTY__TYPE;
import static com.google.eclipse.protobuf.scoping.OptionType.*;
import static com.google.eclipse.protobuf.util.Closeables.close;
+import static com.google.eclipse.protobuf.util.Encodings.UTF_8;
import static java.util.Collections.unmodifiableCollection;
import static org.eclipse.xtext.EcoreUtil2.*;
import static org.eclipse.xtext.util.CancelIndicator.NullImpl;
@@ -18,7 +19,7 @@
import com.google.eclipse.protobuf.protobuf.*;
import com.google.eclipse.protobuf.protobuf.Enum;
-import com.google.eclipse.protobuf.util.ModelNodes;
+import com.google.eclipse.protobuf.util.*;
import com.google.inject.Inject;
import org.eclipse.emf.common.util.URI;
@@ -59,7 +60,7 @@
InputStreamReader reader = null;
try {
XtextResource resource = new XtextResource(descriptorLocation);
- reader = new InputStreamReader(contents(descriptorLocation), "UTF-8");
+ reader = new InputStreamReader(contents(descriptorLocation), UTF_8);
IParseResult result = parser.parse(reader);
root = (Protobuf) result.getRootASTElement();
resource.getContents().add(root);
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Encodings.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Encodings.java
new file mode 100644
index 0000000..f5e9e7d
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Encodings.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2011 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.util;
+
+/**
+ * Encodings used in this project.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public final class Encodings {
+
+ public static final String UTF_8 = "UTF-8";
+
+ private Encodings() {}
+}