View | Details | Raw Unified | Return to bug 331880 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/photran/internal/core/refactoring/IfConstructStatementConversionRefactoring.java (+237 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Zeeshan Ansari, Mark Chen, Burim Isai, Waseem Sheikh, Mumtaz Vauhkonen
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    UIUC - Initial API and implementation
10
 *    Zeeshan Ansari
11
 *    Mark Chen
12
 *    Mumtaz Vauhkonen
13
 *    Burim Isai
14
 *    Waseem Sheikh
15
 *******************************************************************************/
16
package org.eclipse.photran.internal.core.refactoring;
17
18
import java.util.ArrayList;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.OperationCanceledException;
22
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
23
import org.eclipse.photran.internal.core.parser.ASTIfConstructNode;
24
import org.eclipse.photran.internal.core.parser.ASTIfStmtNode;
25
import org.eclipse.photran.internal.core.parser.ASTNode;
26
import org.eclipse.photran.internal.core.refactoring.infrastructure.FortranEditorRefactoring;
27
import org.eclipse.photran.internal.core.reindenter.Reindenter;
28
import org.eclipse.photran.internal.core.reindenter.Reindenter.Strategy;
29
30
/**
31
 * Converts an IF construct to an IF statement and vice versa. User must select
32
 * the entire IF statement or IF construct block, and select the refactoring
33
 * option in the menu.
34
 * 
35
 * @author Zeeshan Ansari
36
 * @author Mark Chen
37
 * @author Mumtaz Vauhkonen
38
 * @author Burim Isai
39
 * @author Waseem Sheikh
40
 */
41
public class IfConstructStatementConversionRefactoring extends FortranEditorRefactoring
42
{
43
    private ASTNode selectedNode = null;
44
    private ASTNode ifStmtNode, ifConstructNode;
45
    private boolean shouldAddEmptyElseBlock = false;
46
    private ArrayList<String> commentList = new ArrayList<String>();
47
48
    /**
49
     * Beyond the standard condition checks, this checks to ensure that a valid
50
     * IF statement or IF construct is selected and is refactorable.
51
     * 
52
     * @param ifConstructNode
53
     * @throws PreconditionFailure
54
     * @author Zeeshan Ansari
55
     * @author Mark Chen
56
     * @author Burim Isai
57
     * @author Waseem Sheikh
58
     */
59
    @Override
60
    protected void doCheckInitialConditions(RefactoringStatus status, IProgressMonitor pm)
61
        throws PreconditionFailure
62
    {
63
        ensureProjectHasRefactoringEnabled(status);
64
       
65
        if(!fileInEditor.exists())
66
            fail(Messages.FortranEditorRefactoring_CantPerformRefactoringOnFileThatDoesNotExist);
67
        
68
        if(fileInEditor.isReadOnly())
69
            fail(Messages.FortranEditorRefactoring_CantPerformRefactoringOnReadOnlyFile);
70
 
71
        ifStmtNode = getNode(this.astOfFileInEditor, this.selectedRegionInEditor, ASTIfStmtNode.class);
72
        ifConstructNode = getNode(this.astOfFileInEditor, this.selectedRegionInEditor, ASTIfConstructNode.class);
73
        
74
        if(ifStmtNode != null)
75
            selectedNode = ifStmtNode;
76
        else if(ifConstructNode != null) {
77
            checkRefactorableConstruct(ifConstructNode);
78
            selectedNode = ifConstructNode;
79
        }
80
        else
81
            fail(Messages.IfConstructStatementConversionRefactoring_SelectAValidIfStatement);
82
    }
83
84
    /**
85
     * Checks various conditions to see if the user-selected IF construct is refactorable to an
86
     * IF statement. This includes making sure there is only one valid statement line in the
87
     * construct and that the construct is not named.
88
     * 
89
     * @param ifConstructNode
90
     * @throws PreconditionFailure
91
     * @author Mark Chen
92
     * @author Waseem Sheikh
93
     * @author Mumtaz Vauhkonen
94
     */
95
    private void checkRefactorableConstruct(ASTNode ifConstructNode)
96
        throws org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring.PreconditionFailure
97
    {
98
        String constructParser = null;
99
        int validStatements = 0;
100
101
        //Checks for named construct
102
        if(!ifConstructNode.findFirstToken().getText().equals("if")) //$NON-NLS-1$
103
            fail(Messages.IfConstructStatementConversionRefactoring_InvalidNamedConstruct);
104
        
105
        //Check for multiple statements within construct and stores comment lines
106
        constructParser = this.selectedRegionInEditor.getText();
107
        constructParser = constructParser.substring(constructParser.indexOf("\n")+1).trim(); //$NON-NLS-1$
108
        while(constructParser.contains("\n")) { //$NON-NLS-1$
109
            constructParser = constructParser.substring(constructParser.indexOf("\n")+1).trim(); //$NON-NLS-1$
110
            if(!constructParser.startsWith("!") && !constructParser.startsWith("end if")) //$NON-NLS-1$ //$NON-NLS-2$
111
                ++validStatements;
112
            if(constructParser.startsWith("!")) //$NON-NLS-1$
113
                commentList.add(constructParser.substring(0, constructParser.indexOf("\n")).trim()); //$NON-NLS-1$
114
        }
115
        if(validStatements > 1)
116
            fail(Messages.IfConstructStatementConversionRefactoring_TooManyStatements);
117
    }
118
    
119
    public boolean isStmtNode() {
120
        return ifStmtNode != null;
121
    }
122
    
123
    public void AddEmptyElseBlock() {
124
        shouldAddEmptyElseBlock = true;
125
    }
126
127
    @Override
128
    protected void doCheckFinalConditions(RefactoringStatus status, IProgressMonitor pm)
129
        throws PreconditionFailure
130
    {
131
        // No final preconditions
132
    }
133
134
    /**
135
     * Determines whether an IF statement is selected or an IF construct is selected (done in pre-condition).
136
     * Depending on which, it will execute the appropriate refactoring (statement to construct or vise versa).
137
     * It will then reindent the entire section of refactored code based on the formating context of the code
138
     * around it.
139
     * 
140
     * @param pm
141
     * @throws CoreException, OperationCanceledException
142
     * @author Zeeshan Ansari
143
     * @author Mark Chen
144
     * @author Mumtaz Vauhkonen
145
     */
146
    @Override
147
    protected void doCreateChange(IProgressMonitor pm) throws CoreException,
148
        OperationCanceledException
149
    {
150
        if(selectedNode instanceof ASTIfStmtNode){
151
            RefactorIfStmt();
152
        }
153
        else if (selectedNode instanceof ASTIfConstructNode){
154
            RefactorIfConstruct();
155
        }
156
        else
157
            throw new OperationCanceledException();
158
        
159
        Reindenter.reindent(selectedNode, this.astOfFileInEditor, Strategy.REINDENT_EACH_LINE);
160
        this.addChangeFromModifiedAST(this.fileInEditor, pm);
161
        vpg.releaseAST(this.fileInEditor);
162
        
163
    }
164
    
165
    protected void RefactorIfStmt(){
166
        ASTIfStmtNode ifStmtNode = (ASTIfStmtNode)selectedNode;
167
                
168
        ifStmtNode.replaceWith(createNewIfConstruct(ifStmtNode));
169
    }
170
    
171
    protected void RefactorIfConstruct(){
172
        ASTIfConstructNode ifConstructNode = (ASTIfConstructNode)selectedNode;
173
        
174
        ifConstructNode.replaceWith(createNewIfStmt(ifConstructNode));
175
    }
176
    
177
    /**
178
     * Creates a new IF statement from the selected IF construct
179
     * 
180
     * @param ifConstructNode
181
     * @author Mark Chen
182
     * @author Waseem Sheikh
183
     * @author Mumtaz Vauhkonen
184
     */
185
    private ASTIfStmtNode createNewIfStmt(ASTIfConstructNode ifConstructNode) {
186
        StringBuilder sb = new StringBuilder();
187
188
        sb.append("    if ("); //$NON-NLS-1$
189
        sb.append(ifConstructNode.getIfThenStmt().getGuardingExpression().toString().trim());
190
        sb.append(") "); //$NON-NLS-1$
191
        sb.append(ifConstructNode.getConditionalBody().toString().trim());
192
        for(String comment : commentList) 
193
            sb.append(" " + comment); //$NON-NLS-1$
194
        sb.append("\n"); //$NON-NLS-1$
195
196
        ASTIfStmtNode newIfStmtNode = (ASTIfStmtNode)parseLiteralIfStmtNode(sb.toString());
197
198
        return newIfStmtNode;
199
    }
200
    
201
    /**
202
     * Creates a new IF construct from the selected IF statement, with an option
203
     * to add an empty ELSE construct
204
     * 
205
     * @param ifConstructNode
206
     * @author Zeeshan Ansari
207
     * @author Mark Chen
208
     * @author Burim Isai
209
     * @author Mumtaz Vauhkonen
210
     */
211
    private ASTIfConstructNode createNewIfConstruct(ASTIfStmtNode ifStmtNode){
212
        StringBuilder sb = new StringBuilder();
213
214
        sb.append("    if ("); //$NON-NLS-1$
215
        sb.append(ifStmtNode.getGuardingExpression().toString());
216
        sb.append(") then"); //$NON-NLS-1$
217
        sb.append("\n        "); //$NON-NLS-1$
218
        sb.append(ifStmtNode.getActionStmt().toString().trim());
219
        sb.append("\n        !can add more statements here"); //$NON-NLS-1$
220
        if(shouldAddEmptyElseBlock)
221
        {
222
            sb.append("\n    else"); //$NON-NLS-1$
223
            sb.append("\n        !can add more statements here"); //$NON-NLS-1$
224
        }
225
        sb.append("\n    end if"); //$NON-NLS-1$
226
227
        ASTIfConstructNode newIfConstructNode = (ASTIfConstructNode)parseLiteralIfConstructNode(sb.toString());
228
229
        return newIfConstructNode;
230
    }
231
  
232
    @Override
233
    public String getName()
234
    {
235
        return Messages.IfConstructStatementConversionRefactoring_Name;
236
    }
237
}
(-)src/org/eclipse/photran/internal/core/refactoring/Messages.java (+12 lines)
Lines 267-272 Link Here
267
    public static String ExtractLocalVariableRefactoring_VarsOnlyExtractedFromStmtsIn;
267
    public static String ExtractLocalVariableRefactoring_VarsOnlyExtractedFromStmtsIn;
268
268
269
    public static String InterchangeLoopsRefactoring_Name;
269
    public static String InterchangeLoopsRefactoring_Name;
270
    
271
    public static String IfConstructStatementConversionRefactoring_Name;
272
    
273
    public static String IfConstructStatementConversionRefactoring_SelectAValidIfStatement;
274
275
    public static String IfConstructStatementConversionRefactoring_InvalidNamedConstruct;
276
    
277
    public static String IfConstructStatementConversionRefactoring_TooManyStatements;
278
    
279
    public static String FortranEditorRefactoring_CantPerformRefactoringOnReadOnlyFile;
280
    
281
    public static String FortranEditorRefactoring_CantPerformRefactoringOnFileThatDoesNotExist;
270
282
271
    public static String InterchangeLoopsRefactoring_SelectTwoPerfNextedLoops;
283
    public static String InterchangeLoopsRefactoring_SelectTwoPerfNextedLoops;
272
284
(-)src/org/eclipse/photran/internal/core/refactoring/messages.properties (+6 lines)
Lines 200-202 Link Here
200
SafeDeleteInternalSubprogramRefactoring_SubroutineMustHaveOnlyInternalReferences=Subroutine must only have internal references.
200
SafeDeleteInternalSubprogramRefactoring_SubroutineMustHaveOnlyInternalReferences=Subroutine must only have internal references.
201
StandardizeStatementsRefactoring_Name=Standardize Statements
201
StandardizeStatementsRefactoring_Name=Standardize Statements
202
StandardizeStatementsRefactoring_SelectedFileCannotBeParsed=One of the selected files ({0}) cannot be parsed.
202
StandardizeStatementsRefactoring_SelectedFileCannotBeParsed=One of the selected files ({0}) cannot be parsed.
203
IfConstructStatementConversionRefactoring_Name= Convert Between IF Statement and IF Construct
204
IfConstructStatementConversionRefactoring_SelectAValidIfStatement= Please select a valid IF statement or construct.
205
IfConstructStatementConversionRefactoring_InvalidNamedConstruct= Cannot refactor a named IF construct. Please select an unnamed IF construct.
206
IfConstructStatementConversionRefactoring_TooManyStatements= Selected IF construct contains too many statements and cannot be refactored to an IF statement.
207
FortranEditorRefactoring_CantPerformRefactoringOnReadOnlyFile= Can't perform refactoring on a read-only file.
208
FortranEditorRefactoring_CantPerformRefactoringOnFileThatDoesNotExist= Can't perform refactoring on a file that does not exist.
(-)src/org/eclipse/photran/internal/core/refactoring/infrastructure/FortranResourceRefactoring.java (+39 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    UIUC - Initial API and implementation
9
 *    UIUC - Initial API and implementation
10
 *    Zeeshan Ansari
11
 *    Mark Chen
12
 *    Burim Isai
13
 *    Waseem Sheihk
14
 *    Mumtaz Vauhkonen
10
 *******************************************************************************/
15
 *******************************************************************************/
11
package org.eclipse.photran.internal.core.refactoring.infrastructure;
16
package org.eclipse.photran.internal.core.refactoring.infrastructure;
12
17
Lines 43-48 Link Here
43
import org.eclipse.photran.internal.core.parser.ASTCallStmtNode;
48
import org.eclipse.photran.internal.core.parser.ASTCallStmtNode;
44
import org.eclipse.photran.internal.core.parser.ASTContainsStmtNode;
49
import org.eclipse.photran.internal.core.parser.ASTContainsStmtNode;
45
import org.eclipse.photran.internal.core.parser.ASTFunctionSubprogramNode;
50
import org.eclipse.photran.internal.core.parser.ASTFunctionSubprogramNode;
51
import org.eclipse.photran.internal.core.parser.ASTIfConstructNode;
52
import org.eclipse.photran.internal.core.parser.ASTIfStmtNode;
46
import org.eclipse.photran.internal.core.parser.ASTImplicitStmtNode;
53
import org.eclipse.photran.internal.core.parser.ASTImplicitStmtNode;
47
import org.eclipse.photran.internal.core.parser.ASTMainProgramNode;
54
import org.eclipse.photran.internal.core.parser.ASTMainProgramNode;
48
import org.eclipse.photran.internal.core.parser.ASTModuleNode;
55
import org.eclipse.photran.internal.core.parser.ASTModuleNode;
Lines 281-286 Link Here
281
        LoopReplacer.replaceAllLoopsIn(prog);
288
        LoopReplacer.replaceAllLoopsIn(prog);
282
        return (ASTProperLoopConstructNode)prog.getBody().get(0);
289
        return (ASTProperLoopConstructNode)prog.getBody().get(0);
283
    }
290
    }
