Minor code cleanup.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/FileOutsideWorkspaceIconUpdater.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/FileOutsideWorkspaceIconUpdater.java
index 8bec058..0f00774 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/FileOutsideWorkspaceIconUpdater.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/FileOutsideWorkspaceIconUpdater.java
@@ -11,6 +11,8 @@
import static org.eclipse.core.runtime.Status.OK_STATUS;
import static org.eclipse.xtext.ui.editor.Messages.XtextEditorErrorTickUpdater_JobName;
+import com.google.inject.Inject;
+
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -21,19 +23,15 @@
import org.eclipse.xtext.ui.editor.IXtextEditorCallback.NullImpl;
import org.eclipse.xtext.ui.editor.*;
-import com.google.inject.Inject;
-
/**
* @author alruiz@google.com (Alex Ruiz)
*/
public class FileOutsideWorkspaceIconUpdater extends NullImpl {
private static final ISchedulingRule SEQUENCE_RULE = SchedulingRuleFactory.INSTANCE.newSequence();
- @Inject
- private PluginImageHelper imageHelper;
+ @Inject private PluginImageHelper imageHelper;
- @Override
- public void afterSetInput(XtextEditor editor) {
+ @Override public void afterSetInput(XtextEditor editor) {
IEditorInput editorInput = editor.getEditorInput();
IResource resource = (IResource) editorInput.getAdapter(IResource.class);
if (resource == null) {
@@ -51,8 +49,7 @@
setRule(SEQUENCE_RULE);
}
- @Override
- public IStatus runInUIThread(final IProgressMonitor monitor) {
+ @Override public IStatus runInUIThread(final IProgressMonitor monitor) {
IEditorSite site = null != editor ? editor.getEditorSite() : null;
if (site != null) {
if (!monitor.isCanceled() && titleImage != null && !titleImage.isDisposed() && editor != null) {
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Strings.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Strings.java
index ffbc9df..bdf5afb 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Strings.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Strings.java
@@ -10,10 +10,10 @@
import static org.eclipse.xtext.util.Strings.isEmpty;
-import java.util.Scanner;
-
import com.google.common.base.Function;
+import java.util.Scanner;
+
/**
* Utility methods related to {@code String}.s
*
@@ -76,14 +76,19 @@
}
StringBuilder valueBuilder = new StringBuilder();
Scanner scanner = new Scanner(s);
- while (scanner.hasNextLine()) {
- String line = scanner.nextLine().trim();
- if (transformation != null) {
- line = transformation.apply(line);
+ try {
+ while (scanner.hasNextLine()) {
+ String line = scanner.nextLine().trim();
+ if (transformation != null) {
+ line = transformation.apply(line);
+ }
+ valueBuilder.append(line);
}
- valueBuilder.append(line);
+ } finally {
+ try {
+ scanner.close();
+ } catch (RuntimeException ignored) {}
}
- scanner.close();
return valueBuilder.toString();
}