Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariano Mendez2012-05-26 19:43:50 +0000
committerJeffrey Overbey2012-05-26 19:43:50 +0000
commit3fccdb2746393d6a87d4150a369338033c4f1882 (patch)
treedfc3b530f30fcc40055d63a224b577b17fbf954b
parent6507f6c56c7de86a12edd82b32224d99083a5fba (diff)
downloadorg.eclipse.photran-3fccdb2746393d6a87d4150a369338033c4f1882.tar.gz
org.eclipse.photran-3fccdb2746393d6a87d4150a369338033c4f1882.tar.xz
org.eclipse.photran-3fccdb2746393d6a87d4150a369338033c4f1882.zip
Bug 345493 - [Refactoring] Change To Vector Notation - Patch
-rw-r--r--org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/ChangeToVectorNotationRefactoring.java40
-rw-r--r--org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/Messages.java2
-rw-r--r--org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/messages.properties3
3 files changed, 37 insertions, 8 deletions
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/ChangeToVectorNotationRefactoring.java b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/ChangeToVectorNotationRefactoring.java
index d2e0e16f..80e6dca6 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/ChangeToVectorNotationRefactoring.java
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/ChangeToVectorNotationRefactoring.java
@@ -46,6 +46,7 @@ import org.eclipse.photran.internal.core.reindenter.Reindenter.Strategy;
*/
public class ChangeToVectorNotationRefactoring extends FortranEditorRefactoring
{
+
private ASTProperLoopConstructNode DoLoopNode =null;
@Override
public String getName()
@@ -76,8 +77,19 @@ public class ChangeToVectorNotationRefactoring extends FortranEditorRefactoring
this.DoLoopNode.accept(dependencyFinder);
this.DoLoopNode.getBody().accept(changer);
- if ((!changer.canBeChanged() || dependencyFinder.getHasDependencies() ) ) //
- fail(Messages.ChangeToVectorNotation_CanNotBeChangedToVectorNotation);
+ if ((!changer.canBeChanged() || dependencyFinder.getHasDependencies() ) )
+ {
+ if (!changer.canBeChanged())
+ {
+ fail(
+ Messages.bind(
+ Messages.ChangeToVectorNotation_CanNotBeChanged,
+ changer.failMessage)
+ );
+ }
+ else
+ fail(Messages.ChangeToVectorNotation_CanNotBeChangedToVectorNotation);
+ }
}
private void ensureDoLoopHasBeenSelected()
@@ -115,8 +127,7 @@ public class ChangeToVectorNotationRefactoring extends FortranEditorRefactoring
// Do something with
IASTNode newNode = getNewCode(this.DoLoopNode);
this.DoLoopNode.replaceWith(newNode.toString().trim()+"\n"); //$NON-NLS-1$
- //this.DoLoopNode.removeFromTree();
- Reindenter.reindent(this.DoLoopNode, this.astOfFileInEditor, Strategy.SHIFT_ENTIRE_BLOCK);
+ Reindenter.reindent(this.DoLoopNode, this.astOfFileInEditor, Strategy.REINDENT_EACH_LINE );
this.addChangeFromModifiedAST(this.fileInEditor, pm);
vpg.releaseAST(this.fileInEditor);
}
@@ -145,7 +156,6 @@ public class ChangeToVectorNotationRefactoring extends FortranEditorRefactoring
token.replaceWith(s2);
}
}
-
});
return newBody;
}
@@ -206,7 +216,8 @@ public class ChangeToVectorNotationRefactoring extends FortranEditorRefactoring
{
private boolean CanChangeVectorNotation=true;
private String indexVarName;
-
+ private String failMessage=""; //$NON-NLS-1$
+
public VectorNotationVisitor(String indexVarName)
{
super();
@@ -217,6 +228,11 @@ public class ChangeToVectorNotationRefactoring extends FortranEditorRefactoring
{
return CanChangeVectorNotation;
}
+
+ public String getFailMessage()
+ {
+ return this.failMessage;
+ }
@Override public void visitIExecutionPartConstruct(IExecutionPartConstruct node)
{
@@ -262,10 +278,17 @@ public class ChangeToVectorNotationRefactoring extends FortranEditorRefactoring
if (!definitions.isEmpty() && definitions.size()==1)
{
Definition symbol = definitions.get(0);
- if (!symbol.isArray()) return false; //if lhsVariable is not an array it can not be changed
+ if (!symbol.isArray())
+ {
+ this.failMessage= "Variable " + lhsVariable.getText() + " must be an explicitly defined array"; //$NON-NLS-1$ //$NON-NLS-2$
+ return false; //if lhsVariable is not an array it can not be changed
+ }
}
else
+ {
+ this.failMessage= "Variable " + lhsVariable.getText() + " must be an explicitly defined array"; //$NON-NLS-1$ //$NON-NLS-2$
return false;
+ }
}
else
@@ -290,4 +313,7 @@ public class ChangeToVectorNotationRefactoring extends FortranEditorRefactoring
}
}
+
+
+
} \ No newline at end of file
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/Messages.java b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/Messages.java
index 55169aad..916c12cc 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/Messages.java
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/Messages.java
@@ -84,6 +84,8 @@ public class Messages extends NLS
public static String ChangeToVectorNotation_PleaseSelectDoLoopNode;
public static String ChangeToVectorNotation_PleaseSelectNewStyleDoLoopNode;
+
+ public static String ChangeToVectorNotation_CanNotBeChanged;
public static String ChangeToVectorNotation_CanNotBeChangedToVectorNotation;
diff --git a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/messages.properties b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/messages.properties
index 9b9405ca..05f39d8c 100644
--- a/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/messages.properties
+++ b/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/messages.properties
@@ -226,7 +226,8 @@ StandardizeStatementsRefactoring_Name=Standardize Statements
StandardizeStatementsRefactoring_SelectedFileCannotBeParsed=One of the selected files ({0}) cannot be parsed.
ChangeToVectorNotation_PleaseSelectDoLoopNode=Please select a DO LOOP statement.
ChangeToVectorNotation_PleaseSelectNewStyleDoLoopNode=Please select a new style DO LOOP statement ended with END DO statement.
-ChangeToVectorNotation_CanNotBeChangedToVectorNotation= Can not be changed to vector notation, subindex dependencies may be found or Do Loop can not be vectorized.IfConstructStatementConversionRefactoring_Name= Convert Between If Statement and If Construct
+ChangeToVectorNotation_CanNotBeChangedToVectorNotation= Cannot be changed to vector notation, subindex dependencies may be found.
+ChangeToVectorNotation_CanNotBeChanged=Can not be changed ({0})
IfConstructStatementConversionRefactoring_Name=Convert Between If Statement and If Construct
IfConstructStatementConversionRefactoring_SelectAValidIfStatement= Please select a valid IF statement or construct.
IfConstructStatementConversionRefactoring_InvalidNamedConstruct= Cannot refactor a named IF construct. Please select an unnamed IF construct.

Back to the top