291
    
292
    /**
293
     * Parses the given If-Construct as a {@link ASTIfConstructNode}.
294
     * <p>
295
     * @see parseLiteralStatement
296
     * @param string
297
     * @author Zeeshan Ansari
298
     * @author Mark Chen
299
     * @author Mumtaz Vauhkonen
300
     */
301
    protected static ASTIfConstructNode parseLiteralIfConstructNode(String string)
302
    {
303
        string = "program p\n" + string + "\nend program"; //$NON-NLS-1$ //$NON-NLS-2$
304
        ASTMainProgramNode prog = (ASTMainProgramNode)parseLiteralProgramUnit(string);
305
        return (ASTIfConstructNode)prog.getBody().get(0);
306
    }
307
    
308
    /**
309
     * Parses the given If-Statement as a {@link ASTIfStmtNode}.
310
     * <p>
311
     * @see parseLiteralStatement
312
     * @param string
313
     * @author Mark Chen
314
     * @author Burim Isai
315
     * @author Mumtaz Vauhkonen
316
     */
317
    protected static ASTIfStmtNode parseLiteralIfStmtNode(String string)
318
    {
319
        string = "program p\n" + string + "\nend program"; //$NON-NLS-1$ //$NON-NLS-2$
320
        ASTMainProgramNode prog = (ASTMainProgramNode)parseLiteralProgramUnit(string);
321
        return (ASTIfStmtNode)prog.getBody().get(0);
322
    }
