Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 185202 Details for
Bug 332596
Refactoring [427]: Add Subroutine Parameter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch containing Add Subroutine Parameter refactoring.
SachaMowha_patch (text/plain), 74.65 KB, created by
Joseph Handzik
on 2010-12-15 01:33:43 EST
(
hide
)
Description:
Patch containing Add Subroutine Parameter refactoring.
Filename:
MIME Type:
Creator:
Joseph Handzik
Created:
2010-12-15 01:33:43 EST
Size:
74.65 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.photran.core.vpg >Index: src/org/eclipse/photran/internal/core/refactoring/AddSubroutineParameterRefactoring.java >=================================================================== >RCS file: src/org/eclipse/photran/internal/core/refactoring/AddSubroutineParameterRefactoring.java >diff -N src/org/eclipse/photran/internal/core/refactoring/AddSubroutineParameterRefactoring.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/photran/internal/core/refactoring/AddSubroutineParameterRefactoring.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,584 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 University of Illinois at Urbana-Champaign and others. >+ * 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 >+ * >+ * Contributors: >+ * UIUC - Initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.photran.internal.core.refactoring; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.Collections; >+import java.util.HashSet; >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.ltk.core.refactoring.RefactoringStatusContext; >+import org.eclipse.photran.internal.core.analysis.binding.Definition; >+import org.eclipse.photran.internal.core.analysis.binding.ScopingNode; >+import org.eclipse.photran.internal.core.lexer.Terminal; >+import org.eclipse.photran.internal.core.lexer.Token; >+import org.eclipse.photran.internal.core.parser.ASTCallStmtNode; >+import org.eclipse.photran.internal.core.parser.ASTEntityDeclNode; >+import org.eclipse.photran.internal.core.parser.ASTIntConstNode; >+import org.eclipse.photran.internal.core.parser.ASTListNode; >+import org.eclipse.photran.internal.core.parser.ASTSeparatedListNode; >+import org.eclipse.photran.internal.core.parser.ASTSubroutineArgNode; >+import org.eclipse.photran.internal.core.parser.ASTSubroutineParNode; >+import org.eclipse.photran.internal.core.parser.ASTSubroutineStmtNode; >+import org.eclipse.photran.internal.core.parser.ASTSubroutineSubprogramNode; >+import org.eclipse.photran.internal.core.parser.ASTTypeDeclarationStmtNode; >+import org.eclipse.photran.internal.core.parser.IASTListNode; >+import org.eclipse.photran.internal.core.parser.IASTNode; >+import org.eclipse.photran.internal.core.parser.IBodyConstruct; >+import org.eclipse.photran.internal.core.refactoring.infrastructure.FortranEditorRefactoring; >+import org.eclipse.photran.internal.core.reindenter.Reindenter; >+import org.eclipse.photran.internal.core.vpg.PhotranTokenRef; >+import org.eclipse.photran.internal.core.vpg.PhotranVPG; >+ >+/** >+ * >+ * >+ * This refactoring allows a user to select a subroutine and to add a new parameter to the list. >+ * The refactoring will ask for a declaration line for the parameter, a default value with which to >+ * update all callers of the subroutine, and a position in the list at which to add the new parameter. >+ * The refactoring ensures that the declaration line is valid, contains some logic to ensure that the >+ * default value matches the appropriate type, and ensures that the position is in bounds. It then updates >+ * the subroutine signature and updates the callers of the subroutine. If the callers specify the variable name >+ * in the call list, the refactoring will match this pattern. >+ * >+ */ >+public class AddSubroutineParameterRefactoring extends FortranEditorRefactoring >+{ >+ private ASTSubroutineStmtNode selectedSubroutine; >+ private List<ASTSubroutineParNode> oldParameterList; >+ private List<ASTSubroutineParNode> newParameterList; >+ private int position = 0; >+ private String parameterName = null; >+ private String declaration = "integer, intent(in) :: newName"; //$NON-NLS-1$ >+ private String defaultValue = "0"; //$NON-NLS-1$ >+ private ASTTypeDeclarationStmtNode declStmt = null; >+ private String type = "integer"; //$NON-NLS-1$ >+ >+ public List<ASTSubroutineParNode> getOldParameterList() { >+ return oldParameterList; >+ } >+ >+ public String getDeclaration() { >+ assert declaration != null; >+ return this.declaration; >+ } >+ >+ public int getPosition() { >+ return this.position; >+ } >+ >+ public String getDefault() { >+ assert defaultValue != null; >+ return this.defaultValue; >+ } >+ >+ public void setPosition(int position) { >+ this.position = position; >+ } >+ >+ /* >+ * Sets the declaration member, but first checks that an appropriate type is at the >+ * beggining of the declaration. If not, it assumes that "real" should be prepended. >+ * The type member is then set to this type. >+ * >+ * @param declaration The declaration to be set. >+ */ >+ public void setDeclaration(String declaration) { >+ // Add "real" to all declaration lines that do not specify a type to avoid parser errors. >+ >+ String[] declArgs = declaration.split(","); //$NON-NLS-1$ >+ String[] validTypes = {"integer","real","logical","double","character"}; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ >+ boolean hasTypeDefined = false; >+ for (int i = 0; i < validTypes.length; i++) { >+ if (validTypes[i].equals(declArgs[0])) { >+ hasTypeDefined = true; >+ type = declArgs[0]; >+ break; >+ } >+ } >+ >+ if (!hasTypeDefined) { >+ type = "real"; //$NON-NLS-1$ >+ if (declArgs.length == 1) >+ declaration = "real, " + declaration; //$NON-NLS-1$ >+ else declaration = "real" + " :: " + declaration; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ this.declaration = declaration; >+ } >+ >+ public void setDefaultValue(String defValue) { >+ defaultValue = defValue; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring#doCheckInitialConditions(org.eclipse.ltk.core.refactoring.RefactoringStatus, org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ @Override >+ protected void doCheckInitialConditions(RefactoringStatus status, IProgressMonitor pm) >+ throws org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring.PreconditionFailure >+ { >+ ensureProjectHasRefactoringEnabled(status); >+ >+ ensureSubroutineIsSelected(); >+ >+ if(!matchingDeclarationsInInterfacesUniquelyBind()) >+ status.addWarning(Messages.AddSubroutineParameterRefactoring_matchingDeclarationsDoNotUniquelyBind); >+ >+ oldParameterList = getSubroutineParameters(); >+ } >+ >+ /* >+ * By looking at the AST tree, starting at the node supplied to the refactoring as the selected node, this method >+ * determines if a subroutine node has been selected or not. >+ * >+ */ >+ private void ensureSubroutineIsSelected() >+ throws org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring.PreconditionFailure >+ { >+ IASTNode temporaryNode = findEnclosingNode(astOfFileInEditor, selectedRegionInEditor); >+ >+ if(temporaryNode == null) >+ fail(Messages.AddSubroutineParameterRefactoring_selectSubroutineError); >+ >+ if(temporaryNode instanceof ASTSubroutineSubprogramNode) >+ selectedSubroutine = ((ASTSubroutineSubprogramNode)temporaryNode).getSubroutineStmt(); >+ else if(temporaryNode instanceof ASTSubroutineStmtNode) >+ { >+ if(temporaryNode.findNearestAncestor(ASTSubroutineSubprogramNode.class) == null) >+ fail(Messages.AddSubroutineParameterRefactoring_selectSubroutineError); >+ selectedSubroutine = (ASTSubroutineStmtNode)temporaryNode; >+ } >+ else >+ fail(Messages.AddSubroutineParameterRefactoring_selectSubroutineError); >+ } >+ >+ /* >+ * This method determines if a matching declaration already exists in scope, and if so, will fail the refactoring. >+ * >+ */ >+ private boolean matchingDeclarationsInInterfacesUniquelyBind() >+ { >+ for(Definition declaration : getInterfaceDeclarations()) >+ if(declaration.resolveInterfaceBinding().size() != 1) >+ return false; >+ >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring#doCheckFinalConditions(org.eclipse.ltk.core.refactoring.RefactoringStatus, org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ @Override >+ protected void doCheckFinalConditions(RefactoringStatus status, IProgressMonitor pm) >+ throws org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring.PreconditionFailure >+ { >+ ensureDeclarationIsValid(); >+ >+ parameterName = declStmt.getEntityDeclList().get(0).getObjectName().getObjectName().getText(); >+ >+ ensurePositionIsValid(); >+ >+ ensureDefaultValueIsValid(); >+ >+ checkForConflictingBindings(pm, status); >+ } >+ >+ /* >+ * This method ensures that the default value supplied is valid by applying logic that >+ * tests whether or not the default type supplied matches the type supplied in the declaration line. >+ * For example, .true. and .false. are reserved for logical types. This method also ensures that the >+ * default value is not a variable name beginning with a number. >+ * >+ */ >+ private void ensureDefaultValueIsValid() >+ throws org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring.PreconditionFailure >+ { >+ if (defaultValue == null || >+ defaultValue.equals("") || //$NON-NLS-1$ >+ isWhiteSpace(defaultValue) || >+ isVariableNameBeginningWithNumber(defaultValue) || >+ (isTrueOrFalse(defaultValue) && !type.equals("logical")) || //$NON-NLS-1$ >+ (isANumber(defaultValue) && (!type.equals("integer") && !type.equals("real"))) || //$NON-NLS-1$//$NON-NLS-2$ >+ (isRealAndNotInteger(defaultValue) && type.equals("integer")) || //$NON-NLS-1$ >+ (defaultValue.equals("null") && !declaration.contains("pointer"))) //$NON-NLS-1$ //$NON-NLS-2$ >+ fail(Messages.AddSubroutineParameterRefactoring_InvalidDefaultValue); >+ } >+ >+ /* >+ * @param str A string to be tested >+ * @return <code> true </code> if the selected string is a real number, and <code> false </code> if the selected string >+ * is ann integer or not a number. >+ * >+ */ >+ private boolean isRealAndNotInteger(String str) { >+ if (isANumber(str)) { >+ try { >+ Integer.parseInt(str); >+ } >+ catch (NumberFormatException e) { >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ /* >+ * @param str A string to be tested >+ * @return <code> true </code> if the selected string is ".true." or ".false.", and <code> false </code> if the selected string >+ * is anything else. >+ */ >+ private boolean isTrueOrFalse(String str) { >+ if (str == null) >+ return false; >+ return str.equals(".true.") || str.equals(".false."); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ /* >+ * @param str A string to be tested >+ * @return <code> true </code> if the string begins with a number but is not a number (hence, a variable name beginning with a number) >+ * and <code> false </code> otherwise. >+ * >+ */ >+ private boolean isVariableNameBeginningWithNumber(String str) { >+ if (str != null) { >+ if (str.length() != 0) { >+ if (isANumber(str.substring(0,1))) { >+ if (!isANumber(str)) >+ return true; >+ } >+ } >+ } >+ >+ return false; >+ } >+ >+ /* >+ * @param str A string >+ * @return <code> true </code> if str is a number. >+ */ >+ private boolean isANumber(String str) { >+ try { >+ Double.parseDouble(str); >+ } >+ catch (NumberFormatException e) { >+ return false; >+ } >+ return true; >+ } >+ >+ /* >+ * This function ensures that the position given to the refactoring is in bounds for the current size of the list, and if not, >+ * fails the refactoring. >+ * >+ */ >+ private void ensurePositionIsValid() >+ throws org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring.PreconditionFailure { >+ if (position > oldParameterList.size() || position < 0) >+ fail(Messages.AddSubroutineParameterRefactoring_InvalidParameterPosition); >+ } >+ >+ /* >+ * This function attempts to produce a declaration node by passing the declaration line on to a parser. If this node is returned >+ * as an error node, the refactoring fails. >+ * >+ */ >+ private void ensureDeclarationIsValid() >+ throws org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring.PreconditionFailure { >+ IBodyConstruct decl = parseLiteralStatementNoFail(declaration); >+ if (decl == null || !(decl instanceof ASTTypeDeclarationStmtNode)) >+ fail(Messages.AddSubroutineParameterRefactoring_InvalidDeclaration); >+ declStmt = (ASTTypeDeclarationStmtNode)decl; >+ IASTListNode<ASTEntityDeclNode> entityDeclList = declStmt.getEntityDeclList(); >+ if (entityDeclList == null) { >+ fail(Messages.AddSubroutineParameterRefactoring_InvalidDeclaration); >+ } >+ } >+ >+ /* >+ * This function checks to see whether or not the variable name supplied to the refactoring is already in scope in the subroutine. >+ * >+ */ >+ private void checkForConflictingBindings(IProgressMonitor pm, RefactoringStatus status) { >+ Definition def = arbitraryDefinitionInScope(); >+ if (def == null) return; // No declarations in scope, so the new one can't conflict >+ >+ checkForConflictingBindings(pm, >+ new ConflictingBindingErrorHandler(status), >+ def, >+ Collections.<PhotranTokenRef>emptyList(), >+ parameterName); >+ } >+ >+ /* >+ * This function returns an arbitrary definition line in scope of the current node. It is used to iterate through >+ * the declarations to see if there are any conflicts. >+ * >+ */ >+ private Definition arbitraryDefinitionInScope() { >+ ScopingNode enclosingScope = selectedSubroutine.findNearestAncestor(ScopingNode.class); >+ List<Definition> allDefs = enclosingScope.getAllDefinitions(); >+ if (allDefs.isEmpty()) >+ return null; >+ else >+ return allDefs.get(0); >+ } >+ >+ /* >+ * @param str A string >+ * @return <code> true </code> if str is only white space. This is used to test if default values are nothing but white space. >+ */ >+ private boolean isWhiteSpace(String str) >+ { >+ return str.replace(" ", "").replace("\t", "").equals(""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring#doCreateChange(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ @Override >+ protected void doCreateChange(IProgressMonitor pm) throws CoreException, >+ OperationCanceledException >+ { >+ >+ buildNewParameterListWithNewParameter(); >+ >+ // Change the arguments list to the new list >+ permuteArgumentList(selectedSubroutine); >+ >+ addArgumentDeclaration(selectedSubroutine); >+ >+ permuteCallSites(); >+ >+ addChangeFromModifiedAST(fileInEditor, pm); >+ vpg.releaseAST(fileInEditor); >+ >+ } >+ >+ /* >+ * This function adds the declaration line to the subroutine. >+ */ >+ private void addArgumentDeclaration(ASTSubroutineStmtNode subroutineStatement) >+ { >+ ASTSubroutineSubprogramNode subroutine = (ASTSubroutineSubprogramNode)subroutineStatement.getParent(); >+ >+ IASTListNode<IBodyConstruct> statements = subroutine.getBody(); >+ if (statements == null) { >+ statements = new ASTListNode<IBodyConstruct>(); >+ subroutine.setBody(statements); >+ } >+ >+ statements.add(0, declStmt); >+ Reindenter.reindent(declStmt, astOfFileInEditor); >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ltk.core.refactoring.Refactoring#getName() >+ */ >+ @Override >+ public String getName() >+ { >+ return Messages.AddSubroutineParameterRefactoring_Name; >+ } >+ >+ /* >+ * This function returns the list of subroutine parameters from the selected subroutine node. >+ */ >+ public List<ASTSubroutineParNode> getSubroutineParameters() >+ { >+ if(selectedSubroutine.getSubroutinePars() != null) >+ return selectedSubroutine.getSubroutinePars(); >+ >+ return new ArrayList<ASTSubroutineParNode>(); >+ } >+ >+ /* >+ * This function returns a collection of interface declarations. >+ */ >+ private Collection<Definition> getInterfaceDeclarations() >+ { >+ List<Definition> subroutineDefinitions = selectedSubroutine.getSubroutineName().getSubroutineName().resolveBinding(); >+ >+ if(subroutineDefinitions.size() != 1) >+ return new ArrayList<Definition>(); >+ >+ return subroutineDefinitions.get(0).findMatchingDeclarationsInInterfaces(); >+ } >+ >+ /* >+ * This function builds the new parameter list to be supplied to the subroutine node by adding the new parameter to >+ * the list in the appropriate position. >+ */ >+ public void buildNewParameterListWithNewParameter() >+ { >+ // Create new variable >+ ASTSubroutineParNode newParameter = new ASTSubroutineParNode(); >+ Token variableName = generateVariableName(); >+ newParameter.setVariableName(variableName); >+ >+ // Create new list >+ newParameterList = new ArrayList<ASTSubroutineParNode>(oldParameterList); >+ newParameterList.add(position, newParameter); >+ >+ } >+ >+ /* >+ * This function returns a token for a variable with the name of the new parameter name. >+ */ >+ private Token generateVariableName() >+ { >+ Token variableName = new Token(Terminal.T_IDENT, parameterName); >+ return variableName; >+ } >+ >+ /* >+ * This function changes the argument list of the subroutine statement node to the new list generated in buildNewParameterListWithNewParameter() >+ */ >+ protected void permuteArgumentList(ASTSubroutineStmtNode node) >+ { >+ ASTSeparatedListNode<ASTSubroutineParNode> newParameterList = new ASTSeparatedListNode<ASTSubroutineParNode>(new Token(Terminal.T_COMMA, ","), this.newParameterList); //$NON-NLS-1$ >+ node.setSubroutinePars(newParameterList); >+ } >+ >+ /* >+ * This function changes all call sites to be updated to have the new argument in place, and will match any calling pattern currently used. >+ */ >+ private void permuteCallSites() >+ { >+ for(ASTCallStmtNode callStmt : getCallSites()) >+ { >+ int previousArgumentListSize = 0; >+ >+ if(callStmt.getArgList() != null) { >+ previousArgumentListSize = callStmt.getArgList().size(); >+ } >+ >+ // Generate new IExpression Node for the default value >+ ASTIntConstNode expr = new ASTIntConstNode(); >+ expr.setIntConst(new Token(Terminal.T_ICON, defaultValue)); >+ ASTSubroutineArgNode addedParArg = new ASTSubroutineArgNode(); >+ addedParArg.setExpr(expr); >+ >+ // Test to see if the call site is using the "(variableName = value, variablename = value)" pattern, or simply the "(value, value)" pattern >+ // The new parameter should follow this pattern at the call site, and should assume the (value) pattern if the list was previously empty. >+ if (previousArgumentListSize > 0) { >+ int positionToCompareTo = Math.min(position, previousArgumentListSize-1); >+ ASTSubroutineParNode firstParameter = oldParameterList.get(positionToCompareTo); >+ ASTSubroutineArgNode firstParameterArgument = getActualArgFromCallStmt(callStmt, firstParameter.getVariableName(), positionToCompareTo); >+ if (firstParameterArgument.getName() != null) >+ addedParArg.setName(new Token(Terminal.T_IDENT, parameterName)); >+ } >+ >+ ArrayList<ASTSubroutineArgNode> newParameterListForCallSite = new ArrayList<ASTSubroutineArgNode>(); >+ >+ for (int i = 0; i < previousArgumentListSize; i++) { >+ ASTSubroutineParNode desiredPar = oldParameterList.get(i); >+ ASTSubroutineArgNode desiredParArgument = getActualArgFromCallStmt(callStmt, desiredPar.getVariableName(), i); >+ newParameterListForCallSite.add(desiredParArgument); >+ } >+ >+ newParameterListForCallSite.add(position, addedParArg); >+ >+ >+ ASTSeparatedListNode<ASTSubroutineArgNode> newArgList = new ASTSeparatedListNode<ASTSubroutineArgNode>(new Token(Terminal.T_COMMA, ","), newParameterListForCallSite); //$NON-NLS-1$ >+ callStmt.setArgList(newArgList); >+ } >+ } >+ >+ /* >+ * This function returns the set of call sites for the subroutine that was selected. >+ */ >+ private Set<ASTCallStmtNode> getCallSites() >+ { >+ List<Definition> subroutineDefinitions = selectedSubroutine.getSubroutineName().getSubroutineName().resolveBinding(); >+ HashSet<ASTCallStmtNode> result = new HashSet<ASTCallStmtNode>(); >+ >+ if (subroutineDefinitions.size() != 1) >+ return result; >+ >+ for(PhotranTokenRef tokenRef : subroutineDefinitions.get(0).findAllReferences(true)) >+ { >+ Token token = tokenRef.findToken(); >+ >+ ASTCallStmtNode callStmtNode = token.findNearestAncestor(ASTCallStmtNode.class); >+ >+ if(callStmtNode != null) >+ result.add(callStmtNode); >+ } >+ >+ return result; >+ } >+ >+ /* >+ * This function gets an argument from a call statement, in order to check if it follows the pattern of "Variablename = Value". >+ */ >+ private ASTSubroutineArgNode getActualArgFromCallStmt(ASTCallStmtNode callStmt, Token desiredParName, int desiredParIndex) >+ { >+ for(int i = 0; i < callStmt.getArgList().size(); i++) >+ { >+ ASTSubroutineArgNode argument = callStmt.getArgList().get(i); >+ if(argument.getName() == null || desiredParName == null) >+ { >+ if(i == desiredParIndex) >+ return argument; >+ } >+ else >+ { >+ String argumentName = PhotranVPG.canonicalizeIdentifier(argument.getName().getText()); >+ String parameterName = PhotranVPG.canonicalizeIdentifier(desiredParName.getText()); >+ if(argumentName.equals(parameterName)) >+ return argument; >+ } >+ } >+ return null; >+ } >+ >+ /* >+ * This class handles all error cases for conflicting variable names or bindings. >+ */ >+ private final class ConflictingBindingErrorHandler implements IConflictingBindingCallback >+ { >+ private final RefactoringStatus status; >+ >+ private ConflictingBindingErrorHandler(RefactoringStatus status) { this.status = status; } >+ >+ public void addConflictError(List<Conflict> conflictingDef) >+ { >+ Conflict conflict = conflictingDef.get(0); >+ >+ String msg = Messages.bind(Messages.AddSubroutineParameterRefactoring_NameConflictsWith, conflict.name, vpg.getDefinitionFor(conflict.tokenRef)); >+ RefactoringStatusContext context = createContext(conflict.tokenRef); // Highlights problematic definition >+ status.addError(msg, context); >+ } >+ >+ public void addConflictWarning(List<Conflict> conflictingDef) >+ { >+ Conflict conflict = conflictingDef.get(0); >+ >+ String msg = Messages.bind(Messages.AddSubroutineParameterRefactoring_NameMightConflictWithSubprogram, conflict.name); >+ RefactoringStatusContext context = createContext(conflict.tokenRef); // Highlights problematic definition >+ status.addWarning(msg, context); >+ } >+ >+ public void addReferenceWillChangeError(String newName, Token reference) >+ { >+ throw new IllegalStateException(); >+ } >+ } >+ >+} >Index: src/org/eclipse/photran/internal/core/refactoring/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/photran/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/Messages.java,v >retrieving revision 1.15 >diff -u -r1.15 Messages.java >--- src/org/eclipse/photran/internal/core/refactoring/Messages.java 21 Sep 2010 18:32:41 -0000 1.15 >+++ src/org/eclipse/photran/internal/core/refactoring/Messages.java 15 Dec 2010 03:35:30 -0000 >@@ -64,6 +64,22 @@ > public static String AddOnlyToUseStmtRefactoring_ProjectDoesNotExist; > > public static String AddOnlyToUseStmtRefactoring_SelectModuleName; >+ >+ public static String AddSubroutineParameterRefactoring_InvalidDeclaration; >+ >+ public static String AddSubroutineParameterRefactoring_InvalidDefaultValue; >+ >+ public static String AddSubroutineParameterRefactoring_InvalidParameterPosition; >+ >+ public static String AddSubroutineParameterRefactoring_matchingDeclarationsDoNotUniquelyBind; >+ >+ public static String AddSubroutineParameterRefactoring_Name; >+ >+ public static String AddSubroutineParameterRefactoring_NameConflictsWith; >+ >+ public static String AddSubroutineParameterRefactoring_NameMightConflictWithSubprogram; >+ >+ public static String AddSubroutineParameterRefactoring_selectSubroutineError; > > public static String EncapsulateVariableRefactoring_CannotEncapsulateArrays; > >Index: src/org/eclipse/photran/internal/core/refactoring/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/photran/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/messages.properties,v >retrieving revision 1.13 >diff -u -r1.13 messages.properties >--- src/org/eclipse/photran/internal/core/refactoring/messages.properties 21 Sep 2010 15:31:10 -0000 1.13 >+++ src/org/eclipse/photran/internal/core/refactoring/messages.properties 15 Dec 2010 03:35:30 -0000 >@@ -21,6 +21,14 @@ > AddOnlyToUseStmtRefactoring_PleaseSelectModuleName=Please select a module name. > AddOnlyToUseStmtRefactoring_ProjectDoesNotExist=Project does not exist\! > AddOnlyToUseStmtRefactoring_SelectModuleName=Please select the name of the module in the USE statement. >+AddSubroutineParameterRefactoring_InvalidDeclaration=Invalid declaration line for new parameter. >+AddSubroutineParameterRefactoring_InvalidDefaultValue=Invalid default value for this parameter for all callers of this subroutine. >+AddSubroutineParameterRefactoring_InvalidParameterPosition=Parameter position is out of bounds. >+AddSubroutineParameterRefactoring_matchingDeclarationsDoNotUniquelyBind=Matching declarations in interface blocks do not uniquely bind to the selected subroutine. >+AddSubroutineParameterRefactoring_Name=Add Subroutine Parameter >+AddSubroutineParameterRefactoring_NameConflictsWith=The name "{0}" conflicts with {1} >+AddSubroutineParameterRefactoring_NameMightConflictWithSubprogram=Name might have conflict with subprogram. >+AddSubroutineParameterRefactoring_selectSubroutineError=Please select a subroutine definition. > PermuteSubroutineArgsRefactoring_matchingDeclarationsDoNotUniquelyBind=Matching declarations in interface blocks do not uniquely bind to the selected subroutine. > PermuteSubroutineArgsRefactoring_name=Permute Subroutine Arguments > PermuteSubroutineArgsRefactoring_selectedTextNotSubroutine=The selected text is not a subroutine. Please select a subroutine. >#P org.eclipse.photran.core.vpg.tests >Index: refactoring-test-code/add-subroutine-parameter/test1-basic/add_subroutine_parameter_1.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test1-basic/add_subroutine_parameter_1.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test1-basic/add_subroutine_parameter_1.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test1-basic/add_subroutine_parameter_1.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program basic ! basic test, adding an integer with intent in, default value 0, at position 0. >+ >+end program basic >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer; intent(in) :: y, 0, 0, pass >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test1-basic/add_subroutine_parameter_1.f90.result >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test1-basic/add_subroutine_parameter_1.f90.result >diff -N refactoring-test-code/add-subroutine-parameter/test1-basic/add_subroutine_parameter_1.f90.result >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test1-basic/add_subroutine_parameter_1.f90.result 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+program basic ! basic test, adding an integer with intent in, default value 0, at position 0. >+ >+end program basic >+subroutine sub(y,z) !<<<<< 4, 1, 4, 5, integer; intent(in) :: y, 0, 0, pass >+ integer, intent(in) :: y >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test10-fail-invalidtype/add_subroutine_parameter_10.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test10-fail-invalidtype/add_subroutine_parameter_10.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test10-fail-invalidtype/add_subroutine_parameter_10.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test10-fail-invalidtype/add_subroutine_parameter_10.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program invalidtype ! Fails because the type specified is invalid in the declaration line. >+ >+end program invalidtype >+subroutine sub(z) !<<<<< 4, 1, 4, 5, invalidtype :: y, 0, 0, fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test11-updatecallsitewhenvariablenamesaddedincall/add_subroutine_parameter_11.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test11-updatecallsitewhenvariablenamesaddedincall/add_subroutine_parameter_11.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test11-updatecallsitewhenvariablenamesaddedincall/add_subroutine_parameter_11.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test11-updatecallsitewhenvariablenamesaddedincall/add_subroutine_parameter_11.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+program variablenameaddedincallsite ! Tests that when y is added, the call site adds y=0 >+ implicit none >+ call sub(z=2) >+end program variablenameaddedincallsite >+subroutine sub(z) !<<<<< 5, 1, 5, 5, integer; intent(in) :: y, 1, 0, pass >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test11-updatecallsitewhenvariablenamesaddedincall/add_subroutine_parameter_11.f90.result >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test11-updatecallsitewhenvariablenamesaddedincall/add_subroutine_parameter_11.f90.result >diff -N refactoring-test-code/add-subroutine-parameter/test11-updatecallsitewhenvariablenamesaddedincall/add_subroutine_parameter_11.f90.result >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test11-updatecallsitewhenvariablenamesaddedincall/add_subroutine_parameter_11.f90.result 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,8 @@ >+program variablenameaddedincallsite ! Tests that when y is added, the call site adds y=0 >+ implicit none >+ call sub(z=2,y=0) >+end program variablenameaddedincallsite >+subroutine sub(z,y) !<<<<< 5, 1, 5, 5, integer; intent(in) :: y, 1, 0, pass >+ integer, intent(in) :: y >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test12-includevalidattributes/add_subroutine_parameter_12.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test12-includevalidattributes/add_subroutine_parameter_12.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test12-includevalidattributes/add_subroutine_parameter_12.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test12-includevalidattributes/add_subroutine_parameter_12.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program validattributes ! Tests that valid attributes (intent(inout)) are allowed. >+ >+end program validattributes >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer; intent(inout) :: y, 0, 0, pass >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test12-includevalidattributes/add_subroutine_parameter_12.f90.result >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test12-includevalidattributes/add_subroutine_parameter_12.f90.result >diff -N refactoring-test-code/add-subroutine-parameter/test12-includevalidattributes/add_subroutine_parameter_12.f90.result >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test12-includevalidattributes/add_subroutine_parameter_12.f90.result 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+program validattributes ! Tests that valid attributes (intent(inout)) are allowed. >+ >+end program validattributes >+subroutine sub(y,z) !<<<<< 4, 1, 4, 5, integer; intent(inout) :: y, 0, 0, pass >+ integer, intent(inout) :: y >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test13-fail-invalidattribute/add_subroutine_parameter_13.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test13-fail-invalidattribute/add_subroutine_parameter_13.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test13-fail-invalidattribute/add_subroutine_parameter_13.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test13-fail-invalidattribute/add_subroutine_parameter_13.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program invalidvalidattributes ! Tests that invalid attributes fail >+ >+end program invalidvalidattributes >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer; intent(inoot) :: y, 0, 0, fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test14-fail-conflictingattributes/add_subroutine_parameter_14.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test14-fail-conflictingattributes/add_subroutine_parameter_14.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test14-fail-conflictingattributes/add_subroutine_parameter_14.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test14-fail-conflictingattributes/add_subroutine_parameter_14.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program conflictingattributes ! Tests that conflicting attributes (two types) fail. >+ >+end program conflictingattributes >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer; real; intent(out) :: y, 0, 0, fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test15-fail-conflictingvariablenames/add_subroutine_parameter_15.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test15-fail-conflictingvariablenames/add_subroutine_parameter_15.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test15-fail-conflictingvariablenames/add_subroutine_parameter_15.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test15-fail-conflictingvariablenames/add_subroutine_parameter_15.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+program conflictingvariablenames ! Tests that a parameter cannot be given the same name as another in scope. >+ >+end program conflictingvariablenames >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer; intent(in) :: alreadyused, 0, 0, fail-final >+ real :: alreadyused >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test16-fail-whitespacevariablename/add_subroutine_parameter_16.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test16-fail-whitespacevariablename/add_subroutine_parameter_16.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test16-fail-whitespacevariablename/add_subroutine_parameter_16.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test16-fail-whitespacevariablename/add_subroutine_parameter_16.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program whitespacevariablename ! Tests that a variable name cannot be set to just white space. >+ >+end program whitespacevariablename >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer; intent(inout) :: , 0, 0, fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test17-fail-parameternamebeginswithnumber/add_subroutine_parameter_17.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test17-fail-parameternamebeginswithnumber/add_subroutine_parameter_17.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test17-fail-parameternamebeginswithnumber/add_subroutine_parameter_17.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test17-fail-parameternamebeginswithnumber/add_subroutine_parameter_17.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program parameternamebeginswithnumber ! Tests that the variable name cannot begin with a number >+ >+end program parameternamebeginswithnumber >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer :: 1y, 0, 0, fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test18-fail-defaultvalueisvariablestartingwithnumber/add_subroutine_parameter_18.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test18-fail-defaultvalueisvariablestartingwithnumber/add_subroutine_parameter_18.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test18-fail-defaultvalueisvariablestartingwithnumber/add_subroutine_parameter_18.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test18-fail-defaultvalueisvariablestartingwithnumber/add_subroutine_parameter_18.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program defaultvalueisvariablestartingwithnumber ! Tests that the default value cannot be set to an invalid variable name >+ >+end program defaultvalueisvariablestartingwithnumber >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer :: y, 0, 1defval, fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test19-fail-defaultvalueisrealwhentypeisinteger/add_subroutine_parameter_19.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test19-fail-defaultvalueisrealwhentypeisinteger/add_subroutine_parameter_19.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test19-fail-defaultvalueisrealwhentypeisinteger/add_subroutine_parameter_19.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test19-fail-defaultvalueisrealwhentypeisinteger/add_subroutine_parameter_19.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program defaultvalueisrealforinteger ! Tests that an integer cannot be given a real default value. >+ >+end program defaultvalueisrealforinteger >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer :: y, 0, 1.7, fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test2-updatecallsite/add_subroutine_parameter_2.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test2-updatecallsite/add_subroutine_parameter_2.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test2-updatecallsite/add_subroutine_parameter_2.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test2-updatecallsite/add_subroutine_parameter_2.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+program updatecallsite ! Tests that the call site is updated appropriately - basic. >+ implicit none >+ call sub(2) >+end program updatecallsite >+subroutine sub(z) !<<<<< 5, 1, 5, 5, integer; intent(in) :: y, 0, 0, pass >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test2-updatecallsite/add_subroutine_parameter_2.f90.result >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test2-updatecallsite/add_subroutine_parameter_2.f90.result >diff -N refactoring-test-code/add-subroutine-parameter/test2-updatecallsite/add_subroutine_parameter_2.f90.result >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test2-updatecallsite/add_subroutine_parameter_2.f90.result 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,8 @@ >+program updatecallsite ! Tests that the call site is updated appropriately - basic. >+ implicit none >+ call sub(0,2) >+end program updatecallsite >+subroutine sub(y,z) !<<<<< 5, 1, 5, 5, integer; intent(in) :: y, 0, 0, pass >+ integer, intent(in) :: y >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test20-fail-defaultvalueisnumberwhentypeisnonnumber/add_subroutine_parameter_20.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test20-fail-defaultvalueisnumberwhentypeisnonnumber/add_subroutine_parameter_20.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test20-fail-defaultvalueisnumberwhentypeisnonnumber/add_subroutine_parameter_20.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test20-fail-defaultvalueisnumberwhentypeisnonnumber/add_subroutine_parameter_20.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program defaultvalueisnumberfornonnumbertype ! Tests that non number types cannot be given a number as a default value. >+ >+end program defaultvalueisnumberfornonnumbertype >+subroutine sub(z) !<<<<< 4, 1, 4, 5, logical :: y, 0, 1, fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test21-fail-defaultvalueisnullwhentypeisnotpointer/add_subroutine_parameter_21.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test21-fail-defaultvalueisnullwhentypeisnotpointer/add_subroutine_parameter_21.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test21-fail-defaultvalueisnullwhentypeisnotpointer/add_subroutine_parameter_21.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test21-fail-defaultvalueisnullwhentypeisnotpointer/add_subroutine_parameter_21.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program defaultvalueisnullfornonpointer ! Tests that null cannot be the default value for a non pointer >+ >+end program defaultvalueisnullfornonpointer >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer :: y, 0, null, fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test22-basicpointer/add_subroutine_parameter_22.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test22-basicpointer/add_subroutine_parameter_22.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test22-basicpointer/add_subroutine_parameter_22.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test22-basicpointer/add_subroutine_parameter_22.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program basicpointer ! Tests that pointers can be passed as a parameter. >+ >+end program basicpointer >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer; intent(in); pointer :: y, 0, null, pass >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test22-basicpointer/add_subroutine_parameter_22.f90.result >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test22-basicpointer/add_subroutine_parameter_22.f90.result >diff -N refactoring-test-code/add-subroutine-parameter/test22-basicpointer/add_subroutine_parameter_22.f90.result >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test22-basicpointer/add_subroutine_parameter_22.f90.result 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+program basicpointer ! Tests that pointers can be passed as a parameter. >+ >+end program basicpointer >+subroutine sub(y,z) !<<<<< 4, 1, 4, 5, integer; intent(in); pointer :: y, 0, null, pass >+ integer, intent(in), pointer :: y >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test3-updatecallsitewithorder/add_subroutine_parameter_3.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test3-updatecallsitewithorder/add_subroutine_parameter_3.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test3-updatecallsitewithorder/add_subroutine_parameter_3.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test3-updatecallsitewithorder/add_subroutine_parameter_3.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+program updatecallsitewithorder ! Tests that the position of the parameter is correctly set. >+ implicit none >+ call sub(2) >+end program updatecallsitewithorder >+subroutine sub(z) !<<<<< 5, 1, 5, 5, integer; intent(in) :: y, 1, 0, pass >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test3-updatecallsitewithorder/add_subroutine_parameter_3.f90.result >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test3-updatecallsitewithorder/add_subroutine_parameter_3.f90.result >diff -N refactoring-test-code/add-subroutine-parameter/test3-updatecallsitewithorder/add_subroutine_parameter_3.f90.result >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test3-updatecallsitewithorder/add_subroutine_parameter_3.f90.result 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,8 @@ >+program updatecallsitewithorder ! Tests that the position of the parameter is correctly set. >+ implicit none >+ call sub(2,0) >+end program updatecallsitewithorder >+subroutine sub(z,y) !<<<<< 5, 1, 5, 5, integer; intent(in) :: y, 1, 0, pass >+ integer, intent(in) :: y >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test4-fail-negativeposition/add_subroutine_parameter_4.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test4-fail-negativeposition/add_subroutine_parameter_4.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test4-fail-negativeposition/add_subroutine_parameter_4.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test4-fail-negativeposition/add_subroutine_parameter_4.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program negativeposition ! Tests that the refactoring fails with negative positions requested. >+ >+end program negativeposition >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer; intent(in) :: y, -1, 0, fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test5-fail-outofboundsposition/add_subroutine_parameter_5.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test5-fail-outofboundsposition/add_subroutine_parameter_5.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test5-fail-outofboundsposition/add_subroutine_parameter_5.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test5-fail-outofboundsposition/add_subroutine_parameter_5.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program outofbounds ! Tests that the refactoring fails for requests to place the new parameter in a position that is out of bounds. >+ >+end program outofbounds >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer; intent(in) :: y, 3, 0, fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test6-fail-whitespacedefaultvalue/add_subroutine_parameter_6.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test6-fail-whitespacedefaultvalue/add_subroutine_parameter_6.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test6-fail-whitespacedefaultvalue/add_subroutine_parameter_6.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test6-fail-whitespacedefaultvalue/add_subroutine_parameter_6.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program whitespacedefaultvalue ! Tests that the refactoring does not allow the default value to be white space >+ >+end program whitespacedefaultvalue >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer; intent(in) :: y, 0, , fail-final >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test7-basicarray/add_subroutine_parameter_7.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test7-basicarray/add_subroutine_parameter_7.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test7-basicarray/add_subroutine_parameter_7.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test7-basicarray/add_subroutine_parameter_7.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program basicarray ! Tests that arrays can be passed. >+ >+end program basicarray >+subroutine sub(z) !<<<<< 4, 1, 4, 5, integer; intent(in); dimension(2) :: y, 0, (/ 2; 3 /), pass >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test7-basicarray/add_subroutine_parameter_7.f90.result >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test7-basicarray/add_subroutine_parameter_7.f90.result >diff -N refactoring-test-code/add-subroutine-parameter/test7-basicarray/add_subroutine_parameter_7.f90.result >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test7-basicarray/add_subroutine_parameter_7.f90.result 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+program basicarray ! Tests that arrays can be passed. >+ >+end program basicarray >+subroutine sub(y,z) !<<<<< 4, 1, 4, 5, integer; intent(in); dimension(2) :: y, 0, (/ 2; 3 /), pass >+ integer, intent(in), dimension(2) :: y >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test8-logicalbasic/add_subroutine_parameter_8.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test8-logicalbasic/add_subroutine_parameter_8.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test8-logicalbasic/add_subroutine_parameter_8.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test8-logicalbasic/add_subroutine_parameter_8.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program logicalbasic ! Tests that logical parameters work correctly. >+ >+end program logicalbasic >+subroutine sub(z) !<<<<< 4, 1, 4, 5, logical; intent(in) :: y, 0, .true., pass >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test8-logicalbasic/add_subroutine_parameter_8.f90.result >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test8-logicalbasic/add_subroutine_parameter_8.f90.result >diff -N refactoring-test-code/add-subroutine-parameter/test8-logicalbasic/add_subroutine_parameter_8.f90.result >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test8-logicalbasic/add_subroutine_parameter_8.f90.result 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+program logicalbasic ! Tests that logical parameters work correctly. >+ >+end program logicalbasic >+subroutine sub(y,z) !<<<<< 4, 1, 4, 5, logical; intent(in) :: y, 0, .true., pass >+ logical, intent(in) :: y >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test9-dontsetvariabletype/add_subroutine_parameter_9.f90 >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test9-dontsetvariabletype/add_subroutine_parameter_9.f90 >diff -N refactoring-test-code/add-subroutine-parameter/test9-dontsetvariabletype/add_subroutine_parameter_9.f90 >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test9-dontsetvariabletype/add_subroutine_parameter_9.f90 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+program dontsetvariabletype ! Tests that the default variable type is set to real >+ >+end program dontsetvariabletype >+subroutine sub(z) !<<<<< 4, 1, 4, 5, intent(in) :: y, 0, 3, pass >+ integer, intent(in) :: z >+end subroutine >Index: refactoring-test-code/add-subroutine-parameter/test9-dontsetvariabletype/add_subroutine_parameter_9.f90.result >=================================================================== >RCS file: refactoring-test-code/add-subroutine-parameter/test9-dontsetvariabletype/add_subroutine_parameter_9.f90.result >diff -N refactoring-test-code/add-subroutine-parameter/test9-dontsetvariabletype/add_subroutine_parameter_9.f90.result >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ refactoring-test-code/add-subroutine-parameter/test9-dontsetvariabletype/add_subroutine_parameter_9.f90.result 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+program dontsetvariabletype ! Tests that the default variable type is set to real >+ >+end program dontsetvariabletype >+subroutine sub(y,z) !<<<<< 4, 1, 4, 5, intent(in) :: y, 0, 3, pass >+ real, intent(in) :: y >+ integer, intent(in) :: z >+end subroutine >Index: src/org/eclipse/photran/internal/tests/refactoring/AddSubroutineParameterTestSuite.java >=================================================================== >RCS file: src/org/eclipse/photran/internal/tests/refactoring/AddSubroutineParameterTestSuite.java >diff -N src/org/eclipse/photran/internal/tests/refactoring/AddSubroutineParameterTestSuite.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/photran/internal/tests/refactoring/AddSubroutineParameterTestSuite.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,57 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 University of Illinois at Urbana-Champaign and others. >+ * 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 >+ * >+ * Contributors: >+ * UIUC - Initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.photran.internal.tests.refactoring; >+ >+import junit.framework.Test; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.jface.text.TextSelection; >+import org.eclipse.photran.internal.core.refactoring.AddSubroutineParameterRefactoring; >+import org.eclipse.photran.internal.tests.Activator; >+import org.eclipse.photran.internal.tests.PhotranRefactoringTestSuiteFromMarkers; >+ >+/** >+ * >+ * @author Marc Celani, Joe Handzik, Joe Gonzalez, Jason Patel >+ */ >+public class AddSubroutineParameterTestSuite extends >+ PhotranRefactoringTestSuiteFromMarkers<AddSubroutineParameterRefactoring> >+{ >+ private static final String DIR = "refactoring-test-code/add-subroutine-parameter"; >+ >+ public static Test suite() throws Exception >+ { >+ return new AddSubroutineParameterTestSuite(); >+ } >+ >+ public AddSubroutineParameterTestSuite() throws Exception >+ { >+ super(Activator.getDefault(), >+ "Running Add Subroutine Parameter refactoring in", >+ DIR, >+ AddSubroutineParameterRefactoring.class); >+ } >+ >+ @Override >+ protected boolean configureRefactoring(AddSubroutineParameterRefactoring refactoring, >+ IFile file, >+ TextSelection selection, >+ String[] markerText) >+ { >+ boolean shouldSucceed = super.configureRefactoring(refactoring, file, selection, markerText); >+ refactoring.setDeclaration(markerText[4].replaceAll(";", ",")); >+ refactoring.setPosition(Integer.parseInt(markerText[5])); >+ if (!markerText[6].equals("_dont_call")) >+ refactoring.setDefaultValue(markerText[6]); >+ >+ return shouldSucceed; >+ } >+} >\ No newline at end of file >#P org.eclipse.photran.ui.vpg >Index: OSGI-INF/l10n/bundle.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/photran/org.eclipse.photran.ui.vpg/OSGI-INF/l10n/bundle.properties,v >retrieving revision 1.4 >diff -u -r1.4 bundle.properties >--- OSGI-INF/l10n/bundle.properties 21 Sep 2010 18:29:59 -0000 1.4 >+++ OSGI-INF/l10n/bundle.properties 15 Dec 2010 03:35:32 -0000 >@@ -3,19 +3,19 @@ > command.name = Rename... > command.name.0 = Extract Procedure... > command.name.1 = Extract Local Variable... >+command.name.21 = Add Subroutine Parameter... > actionSet.description = Fortran Refactorings > actionSet.label = Fortran Refactorings > action.label = Re&name... > action.label.0 = E&xtract Procedure... > action.label.1 = Extract &Local Variable... >+action.label.21 = Add Subrouti&ne Parameter... > page.name = Analysis/Refactoring > category.description = Navigation > category.name.0 = Navigation > command.description = Open Declaration >-command.name.2 = Open Declaration > actionSet.description.0 = Fortran Analysis Actions > actionSet.label.0 = Fortran Analysis Actions >-action.label.2 = &Open Declaration > action.label.3 = &Open Declaration > extension.name = Fortran Search > page.label = Fortran Search >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/photran/org.eclipse.photran.ui.vpg/plugin.xml,v >retrieving revision 1.78 >diff -u -r1.78 plugin.xml >--- plugin.xml 16 Nov 2010 18:07:25 -0000 1.78 >+++ plugin.xml 15 Dec 2010 03:35:32 -0000 >@@ -20,6 +20,7 @@ > <group><!-- Extract XYZ --> > <editorRefactoring command="org.eclipse.photran.ui.ExtractProcedureRefactoringCommand" /> > <editorRefactoring command="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand" /> >+ <editorRefactoring command="org.eclipse.photran.ui.AddSubroutineParameterRefactoringCommand" /> > </group> > <group><!-- Refactorings that change local variable declarations --> > <resourceRefactoring >@@ -151,6 +152,11 @@ > categoryId="org.eclipse.photran.ui.RefactoringCategory" > id="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand"> > </command> >+ <command >+ name="%command.name.21" >+ categoryId="org.eclipse.photran.ui.RefactoringCategory" >+ id="org.eclipse.photran.ui.AddSubroutineParameterRefactoringCommand"> >+ </command> > </extension> > > <!-- 2. Optionally associate the command with an accelerator key --> >@@ -174,6 +180,12 @@ > contextId="org.eclipse.photran.ui.FortranEditorContext" > commandId="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand" > /> >+ <key >+ sequence="M3+M2+T" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" >+ contextId="org.eclipse.photran.ui.FortranEditorContext" >+ commandId="org.eclipse.photran.ui.AddSubroutineParameterRefactoringCommand" >+ /> > </extension> > > <!-- 3. Add the command to Photran's Refactoring action set --> >@@ -199,6 +211,11 @@ > definitionId="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand" > class="org.eclipse.photran.internal.ui.refactoring.ExtractLocalVariableAction" > id="org.eclipse.photran.ui.ExtractLocalVariableRefactoringAction"/> >+ <action >+ label="%action.label.21" >+ definitionId="org.eclipse.photran.ui.AddSubroutineParameterRefactoringCommand" >+ class="org.eclipse.photran.internal.ui.refactoring.AddSubroutineParameterAction" >+ id="org.eclipse.photran.ui.AddSubroutineParameterRefactoringAction"/> > </actionSet> > </extension> > >@@ -353,7 +370,7 @@ > id="org.eclipse.photran.ui.Reindenter"> > <action > label="%action.label.reindent.0" >- menubarPath="org.eclipse.photran.ui.source.menu/indentationActions" >+ menubarPath="edit/additions" > definitionId="org.eclipse.photran.ui.ReindenterCommand" > class="org.eclipse.photran.internal.ui.actions.ReindentAction" > id="org.eclipse.photran.ui.ReindenterAction"> >Index: src/org/eclipse/photran/internal/ui/refactoring/AddSubroutineParameterAction.java >=================================================================== >RCS file: src/org/eclipse/photran/internal/ui/refactoring/AddSubroutineParameterAction.java >diff -N src/org/eclipse/photran/internal/ui/refactoring/AddSubroutineParameterAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/photran/internal/ui/refactoring/AddSubroutineParameterAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,170 @@ >+/******************************************************************************* >+ * Copyright (c) 2007, 2009 University of Illinois at Urbana-Champaign and others. >+ * 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 >+ * >+ * Contributors: >+ * UIUC - Initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.photran.internal.ui.refactoring; >+ >+import java.util.List; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; >+import org.eclipse.photran.core.IFortranAST; >+import org.eclipse.photran.internal.core.lexer.Token; >+import org.eclipse.photran.internal.core.parser.ASTSubroutineParNode; >+import org.eclipse.photran.internal.core.refactoring.AddSubroutineParameterRefactoring; >+import org.eclipse.photran.internal.core.vpg.PhotranVPG; >+import org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.TableColumn; >+import org.eclipse.swt.widgets.TableItem; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.ui.IEditorActionDelegate; >+import org.eclipse.ui.IWorkbenchWindowActionDelegate; >+ >+/** >+ * Handles the Add Subroutine Parameter action in the Fortran editor's Refactoring popup menu and in >+ * the Refactor menu in the workbench menu bar. >+ * >+ * @author Joe Handzik, Joe Gonzales, Marc Celani, Jason Patel >+ */ >+public class AddSubroutineParameterAction extends AbstractFortranRefactoringActionDelegate >+ implements IWorkbenchWindowActionDelegate, IEditorActionDelegate >+{ >+ public AddSubroutineParameterAction() >+ { >+ super(AddSubroutineParameterRefactoring.class, >+ FortranAddSubroutineParameterRefactoringWizard.class); >+ } >+ >+ @Override >+ protected VPGRefactoring<IFortranAST, Token, PhotranVPG> getRefactoring(List<IFile> files) >+ { >+ AddSubroutineParameterRefactoring r = new AddSubroutineParameterRefactoring(); >+ r.initialize(getFortranEditor().getIFile(), getFortranEditor().getSelection()); >+ return r; >+ } >+ >+ public static class FortranAddSubroutineParameterRefactoringWizard extends >+ AbstractFortranRefactoringWizard >+ { >+ protected AddSubroutineParameterRefactoring addSubRefactoring; >+ >+ public FortranAddSubroutineParameterRefactoringWizard(AddSubroutineParameterRefactoring r) >+ { >+ super(r); >+ this.addSubRefactoring = r; >+ } >+ >+ @Override >+ protected void doAddUserInputPages() >+ { >+ addPage(new UserInputWizardPage(addSubRefactoring.getName()) >+ { >+ protected Text declField; >+ protected Text locationField; >+ protected Text defaultField; >+ >+ public void createControl(Composite parent) >+ { >+ Composite group = new Composite(parent, SWT.NONE); >+ initializeDialogUnits(group); >+ setControl(group); >+ group.setLayout(new GridLayout(3, false)); >+ >+ GridData threeCol = new GridData(); >+ threeCol.horizontalSpan = 3; >+ >+ Label lbl = new Label(group, SWT.NONE); >+ lbl.setText(Messages.AddSubroutineParameterAction_DeclarationLabel); >+ Label lbl3 = new Label(group, SWT.NONE); >+ lbl3.setText(Messages.AddSubroutineParameterAction_DefaultLabel); >+ Label lbl2 = new Label(group, SWT.NONE); >+ lbl2.setText(Messages.AddSubroutineParameterAction_LocationLabel); >+ >+ declField = new Text(group, SWT.BORDER); >+ declField.setText(addSubRefactoring.getDeclaration()); >+ declField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ declField.selectAll(); >+ declField.addModifyListener(new ModifyListener() >+ { >+ public void modifyText(ModifyEvent e) >+ { >+ addSubRefactoring.setDeclaration(declField.getText()); >+ } >+ }); >+ >+ defaultField = new Text(group, SWT.BORDER); >+ defaultField.setText(addSubRefactoring.getDefault()); >+ defaultField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ defaultField.selectAll(); >+ defaultField.addModifyListener(new ModifyListener() >+ { >+ public void modifyText(ModifyEvent e) >+ { >+ addSubRefactoring.setDefaultValue(defaultField.getText()); >+ } >+ }); >+ >+ locationField = new Text(group, SWT.BORDER); >+ locationField.setText(String.valueOf(addSubRefactoring.getPosition())); >+ locationField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ locationField.selectAll(); >+ locationField.addModifyListener(new ModifyListener() >+ { >+ public void modifyText(ModifyEvent e) >+ { >+ addSubRefactoring.setPosition(Integer.parseInt(locationField.getText())); >+ } >+ }); >+ >+ //creates the table that lists the variables that exist in the subroutine >+ List<ASTSubroutineParNode> parList = addSubRefactoring.getOldParameterList(); >+ >+ GridData gridData = new GridData(GridData.VERTICAL_ALIGN_END); >+ gridData.horizontalSpan = 3; >+ gridData.horizontalAlignment = GridData.FILL; >+ >+ Table table = new Table (group, SWT.BORDER ); >+ table.setLinesVisible (true); >+ table.setHeaderVisible (true); >+ table.setLayoutData(gridData); >+ for (int i = 0; i < parList.size(); i++){ >+ TableColumn column = new TableColumn (table, SWT.NONE); >+ column.setText (String.valueOf(i)); >+ } >+ TableItem item = new TableItem (table, SWT.NONE); >+ for (int i = 0; i < parList.size(); i++){ >+ item.setText (i, parList.get(i).getVariableName().getText()); >+ } >+ for (int i=0; i<parList.size(); i++) { >+ table.getColumn (i).pack (); >+ } >+ >+ // Call once for sure, just in case the user doesn't modify the text >+ // addSubRefactoring.setDeclaration(declField.getText()); >+ >+ int offset = declField.getText().indexOf(":: "); //$NON-NLS-1$ >+ if (offset < 0) >+ offset = 0; >+ else >+ offset = offset + ":: ".length(); //$NON-NLS-1$ >+ declField.setSelection(offset, declField.getText().length()); >+ declField.setFocus(); >+ } >+ }); >+ } >+ } >+} >Index: src/org/eclipse/photran/internal/ui/refactoring/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/photran/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/refactoring/Messages.java,v >retrieving revision 1.3 >diff -u -r1.3 Messages.java >--- src/org/eclipse/photran/internal/ui/refactoring/Messages.java 21 Sep 2010 13:26:16 -0000 1.3 >+++ src/org/eclipse/photran/internal/ui/refactoring/Messages.java 15 Dec 2010 03:35:33 -0000 >@@ -19,6 +19,10 @@ > { > private static final String BUNDLE_NAME = "org.eclipse.photran.internal.ui.refactoring.messages"; //$NON-NLS-1$ > >+ public static String AddSubroutineParameterAction_DefaultLabel; >+ >+ public static String AddSubroutineParameterAction_DeclarationLabel; >+ > public static String AbstractFortranRefactoringActionDelegate_ErrorTitle; > > public static String AbstractFortranRefactoringActionDelegate_FileInEditorCannotBeRefactored; >@@ -62,6 +66,8 @@ > public static String CommonVarNamesInputPage_OriginalNameLabel; > > public static String ExtractLocalVariableAction_DeclarationLabel; >+ >+ //public static String AddSubroutineParameterAction_DeclarationLabel; > > public static String ExtractProcedureAction_SubroutineNameLabel; > >@@ -84,6 +90,8 @@ > public static String RenameAction_MatchExternalSubprograms; > > public static String RenameAction_RenameAtoB; >+ >+ public static String AddSubroutineParameterAction_LocationLabel; > static > { > // initialize resource bundle >Index: src/org/eclipse/photran/internal/ui/refactoring/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/photran/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/refactoring/messages.properties,v >retrieving revision 1.2 >diff -u -r1.2 messages.properties >--- src/org/eclipse/photran/internal/ui/refactoring/messages.properties 21 Sep 2010 13:26:16 -0000 1.2 >+++ src/org/eclipse/photran/internal/ui/refactoring/messages.properties 15 Dec 2010 03:35:33 -0000 >@@ -2,6 +2,9 @@ > AbstractFortranRefactoringActionDelegate_FileInEditorCannotBeRefactored=The file in the editor cannot be refactored.\n\nFortran files can only be refactored if they are located inside a Fortran project in your workspace. > AddOnlyToUseStmtInputPage_ClickOKMessage=Click OK to add the ONLY clause to the selected USE statement. To see what changes will be made, click Preview. > AddOnlyToUseStmtInputPage_SelectModuleEntitiesLabel=Select the module entities to add to the ONLY clause. >+AddSubroutineParameterAction_DeclarationLabel=Declaration: >+AddSubroutineParameterAction_LocationLabel=Position: >+AddSubroutineParameterAction_DefaultLabel=Default Value: > PermuteSubroutineArgsInputPage_alternateReturnColumnLabel=Alternate Return > PermuteSubroutineArgsInputPage_alternateReturnErrorLabel=The relative order of alternate returns must remain the same.\n > PermuteSubroutineArgsInputPage_downButtonLabel=Down
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 332596
:
185202
|
185246