Limited error messages in refactoring dialog to errors in affected files (Bug 303561)
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/IntroImplicitNoneRefactoring.java b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/IntroImplicitNoneRefactoring.java
index 7144189..f1259b1 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/IntroImplicitNoneRefactoring.java
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/IntroImplicitNoneRefactoring.java
@@ -75,7 +75,7 @@
protected void doCheckFinalConditions(RefactoringStatus status, IProgressMonitor pm)
throws PreconditionFailure
{
- logVPGErrors(status);
+ logVPGErrors(status, this.selectedFiles);
try
{
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/FortranEditorRefactoring.java b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/FortranEditorRefactoring.java
index c0d77ed..3c68cc7 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/FortranEditorRefactoring.java
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/FortranEditorRefactoring.java
@@ -81,7 +81,7 @@
checkIfFileIsAccessibleAndWritable(fileInEditor);
this.astOfFileInEditor = vpg.acquireTransientAST(fileInEditor);
- logVPGErrors(status);
+ logVPGErrors(status, fileInEditor);
if (astOfFileInEditor == null)
fail("The file in the editor cannot be parsed.");
}
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/FortranResourceRefactoring.java b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/FortranResourceRefactoring.java
index a712b90..0abc44c 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/FortranResourceRefactoring.java
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/infrastructure/FortranResourceRefactoring.java
@@ -85,7 +85,7 @@
@Override
protected final void preCheckInitialConditions(RefactoringStatus status, IProgressMonitor pm) throws PreconditionFailure
{
- status.addWarning("C preprocessor directives are IGNORED by the refactoring engine. Use at your own risk.");
+ //status.addWarning("C preprocessor directives are IGNORED by the refactoring engine. Use at your own risk.");
if (FIXED_FORM_REFACTORING_ENABLED)
{
diff --git a/org.eclipse.rephraserengine.core.vpg/src/org/eclipse/rephraserengine/core/vpg/refactoring/VPGEditorRefactoring.java b/org.eclipse.rephraserengine.core.vpg/src/org/eclipse/rephraserengine/core/vpg/refactoring/VPGEditorRefactoring.java
index 09d793d..d0af893 100644
--- a/org.eclipse.rephraserengine.core.vpg/src/org/eclipse/rephraserengine/core/vpg/refactoring/VPGEditorRefactoring.java
+++ b/org.eclipse.rephraserengine.core.vpg/src/org/eclipse/rephraserengine/core/vpg/refactoring/VPGEditorRefactoring.java
@@ -39,7 +39,7 @@
checkIfFileIsAccessibleAndWritable(fileInEditor);
this.astOfFileInEditor = vpg.acquireTransientAST(fileInEditor);
- logVPGErrors(status);
+ logVPGErrors(status, fileInEditor);
if (astOfFileInEditor == null)
fail("The file in the editor cannot be parsed.");
}
diff --git a/org.eclipse.rephraserengine.core.vpg/src/org/eclipse/rephraserengine/core/vpg/refactoring/VPGRefactoring.java b/org.eclipse.rephraserengine.core.vpg/src/org/eclipse/rephraserengine/core/vpg/refactoring/VPGRefactoring.java
index d783f18..44934a0 100644
--- a/org.eclipse.rephraserengine.core.vpg/src/org/eclipse/rephraserengine/core/vpg/refactoring/VPGRefactoring.java
+++ b/org.eclipse.rephraserengine.core.vpg/src/org/eclipse/rephraserengine/core/vpg/refactoring/VPGRefactoring.java
@@ -4,6 +4,8 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.util.Collection;
+import java.util.Collections;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
@@ -87,15 +89,40 @@
protected void logVPGErrors(RefactoringStatus status)
{
+ logVPGErrors(status, (Collection<IFile>)null);
+ }
+
+ protected void logVPGErrors(RefactoringStatus status, IFile file)
+ {
+ logVPGErrors(status, file == null ? null : Collections.singleton(file));
+ }
+
+ protected void logVPGErrors(RefactoringStatus status, Collection<IFile> files)
+ {
for (VPGLog<T, ? extends TokenRef<T>>.Entry entry : vpg.log.getEntries())
{
- if (entry.isWarning())
- status.addWarning(entry.getMessage(), createContext(entry.getTokenRef()));
- else
- status.addError(entry.getMessage(), createContext(entry.getTokenRef()));
+ if (files == null || contains(files, entry.getTokenRef()))
+ {
+ if (entry.isWarning())
+ status.addWarning(entry.getMessage(), createContext(entry.getTokenRef()));
+ else
+ status.addError(entry.getMessage(), createContext(entry.getTokenRef()));
+ }
}
}
+ private boolean contains(Collection<IFile> files, TokenRef<T> tokenRef)
+ {
+ if (files == null || tokenRef == null || tokenRef.getFilename() == null)
+ return false;
+
+ IFile file = EclipseVPG.getIFileForFilename(tokenRef.getFilename());
+ if (file == null)
+ return false;
+
+ return files.contains(file);
+ }
+
@Override
public final RefactoringStatus checkFinalConditions(IProgressMonitor pm)
{