284
323
285
    /** @return a CONTAINS statement */
324
    /** @return a CONTAINS statement */
286
    protected static ASTContainsStmtNode createContainsStmt()
325
    protected static ASTContainsStmtNode createContainsStmt()
(-)refactoring-test-code/if-construct-statement-conversion/test01-fail-notAValidIfStatement/convertIfStatementToIfConstruct_InvalidIfStatement.f90 (+8 lines)
Added Link Here
1
program notAValidIf
2
    implicit none
3
    print *, "This is a test"
4
    print *, 3+4*5+6 !<<<<< 4, 5, 4, 22, fail-initial
5
    
6
    !!! This test shows the refactoring failing the initial precondition because the selected text is a print statement, and
7
    !!! not a valid IF statement or construct
8
end program
(-)refactoring-test-code/if-construct-statement-conversion/test02-convert_ifConstructToIfStmt/convert_ifConstruct.f90 (+10 lines)
Added Link Here
1
program convert_ifConstructToIfStmt
2
    implicit none
3
    print *, "This is a test"
4
    if(.true.) then
5
      a = 1
6
    end if
7
    !<<<<< 4, 5, 6, 11, pass
8
    
9
    !!! This test shows the refactoring successfully refactoring a simple valid IF construct into a valid IF statement.
10
end program
(-)refactoring-test-code/if-construct-statement-conversion/test02-convert_ifConstructToIfStmt/convert_ifConstruct.f90.result (+8 lines)
Added Link Here
1
program convert_ifConstructToIfStmt
2
    implicit none
3
    print *, "This is a test"
4
    if (.true.) a = 1
5
    !<<<<< 4, 5, 6, 11, pass
6
    
7
    !!! This test shows the refactoring successfully refactoring a simple valid IF construct into a valid IF statement.
8
end program
(-)refactoring-test-code/if-construct-statement-conversion/test03-fail-ifNamedVariable/convert_ifStatement_ifNamedVariable.f90 (+9 lines)
Added Link Here
1
program convert_ifStatementToIfConstruct_incorrectSelection
2
    implicit none
3
    print *, "This is a test"
4
    integer :: if
5
    if = 5 !<<<<< 5, 5, 5, 11, fail-initial
6
    
7
    !!! This test shows the refactoring failing the initial precondition because the selected text is not a valid
8
    !!! IF statement or construct, even though the first token is "if"
9
end program
(-)refactoring-test-code/if-construct-statement-conversion/test04-complexboolean/ifStmtComplexBoolean_1.f90 (+9 lines)
Added Link Here
1
program ifStmtComplexBoolean_1
2
    implicit none
3
    integer :: x, y, a
4
    print *, "This is a test"
5
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) a = 1 !<<<<< 5, 5, 5, 53, pass
6
    
7
    !!! This tests shows the refactoring successfully converting a valid IF statement to a valid IF construct, even
8
    !!! with a complex boolean guardian expression.
9
end program
(-)refactoring-test-code/if-construct-statement-conversion/test04-complexboolean/ifStmtComplexBoolean_1.f90.result (+12 lines)
Added Link Here
1
program ifStmtComplexBoolean_1
2
    implicit none
3
    integer :: x, y, a
4
    print *, "This is a test"
5
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) then
6
        a = 1 !<<<<< 5, 5, 5, 53, pass
7
        !can add more statements here
8
    end if
9
    
10
    !!! This tests shows the refactoring successfully converting a valid IF statement to a valid IF construct, even
11
    !!! with a complex boolean guardian expression.
12
end program
(-)refactoring-test-code/if-construct-statement-conversion/test05-complexboolean/ifStmtComplexBoolean_2.f90 (+9 lines)
Added Link Here
1
program ifStmtComplexBoolean_2
2
    implicit none
3
    integer :: x, y, z, a
4
    print *, "This is a test"
5
    if ((x*2+3)/z .GE. y) a = 1 !<<<<< 5, 5, 5, 32, pass
6
    
7
    !!! This tests shows the refactoring successfully converting a valid IF statement to a valid IF construct, even
8
    !!! with a complex boolean guardian expression.
9
end program
(-)refactoring-test-code/if-construct-statement-conversion/test05-complexboolean/ifStmtComplexBoolean_2.f90.result (+12 lines)
Added Link Here
1
program ifStmtComplexBoolean_2
2
    implicit none
3
    integer :: x, y, z, a
4
    print *, "This is a test"
5
    if ((x*2+3)/z .GE. y) then
6
        a = 1 !<<<<< 5, 5, 5, 32, pass
7
        !can add more statements here
8
    end if
9
    
10
    !!! This tests shows the refactoring successfully converting a valid IF statement to a valid IF construct, even
11
    !!! with a complex boolean guardian expression.
12
end program
(-)refactoring-test-code/if-construct-statement-conversion/test06-convertifStmt/convertIfStatementToIfConstruct.f90 (+10 lines)
Added Link Here
1
program convertIfStatementToIfConstruct
2
    implicit none
3
    integer :: var1, var2
4
    print *, "This is an if construct example."
5
    var1 = 4
6
    var2 = 5
7
    if (var1 < var2) print *, var1, " is less than ", var2, " using if-stmt." !<<<<< 7, 5, 7, 78, pass
8
    
9
    !!! This tests shows the refactoring successfully converting a valid IF statement to a valid IF construct.
10
end program
(-)refactoring-test-code/if-construct-statement-conversion/test06-convertifStmt/convertIfStatementToIfConstruct.f90.result (+13 lines)
Added Link Here
1
program convertIfStatementToIfConstruct
2
    implicit none
3
    integer :: var1, var2
4
    print *, "This is an if construct example."
5
    var1 = 4
6
    var2 = 5
7
    if (var1 < var2) then
8
        print *, var1, " is less than ", var2, " using if-stmt." !<<<<< 7, 5, 7, 78, pass
9
        !can add more statements here
10
    end if
11
    
12
    !!! This tests shows the refactoring successfully converting a valid IF statement to a valid IF construct.
13
end program
(-)refactoring-test-code/if-construct-statement-conversion/test07-ifConstructToStmtBasic/ifConstructToStmtBasic_1.f90 (+8 lines)
Added Link Here
1
program ifConstructToStmtBasic_1
2
    if (.true.) then
3
	    a = 2
4
    end if
5
    !<<<<< 2, 5, 4, 11, pass
6
    
7
    !!! This tests shows the refactoring successfully converting a valid IF construct to a valid IF statement.
8
end program
(-)refactoring-test-code/if-construct-statement-conversion/test07-ifConstructToStmtBasic/ifConstructToStmtBasic_1.f90.result (+6 lines)
Added Link Here
1
program ifConstructToStmtBasic_1
2
    if (.true.) a = 2
3
    !<<<<< 2, 5, 4, 11, pass
4
    
5
    !!! This tests shows the refactoring successfully converting a valid IF construct to a valid IF statement.
6
end program
(-)refactoring-test-code/if-construct-statement-conversion/test08-nonIfToken/nonIfToken_fail.f90 (+14 lines)
Added Link Here
1
program nonIfToken_1
2
	integer :: i, j
3
	integer :: k, z
4
	do j = 1, 10 !<<<<< 4, 5, 10, 11, fail-initial
5
		print *, i                   
6
   		if (i .gt. j) then
7
     		print *, i * 10
8
   		end if                      
9
   		print *, i
10
	end do
11
    
12
    !!! This tests shows the refactoring failing the initial precondition because the selected text is not a valid
13
    !!! IF statement or construct, since the first token is "do"
14
end program
(-)refactoring-test-code/if-construct-statement-conversion/test09-ifConstructComplexBoolean/ifConstructComplexBoolean_1.f90 (+12 lines)
Added Link Here
1
program ifConstructComplexBoolean_1
2
    implicit none
3
    integer :: x, y, a
4
    print *, "This is a test"
5
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) then
6
        a = 1
7
    end if
8
    !<<<<< 5, 5, 7, 11, pass
9
    
10
    !!! This tests shows the refactoring successfully converting a valid IF construct to a valid IF statement, even
11
    !!! with a complex boolean guardian expression.
12
end program
(-)refactoring-test-code/if-construct-statement-conversion/test09-ifConstructComplexBoolean/ifConstructComplexBoolean_1.f90.result (+10 lines)
Added Link Here
1
program ifConstructComplexBoolean_1
2
    implicit none
3
    integer :: x, y, a
4
    print *, "This is a test"
5
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) a = 1
6
    !<<<<< 5, 5, 7, 11, pass
7
    
8
    !!! This tests shows the refactoring successfully converting a valid IF construct to a valid IF statement, even
9
    !!! with a complex boolean guardian expression.
10
end program
(-)refactoring-test-code/if-construct-statement-conversion/test10-namedIfConstruct/namedIfConstruct_fail.f90 (+9 lines)
Added Link Here
1
program namedIfConstruct_fail
2
    myifconstruct: if (.true.) then
3
        a = 3
4
    end if myifconstruct
5
    print *, "This test tries to convert a named if construct to if statement" !<<<<< 2, 5, 4, 11, fail-initial
6
    
7
    !!! This test shows the refactoring failing the initial precondition because while the selected text is a
8
    !!! valid IF construct, it is a named IF construct, and therefore is not refactorable to an IF statement
9
end program
(-)refactoring-test-code/if-construct-statement-conversion/test11-multiLineIfConstructToIfStatement-failure/multiLineIfConstructToIfStmt.f90 (+12 lines)
Added Link Here
1
program convert_multiLineIfConstructToIfStatement
2
    if (.true.) then
3
        a = 2
4
        print *, 'hello'
5
        print *, 'world'
6
    end if
7
    print *, 3+4*5+6 !<<<<< 2, 5, 6, 11, fail-initial
8
    
9
    !!! This test shows the refactoring failing the initial precondition because while the selected text is a valid
10
    !!! IF construct, the body contains multiple lines of valid statements, and therefore, is not refactorable to
11
    !!! an IF statement.
12
end program
(-)refactoring-test-code/if-construct-statement-conversion/test12-generalIfConstToIfStmt-failure/generalIfConstToIfStmt.f90 (+13 lines)
Added Link Here
1
program convert_blockIfConstructToIfStatement
2
    if (x .LT. 1) then
3
        a = 2
4
    else if (x .GE. 1) then
5
        a = 4
6
    else
7
        a = 6
8
    end if !<<<<< 2, 5, 8, 11, fail-initial
9
    
10
    !!! This test shows the refactoring failing the initial precondition because while the selected text is a valid
11
    !!! IF construct, the body contains multiple lines of valid statements, and therefore, is not refactorable to
12
    !!! an IF statement.
13
end program
(-)refactoring-test-code/if-construct-statement-conversion/test13-fail-multipleIfSelections1/multipleIfSelections1.f90 (+10 lines)
Added Link Here
1
program multipleIfSelections1
2
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) a = 1
3
    if (.true.) then
4
	    a = 2
5
    end if 
6
    !<<<<< 2, 5, 5, 11, fail-initial
7
    
8
    !!! This test shows the refactoring failing the initial precondition because multiple IF statements and IF
9
    !!! constructs are selected, while the refactoring can only handle one at a time.
10
end program
(-)refactoring-test-code/if-construct-statement-conversion/test14-fail-multipleIfSelections2/multipleIfSelections2.f90 (+10 lines)
Added Link Here
1
program multipleIfSelections2
2
    if (.true.) then
3
	    a = 2
4
    end if 
5
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) a = 1
6
    !<<<<< 2, 5, 5, 53, fail-initial
7
    
8
    !!! This test shows the refactoring failing the initial precondition because multiple IF statements and IF
9
    !!! constructs are selected, while the refactoring can only handle one at a time.
10
end program
(-)refactoring-test-code/if-construct-statement-conversion/test15-commentInIfConstructToIfStmt/commentIfConstructToIfStmt.f90 (+11 lines)
Added Link Here
1
program commentIfConstructToIfStmt
2
    implicit none
3
    integer :: x, y, a
4
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) then
5
        a = 1 !This is an if statement
6
    end if
7
    print *, "This is a test" !<<<<< 4, 5, 6, 11, pass
8
    
9
    !!! This test shows the refactoring successfully converting a valid IF construct to a valid IF statement, while
10
    !!! also preserving the included comment.
11
end program
(-)refactoring-test-code/if-construct-statement-conversion/test15-commentInIfConstructToIfStmt/commentIfConstructToIfStmt.f90.result (+9 lines)
Added Link Here
1
program commentIfConstructToIfStmt
2
    implicit none
3
    integer :: x, y, a
4
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) a = 1 !This is an if statement
5
    print *, "This is a test" !<<<<< 4, 5, 6, 11, pass
6
    
7
    !!! This test shows the refactoring successfully converting a valid IF construct to a valid IF statement, while
8
    !!! also preserving the included comment.
9
end program
(-)refactoring-test-code/if-construct-statement-conversion/test16-commentInIfStmtToIfConstruct/commentInIfStmtToIfConst.f90 (+9 lines)
Added Link Here
1
program commentIfStmtToIfConstruct
2
    implicit none
3
    integer :: x, y, a
4
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) a = 1 !This is an if statement
5
    print *, "This is a test" !<<<<< 4, 5, 4, 78, pass
6
    
7
    !!! This test shows the refactoring successfully converting a valid IF statement to a valid IF construct, while
8
    !!! also preserving the included comment.
9
end program
(-)refactoring-test-code/if-construct-statement-conversion/test16-commentInIfStmtToIfConstruct/commentInIfStmtToIfConst.f90.result (+12 lines)
Added Link Here
1
program commentIfStmtToIfConstruct
2
    implicit none
3
    integer :: x, y, a
4
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) then
5
        a = 1 !This is an if statement
6
        !can add more statements here
7
    end if
8
    print *, "This is a test" !<<<<< 4, 5, 4, 78, pass
9
    
10
    !!! This test shows the refactoring successfully converting a valid IF statement to a valid IF construct, while
11
    !!! also preserving the included comment.
12
end program
(-)refactoring-test-code/if-construct-statement-conversion/test17-reindentIfConstruct/reindentIfConstruct.f90 (+9 lines)
Added Link Here
1
program reindentIfConstruct
2
                                     if (1 .GE. 1) then
3
                                     	a = 1
4
                                     end if
5
    !<<<<< 2, 38, 4, 44, pass
6
    
7
    !!! This test shows the refactoring successfully converting a valid IF construct to a valid IF statement, and 
8
    !!! then reindenting the section of code to the correct location, based on code context.
9
end program
(-)refactoring-test-code/if-construct-statement-conversion/test17-reindentIfConstruct/reindentIfConstruct.f90.result (+7 lines)
Added Link Here
1
program reindentIfConstruct
2
    if (1 .GE. 1) a = 1
3
    !<<<<< 2, 38, 4, 44, pass
4
    
5
    !!! This test shows the refactoring successfully converting a valid IF construct to a valid IF statement, and 
6
    !!! then reindenting the section of code to the correct location, based on code context.
7
end program
(-)refactoring-test-code/if-construct-statement-conversion/test18-commentHandling/commentHandling.f90 (+15 lines)
Added Link Here
1
program commentHandling
2
    implicit none
3
    integer :: x, y, a
4
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) then
5
        a = 1 !This is an if statement
6
        !can add more statements here
7
        !more comments here
8
    end if
9
    print *, "This is a test" !<<<<< 4, 5, 8, 11, pass
10
    
11
    !!! This test shows the refactoring successfully converting a valid IF construct to a valid IF statement. Even though the IF
12
    !!! construct has multiple lines of code, only one of which is a valid statement, so it is therefore still refactorable. The
13
    !!! refactoring will then take the lines of comments and append them to the end of the IF statement in order to preserve them.
14
    !!! The user can then reformat the comments as they feel fit.
15
end program
(-)refactoring-test-code/if-construct-statement-conversion/test18-commentHandling/commentHandling.f90.result (+11 lines)
Added Link Here
1
program commentHandling
2
    implicit none
3
    integer :: x, y, a
4
    if (x .LT. y .OR. y .GT. 5 .AND. 6 .GE. 6) a = 1 !This is an if statement !can add more statements here !more comments here
5
    print *, "This is a test" !<<<<< 4, 5, 8, 11, pass
6
    
7
    !!! This test shows the refactoring successfully converting a valid IF construct to a valid IF statement. Even though the IF
8
    !!! construct has multiple lines of code, only one of which is a valid statement, so it is therefore still refactorable. The
9
    !!! refactoring will then take the lines of comments and append them to the end of the IF statement in order to preserve them.
10
    !!! The user can then reformat the comments as they feel fit.
11
end program
(-)refactoring-test-code/if-construct-statement-conversion/test19-optionalElse/optionalElse.f90 (+11 lines)
Added Link Here
1
program convertIfStatementToIfConstructWithOptionalElseBlock
2
    implicit none
3
    integer :: var1, var2
4
    print *, "This is an if construct example."
5
    var1 = 4
6
    var2 = 5
7
    if (var1 < var2) print *, var1, " is less than ", var2, " using if-stmt." !<<<<< 7, 5, 7, 78, IfStmtToIfConstruct, TRUE, pass
8
    
9
    !!! This test shows the refactoring successfully converting a valid IF statement to a valid IF construct, and then based
10
    !!! on the user's affirmative selection of the option, will add on an else construct block to the end of it.
11
end program
(-)refactoring-test-code/if-construct-statement-conversion/test19-optionalElse/optionalElse.f90.result (+16 lines)
Added Link Here
1
program convertIfStatementToIfConstructWithOptionalElseBlock
2
    implicit none
3
    integer :: var1, var2
4
    print *, "This is an if construct example."
5
    var1 = 4
6
    var2 = 5
7
    if (var1 < var2) then
8
        print *, var1, " is less than ", var2, " using if-stmt." !<<<<< 7, 5, 7, 78, IfStmtToIfConstruct, TRUE, pass
9
        !can add more statements here
10
    else
11
        !can add more statements here
12
    end if
13
    
14
    !!! This test shows the refactoring successfully converting a valid IF statement to a valid IF construct, and then based
15
    !!! on the user's affirmative selection of the option, will add on an else construct block to the end of it.
16
end program
(-)refactoring-test-code/if-construct-statement-conversion/test20-optionalElseNotAdded/optionalElseNotAdded.f90 (+11 lines)
Added Link Here
1
program convertIfStatementToIfConstructWithOutOptionalElseBlock
2
    implicit none
3
    integer :: var1, var2
4
    print *, "This is an if construct example."
5
    var1 = 4
6
    var2 = 5
7
    if (var1 < var2) print *, var1, " is less than ", var2, " using if-stmt." !<<<<< 7, 5, 7, 78, IfStmtToIfConstruct, FALSE, pass
8
    
9
    !!! This test shows the refactoring successfully converting a valid IF statement to a valid IF construct, and then based
10
    !!! on the user's negative selection of the option, will now add on an else construct block to the end of it.
11
end program
(-)refactoring-test-code/if-construct-statement-conversion/test20-optionalElseNotAdded/optionalElseNotAdded.f90.result (+14 lines)
Added Link Here
1
program convertIfStatementToIfConstructWithOutOptionalElseBlock
2
    implicit none
3
    integer :: var1, var2
4
    print *, "This is an if construct example."
5
    var1 = 4
6
    var2 = 5
7
    if (var1 < var2) then
8
        print *, var1, " is less than ", var2, " using if-stmt." !<<<<< 7, 5, 7, 78, IfStmtToIfConstruct, FALSE, pass
9
        !can add more statements here
10
    end if
11
    
12
    !!! This test shows the refactoring successfully converting a valid IF statement to a valid IF construct, and then based
13
    !!! on the user's negative selection of the option, will now add on an else construct block to the end of it.
14
end program
(-)src/org/eclipse/photran/internal/tests/refactoring/IfConstructStatementConversionRefactoringTestSuite.java (+72 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 University of Illinois at Urbana-Champaign and others. 
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     UIUC - Initial API and implementation
10
 *     Zeeshan Ansari
11
 *     Mark Chen
12
 *     Burim Isai
13
 *     Waseem Sheihk
14
 *     Mumtaz Vauhkonen
15
 *******************************************************************************/
16
package org.eclipse.photran.internal.tests.refactoring;
17
18
import junit.framework.Test;
19
import junit.framework.TestFailure;
20
21
import org.eclipse.core.resources.IFile;
22
import org.eclipse.jface.text.TextSelection;
23
import org.eclipse.photran.internal.core.refactoring.ExtractLocalVariableRefactoring;
24
import org.eclipse.photran.internal.core.refactoring.IfConstructStatementConversionRefactoring;
25
import org.eclipse.photran.internal.tests.Activator;
26
import org.eclipse.photran.internal.tests.PhotranRefactoringTestSuiteFromMarkers;
27
28
/**
29
 * Unit tests for the IF Statement/Construct refactoring.
30
 * @author Zeeshan Ansari
31
 * @author Mark Chen
32
 * @author Burim Isai
33
 * @author Waseem Sheik
34
 * @author Mumtaz Vauhkonen
35
 */
36
public class IfConstructStatementConversionRefactoringTestSuite
37
     extends PhotranRefactoringTestSuiteFromMarkers<IfConstructStatementConversionRefactoring>
38
{
39
    private static final String DIR = "refactoring-test-code/if-construct-statement-conversion";
40
41
    public static Test suite() throws Exception
42
    {
43
        return new IfConstructStatementConversionRefactoringTestSuite();
44
    }
45
46
    public IfConstructStatementConversionRefactoringTestSuite() throws Exception
47
    {
48
        super(Activator.getDefault(),
49
              "Running If Construct Statement Conversion refactoring in",
50
              DIR,
51
              IfConstructStatementConversionRefactoring.class);
52
    }
53
54
    @Override
55
    protected boolean configureRefactoring(IfConstructStatementConversionRefactoring refactoring,
56
                                           IFile file,
57
                                           TextSelection selection,
58
                                           String[] markerText)
59
    {
60
        boolean shouldSucceed = super.configureRefactoring(refactoring, file, selection, markerText);
61
        String includeOptionalElse;
62
        String testType;
63
        testType = markerText[4];
64
        
65
        if(testType.equals("IfStmtToIfConstruct")){
66
            includeOptionalElse = markerText[5];
67
            if(includeOptionalElse.equals("TRUE"))
68
                refactoring.AddEmptyElseBlock();
69
        }
70
        return shouldSucceed;
71
    }
72
}
(-)plugin.xml (-1 / +18 lines)
Lines 102-107 Link Here
102
         />
102
         />
103
      </group>
103
      </group>
104
      <group><!-- Refactorings that reformat code -->
104
      <group><!-- Refactorings that reformat code -->
105
         <editorRefactoring  command="org.eclipse.photran.ui.IfConstructStatementConversionRefactoringCommand" />   
105
         <editorRefactoring
106
         <editorRefactoring
106
             class="org.eclipse.photran.internal.core.refactoring.RemoveUnreferencedLabelsRefactoring"
107
             class="org.eclipse.photran.internal.core.refactoring.RemoveUnreferencedLabelsRefactoring"
107
         />         
108
         />         
Lines 151-156 Link Here
151
            categoryId="org.eclipse.photran.ui.RefactoringCategory"
152
            categoryId="org.eclipse.photran.ui.RefactoringCategory"
152
            id="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand">
153
            id="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand">
153
      </command>
154
      </command>
155
      <command
156
            name="%command.name.IfConstructStatementConversion"
157
            categoryId="org.eclipse.photran.ui.RefactoringCategory"
158
            id="org.eclipse.photran.ui.IfConstructStatementConversionRefactoringCommand">
159
      </command>
154
   </extension>
160
   </extension>
155
161
156
   <!-- 2. Optionally associate the command with an accelerator key -->
162
   <!-- 2. Optionally associate the command with an accelerator key -->
Lines 174-179 Link Here
174
            contextId="org.eclipse.photran.ui.FortranEditorContext"
180
            contextId="org.eclipse.photran.ui.FortranEditorContext"
175
            commandId="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand"
181
            commandId="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand"
176
     />
182
     />
183
     <key
184
            sequence="M3+M2+I"
185
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
186
            contextId="org.eclipse.photran.ui.FortranEditorContext"
187
            commandId="org.eclipse.photran.ui.IfConstructStatementConversionRefactoringCommand"
188
     />
177
   </extension>
189
   </extension>
178
190
179
   <!-- 3. Add the command to Photran's Refactoring action set -->
191
   <!-- 3. Add the command to Photran's Refactoring action set -->
Lines 199-204 Link Here
199
               definitionId="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand"
211
               definitionId="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand"
200
               class="org.eclipse.photran.internal.ui.refactoring.ExtractLocalVariableAction"
212
               class="org.eclipse.photran.internal.ui.refactoring.ExtractLocalVariableAction"
201
               id="org.eclipse.photran.ui.ExtractLocalVariableRefactoringAction"/>
213
               id="org.eclipse.photran.ui.ExtractLocalVariableRefactoringAction"/>
214
         <action
215
               label="%action.label.IfConstructStatementConversion"
216
               definitionId="org.eclipse.photran.ui.IfConstructStatementConversionRefactoringCommand"
217
               class="org.eclipse.photran.internal.ui.refactoring.IfConstructStatementConversionAction"
218
               id="org.eclipse.photran.ui.IfConstructStatementConversionRefactoringAction"/>
202
      </actionSet>
219
      </actionSet>
203
   </extension>
220
   </extension>
204
221
Lines 353-359 Link Here
353
            id="org.eclipse.photran.ui.Reindenter">
370
            id="org.eclipse.photran.ui.Reindenter">
354
	     <action 
371
	     <action 
355
	           label="%action.label.reindent.0" 
372
	           label="%action.label.reindent.0" 
356
               menubarPath="org.eclipse.photran.ui.source.menu/indentationActions"
373
               menubarPath="edit/additions"
357
               definitionId="org.eclipse.photran.ui.ReindenterCommand"
374
               definitionId="org.eclipse.photran.ui.ReindenterCommand"
358
	           class="org.eclipse.photran.internal.ui.actions.ReindentAction"
375
	           class="org.eclipse.photran.internal.ui.actions.ReindentAction"
359
	           id="org.eclipse.photran.ui.ReindenterAction">
376
	           id="org.eclipse.photran.ui.ReindenterAction">
(-)src/org/eclipse/photran/internal/ui/refactoring/IfConstructStatementConversionAction.java (+132 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 University of Illinois at Urbana-Champaign and others. 
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     UIUC - Initial API and implementation
10
 *     Zeeshan Ansari
11
 *     Mark Chen
12
 *     Burim Isai
13
 *     Waseem Sheihk
14
 *     Mumtaz Vauhkonen
15
 *******************************************************************************/
16
package org.eclipse.photran.internal.ui.refactoring;
17
18
import java.util.List;
19
20
import org.eclipse.core.resources.IFile;
21
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
22
import org.eclipse.photran.core.IFortranAST;
23
import org.eclipse.photran.internal.core.lexer.Token;
24
import org.eclipse.photran.internal.core.refactoring.IfConstructStatementConversionRefactoring;
25
import org.eclipse.photran.internal.core.vpg.PhotranVPG;
26
import org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring;
27
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.events.SelectionEvent;
29
import org.eclipse.swt.events.SelectionListener;
30
import org.eclipse.swt.layout.GridLayout;
31
import org.eclipse.swt.widgets.Button;
32
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.swt.widgets.Label;
34
import org.eclipse.ui.IEditorActionDelegate;
35
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
36
37
/**
38
 * Handles the If Statement/Construct action in the Fortran editor's Refactoring popup menu
39
 * and in the Refactor menu in the workbench menu bar.
40
 *
41
 * @author Zeeshan Ansari
42
 * @author Burim Isai
43
 * @author Waseem Sheikh
44
 */
45
public class IfConstructStatementConversionAction
46
    extends AbstractFortranRefactoringActionDelegate
47
    implements IWorkbenchWindowActionDelegate, IEditorActionDelegate
48
{
49
    public IfConstructStatementConversionAction()
50
    {
51
        super(IfConstructStatementConversionRefactoring.class, FortranIfConstructStatementConversionWizard.class);
52
    }
53
54
    @Override
55
    protected VPGRefactoring<IFortranAST, Token, PhotranVPG> getRefactoring(List<IFile> files)
56
    {
57
        IfConstructStatementConversionRefactoring r = new IfConstructStatementConversionRefactoring();
58
        r.initialize(
59
            getFortranEditor().getIFile(),
60
            getFortranEditor().getSelection());
61
        return r;
62
    }
63
64
    public static class FortranIfConstructStatementConversionWizard extends AbstractFortranRefactoringWizard
65
    {
66
        protected IfConstructStatementConversionRefactoring ifConstructStatementConversionRefactoring;
67
68
        public FortranIfConstructStatementConversionWizard(IfConstructStatementConversionRefactoring r)
69
        {
70
            super(r);
71
            this.ifConstructStatementConversionRefactoring = r;
72
        }
73
74
        @Override protected void doAddUserInputPages()
75
        {
76
            if(ifConstructStatementConversionRefactoring.isStmtNode())
77
            {
78
                addPage(new UserInputWizardPage(ifConstructStatementConversionRefactoring.getName())
79
                {
80
                    protected Button shouldAddEmptyElseBlock;
81
82
                    public void createControl(Composite parent)
83
                    {
84
                        Composite top = new Composite(parent, SWT.NONE);
85
                        initializeDialogUnits(top);
86
                        setControl(top);
87
                        top.setLayout(new GridLayout(2, false));
88
                        Composite group = top;
89
                        new Label(group, SWT.NONE).setText(""); //$NON-NLS-1$
90
91
                        shouldAddEmptyElseBlock = new Button(group, SWT.CHECK);
92
                        shouldAddEmptyElseBlock.setText(Messages.IfConstructStatementConversionAction_AddEmptyElseBlock);
93
                        shouldAddEmptyElseBlock.setSelection(false);
94
                        shouldAddEmptyElseBlock.addSelectionListener(new SelectionListener()
95
                        {
96
                            public void widgetDefaultSelected(SelectionEvent e)
97
                            {
98
                                widgetSelected(e);
99
                            }
100
101
                            public void widgetSelected(SelectionEvent e)
102
                            {
103
                               if(shouldAddEmptyElseBlock.getSelection())
104
                                   ifConstructStatementConversionRefactoring.AddEmptyElseBlock();
105
                            }
106
107
                        });
108
                    }
109
                });
110
            }else
111
            {
112
                addPage(new UserInputWizardPage(ifConstructStatementConversionRefactoring.getName())
113
                {
114
                    public void createControl(Composite parent)
115
                    {
116
                        Composite top = new Composite(parent, SWT.NONE);
117
                        initializeDialogUnits(top);
118
                        setControl(top);
119
120
                        top.setLayout(new GridLayout(1, false));
121
122
                        Label lbl = new Label(top, SWT.NONE);
123
                        lbl.setText( Messages.bind( Messages.RefactoringAction_ClickOKToRunTheRefactoring,
124
                            ifConstructStatementConversionRefactoring.getName()));
125
                    }
126
           
127
                });
128
            }
129
130
        }
131
    }
132
}
(-)src/org/eclipse/photran/internal/ui/refactoring/Messages.java (+4 lines)
Lines 82-87 Link Here
82
    public static String MoveFromModuleInputPage_selectDataMessage;
82
    public static String MoveFromModuleInputPage_selectDataMessage;
83
83
84
    public static String RenameAction_MatchExternalSubprograms;
84
    public static String RenameAction_MatchExternalSubprograms;
85
    
86
    public static String IfConstructStatementConversionAction_AddEmptyElseBlock;
87
    
88
    public static String RefactoringAction_ClickOKToRunTheRefactoring;
85
89
86
    public static String RenameAction_RenameAtoB;
90
    public static String RenameAction_RenameAtoB;
87
    static
91
    static
(-)src/org/eclipse/photran/internal/ui/refactoring/messages.properties (+2 lines)
Lines 31-33 Link Here
31
MoveFromModuleInputPage_selectDataMessage=Please select member data to move from module 
31
MoveFromModuleInputPage_selectDataMessage=Please select member data to move from module 
32
RenameAction_MatchExternalSubprograms=Match external subprograms with interfaces and external declarations
32
RenameAction_MatchExternalSubprograms=Match external subprograms with interfaces and external declarations
33
RenameAction_RenameAtoB=Rename {0} to
33
RenameAction_RenameAtoB=Rename {0} to
34
IfConstructStatementConversionAction_AddEmptyElseBlock=Add an empty else block
35
RefactoringAction_ClickOKToRunTheRefactoring=Click OK to run the {0} refactoring.\nTo see what changes will be made, click Preview.

Return to bug 331880