diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java index c3d77948b91..ffacf2dc1b6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFileLocation.java @@ -24,18 +24,13 @@ import java.net.URI; */ public interface IIndexFileLocation { /** - * The URI of the indexed file. - * - * @return the URI of the indexed file (non-{@code null}) + * Returns the URI of the indexed file (non-{@code null}). */ public URI getURI(); /** - * Returns the workspace relative path of the indexed file or {@code null} if the file + * Returns the workspace relative path of the file in the index or {@code null} if the file * is not in the workspace. - * - * @return the workspace relative path of the file in the index, or null if the - * file is not in the workspace */ public String getFullPath(); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java index 9ce5fe8f045..b1470f0730a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java @@ -1,13 +1,13 @@ /******************************************************************************* * Copyright (c) 2005, 2008 Wind River Systems, Inc. - * 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: - * Markus Schorn - initial API and implementation - ******************************************************************************/ + * 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: + * Markus Schorn - initial API and implementation + ******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.rename; import java.io.StringWriter; @@ -63,15 +63,15 @@ public class RefactoringTests extends BaseTestFramework { assertTotalChanges(numChanges, 0, 0, changes); } - protected void assertTotalChanges(int numChanges, int potChanges, int commentCh, + protected void assertTotalChanges(int numChanges, int potChanges, int commentCh, Change changes) throws Exception { int count[]= { 0, 0, 0 }; if (changes != null) { countChanges(changes, count); } assertEquals(numChanges, count[0]); - assertEquals("potential changes: ", potChanges, count[1]); //$NON-NLS-1$ - assertEquals("comment changes: ", commentCh, count[2]); //$NON-NLS-1$ + assertEquals("potential changes: ", potChanges, count[1]); + assertEquals("comment changes: ", commentCh, count[2]); } private void countChanges(Change change, int[] count) { @@ -92,9 +92,9 @@ public class RefactoringTests extends BaseTestFramework { private void countChanges(TextEditChangeGroup edit, int[] count) { String name= edit.getName(); - if (name.indexOf("potential") != -1) { //$NON-NLS-1$ + if (name.indexOf("potential") != -1) { count[1]++; - } else if (name.indexOf("comment") != -1) { //$NON-NLS-1$ + } else if (name.indexOf("comment") != -1) { count[2]++; } else { count[0]++; @@ -110,9 +110,9 @@ public class RefactoringTests extends BaseTestFramework { if (changes != null && changes instanceof CompositeChange) { found = checkCompositeChange((CompositeChange) changes, file, startOffset, numChars, newText, potential); } - + if (!found) { - fail ("Rename at offset " + startOffset + " in \"" + file.getLocation() + "\" not found."); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + fail ("Rename at offset " + startOffset + " in \"" + file.getLocation() + "\" not found."); assertFalse(true); } } @@ -139,7 +139,7 @@ public class RefactoringTests extends BaseTestFramework { TextEditChangeGroup[] groups= change.getTextEditChangeGroups(); for (int i = 0; i < groups.length; i++) { TextEditGroup group = groups[i].getTextEditGroup(); - if ((group.getName().indexOf("potential") != -1) == potential) { //$NON-NLS-1$ + if ((group.getName().indexOf("potential") != -1) == potential) { TextEdit[] edits= group.getTextEdits(); if (checkTextEdits(edits, startOffset, numChars, newText)) { return true; @@ -151,7 +151,7 @@ public class RefactoringTests extends BaseTestFramework { private boolean checkTextEdit(TextEdit edit, int startOffset, int numChars, String newText) { if (edit instanceof MultiTextEdit) { - if (checkTextEdits(((MultiTextEdit) edit).getChildren(), + if (checkTextEdits(((MultiTextEdit) edit).getChildren(), startOffset, numChars, newText)) { return true; } @@ -176,94 +176,94 @@ public class RefactoringTests extends BaseTestFramework { private boolean checkReplaceEdit(ReplaceEdit edit, int startOffset, int numChars, String newText) { return (edit.getOffset() == startOffset && edit.getLength() == numChars && edit.getText().equals(newText ) ); } - + protected IFile createCppFwdDecls(String fileName) throws Exception { StringWriter writer = new StringWriter(); - writer.write("class class_fwd; \n"); //$NON-NLS-1$ - writer.write("struct struct_fwd; \n"); //$NON-NLS-1$ - writer.write("union union_fwd; \n"); //$NON-NLS-1$ - writer.write("int func_proto(); \n"); //$NON-NLS-1$ - writer.write("int func_proto_ov(); \n"); //$NON-NLS-1$ - writer.write("int func_proto_ov(int); \n"); //$NON-NLS-1$ - writer.write("int func_proto_ov(int*); \n"); //$NON-NLS-1$ - writer.write("extern int extern_var; \n"); //$NON-NLS-1$ + writer.write("class class_fwd; \n"); + writer.write("struct struct_fwd; \n"); + writer.write("union union_fwd; \n"); + writer.write("int func_proto(); \n"); + writer.write("int func_proto_ov(); \n"); + writer.write("int func_proto_ov(int); \n"); + writer.write("int func_proto_ov(int*); \n"); + writer.write("extern int extern_var; \n"); String contents = writer.toString(); - return importFile(fileName, contents ); + return importFile(fileName, contents ); } protected IFile createCFwdDecls(String fileName) throws Exception { StringWriter writer = new StringWriter(); - writer.write("struct struct_fwd; \n"); //$NON-NLS-1$ - writer.write("union union_fwd; \n"); //$NON-NLS-1$ - writer.write("int func_proto(); \n"); //$NON-NLS-1$ - writer.write("extern int extern_var; \n"); //$NON-NLS-1$ + writer.write("struct struct_fwd; \n"); + writer.write("union union_fwd; \n"); + writer.write("int func_proto(); \n"); + writer.write("extern int extern_var; \n"); String contents = writer.toString(); - return importFile(fileName, contents ); + return importFile(fileName, contents ); } protected IFile createCppDefs(String fileName) throws Exception { StringWriter writer = new StringWriter(); - writer.write("class class_def { \n"); //$NON-NLS-1$ - writer.write("public: \n"); //$NON-NLS-1$ - writer.write(" int member; \n"); //$NON-NLS-1$ - writer.write(" static int static_member; \n"); //$NON-NLS-1$ - writer.write(" void method(int par); \n"); //$NON-NLS-1$ - writer.write(" void static_method(int par); \n"); //$NON-NLS-1$ - writer.write(" int method_ov(); \n"); //$NON-NLS-1$ - writer.write(" int method_ov(int); \n"); //$NON-NLS-1$ - writer.write(" int method_ov(int*); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("struct struct_def { \n"); //$NON-NLS-1$ - writer.write(" int st_member; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("union union_def { \n"); //$NON-NLS-1$ - writer.write(" int un_member; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("typedef int typedef_def; \n"); //$NON-NLS-1$ - writer.write("namespace namespace_def{}; \n"); //$NON-NLS-1$ - writer.write("enum enum_def { \n"); //$NON-NLS-1$ - writer.write(" enum_item }; \n"); //$NON-NLS-1$ - writer.write("int func_def() {} \n"); //$NON-NLS-1$ - writer.write("int func_def_ov() {} \n"); //$NON-NLS-1$ - writer.write("int func_def_ov(int){} \n"); //$NON-NLS-1$ - writer.write("int func_def_ov(int*){} \n"); //$NON-NLS-1$ - writer.write("int var_def; \n"); //$NON-NLS-1$ + writer.write("class class_def { \n"); + writer.write("public: \n"); + writer.write(" int member; \n"); + writer.write(" static int static_member; \n"); + writer.write(" void method(int par); \n"); + writer.write(" void static_method(int par); \n"); + writer.write(" int method_ov(); \n"); + writer.write(" int method_ov(int); \n"); + writer.write(" int method_ov(int*); \n"); + writer.write("}; \n"); + writer.write("struct struct_def { \n"); + writer.write(" int st_member; \n"); + writer.write("}; \n"); + writer.write("union union_def { \n"); + writer.write(" int un_member; \n"); + writer.write("}; \n"); + writer.write("typedef int typedef_def; \n"); + writer.write("namespace namespace_def{}; \n"); + writer.write("enum enum_def { \n"); + writer.write(" enum_item }; \n"); + writer.write("int func_def() {} \n"); + writer.write("int func_def_ov() {} \n"); + writer.write("int func_def_ov(int){} \n"); + writer.write("int func_def_ov(int*){} \n"); + writer.write("int var_def; \n"); String contents = writer.toString(); - return importFile(fileName, contents ); + return importFile(fileName, contents ); } protected IFile createCDefs(String fileName) throws Exception { StringWriter writer = new StringWriter(); - writer.write("struct struct_def { \n"); //$NON-NLS-1$ - writer.write(" int st_member; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("union union_def { \n"); //$NON-NLS-1$ - writer.write(" int un_member; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("typedef int typedef_def; \n"); //$NON-NLS-1$ - writer.write("enum enum_def { \n"); //$NON-NLS-1$ - writer.write(" enum_item }; \n"); //$NON-NLS-1$ - writer.write("int func_def() {} \n"); //$NON-NLS-1$ - writer.write("int var_def; \n"); //$NON-NLS-1$ + writer.write("struct struct_def { \n"); + writer.write(" int st_member; \n"); + writer.write("}; \n"); + writer.write("union union_def { \n"); + writer.write(" int un_member; \n"); + writer.write("}; \n"); + writer.write("typedef int typedef_def; \n"); + writer.write("enum enum_def { \n"); + writer.write(" enum_item }; \n"); + writer.write("int func_def() {} \n"); + writer.write("int var_def; \n"); String contents = writer.toString(); - return importFile(fileName, contents ); + return importFile(fileName, contents ); } protected void assertRefactoringError(RefactoringStatus status, String msg) { RefactoringStatusEntry e= status.getEntryMatchingSeverity(RefactoringStatus.ERROR); - assertNotNull("Expected refactoring error!", e); //$NON-NLS-1$ + assertNotNull("Expected refactoring error!", e); assertEquals(msg, e.getMessage()); } protected void assertRefactoringWarning(RefactoringStatus status, String msg) { RefactoringStatusEntry e= status.getEntryMatchingSeverity(RefactoringStatus.WARNING); - assertNotNull("Expected refactoring warning!", e); //$NON-NLS-1$ + assertNotNull("Expected refactoring warning!", e); assertEquals(msg, e.getMessage()); } protected void assertRefactoringOk(RefactoringStatus status) { - assertTrue("Expected refactoring status ok: " + //$NON-NLS-1$ - status.getMessageMatchingSeverity(status.getSeverity()), - status.getSeverity()==RefactoringStatus.OK); + assertTrue("Expected refactoring status ok: " + + status.getMessageMatchingSeverity(status.getSeverity()), + status.getSeverity() == RefactoringStatus.OK); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java index 2d6f292c06c..e7a9ce3e1af 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.rename; @@ -25,814 +25,814 @@ public class RenameFunctionTests extends RenameTestBase { super(name); } - public static Test suite(){ + public static Test suite() { return suite(true); } - public static Test suite( boolean cleanup ) { - TestSuite suite = new TestSuite(RenameFunctionTests.class); + public static Test suite(boolean cleanup) { + TestSuite suite = new TestSuite(RenameFunctionTests.class); if (cleanup) { - suite.addTest( new RefactoringTests("cleanupProject") ); //$NON-NLS-1$ + suite.addTest(new RefactoringTests("cleanupProject")); } return suite; } - + public void testFunctionNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("int v1(); int v2(); int v3(); \n"); //$NON-NLS-1$ - writer.write("static int s1(); \n"); //$NON-NLS-1$ - writer.write("static int s2(); \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; v1(); \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2(); \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3; v3(); \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("int v1(); int v2(); int v3(); \n"); + writer.write("static int s1(); \n"); + writer.write("static int s2(); \n"); + writer.write("void f(int par1){ \n"); + writer.write(" { \n"); + writer.write(" int w1; v1(); \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; v2(); \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" { \n"); + writer.write(" int w3; v3(); \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - + IFile cpp= importFile("test.cpp", contents); + writer = new StringWriter(); - writer.write( "static int static_other_file(); \n" ); //$NON-NLS-1$ - importFile( "other.cpp", writer.toString() ); //$NON-NLS-1$ + writer.write("static int static_other_file(); \n"); + importFile("other.cpp", writer.toString()); - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w2 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset2, "par2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par2 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "w3"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w3 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset3, "par3"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par3 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset3, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset3, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset3, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); // renamings depending on scope - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + "Conflicting element type: Method"); + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "Conflicting element type: Method"); // lookup inside a static method also returns non-static members // we may want to have a check whether a binding is accessible or not. - -// status= checkConditions(cpp, offset3, "member"); //$NON-NLS-1$ + +// status= checkConditions(cpp, offset3, "member"); // assertRefactoringOk(status); -// status= checkConditions(cpp, offset3, "method"); //$NON-NLS-1$ +// status= checkConditions(cpp, offset3, "method"); // assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "Conflicting element type: Method"); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); // would be good to see an error here - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); // would be good to see an error here - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_proto_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_def_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); // renamings that are ok. - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset3, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "un_member"); assertRefactoringOk(status); - + // file static stuff - status= checkConditions(cpp, contents.indexOf("s1"), "s2"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("s1"), "s2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: s2 \n" + - "Conflicting element type: File static function"); //$NON-NLS-1$ + "Conflicting element type: File static function"); - status= checkConditions(cpp, contents.indexOf("s1"), "static_other_file"); //$NON-NLS-1$ //$NON-NLS-2$ - assertRefactoringOk(status); + status= checkConditions(cpp, contents.indexOf("s1"), "static_other_file"); + assertRefactoringOk(status); } - + public void testFunctionsPlainC() throws Exception { - createCFwdDecls("c_fwd.h"); //$NON-NLS-1$ - createCDefs("c_def.h"); //$NON-NLS-1$ + createCFwdDecls("c_fwd.h"); + createCDefs("c_def.h"); StringWriter writer = new StringWriter(); - writer.write("#include \"c_fwd.h\" \n"); //$NON-NLS-1$ - writer.write("#include \"c_def.h\" \n"); //$NON-NLS-1$ - writer.write("int v1(); int v2(); int v3(); \n"); //$NON-NLS-1$ - writer.write("int func_proto(); \n"); //$NON-NLS-1$ - writer.write("static int s2(); \n"); //$NON-NLS-1$ - writer.write("void func_def(){ \n"); //$NON-NLS-1$ - writer.write(" int w1; v1(); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"c_fwd.h\" \n"); + writer.write("#include \"c_def.h\" \n"); + writer.write("int v1(); int v2(); int v3(); \n"); + writer.write("int func_proto(); \n"); + writer.write("static int s2(); \n"); + writer.write("void func_def(){ \n"); + writer.write(" int w1; v1(); \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.c", contents ); //$NON-NLS-1$ - - int offset1= contents.indexOf("func_proto"); //$NON-NLS-1$ - Change change= getRefactorChanges(cpp, offset1, "xxx"); //$NON-NLS-1$ + IFile cpp= importFile("test.c", contents); + + int offset1= contents.indexOf("func_proto"); + Change change= getRefactorChanges(cpp, offset1, "xxx"); assertTotalChanges(2, change); - offset1= contents.indexOf("func_def"); //$NON-NLS-1$ - change= getRefactorChanges(cpp, offset1, "xxx"); //$NON-NLS-1$ + offset1= contents.indexOf("func_def"); + change= getRefactorChanges(cpp, offset1, "xxx"); assertTotalChanges(2, change); } - + public void testFunctionNameConflictsPlainC() throws Exception { - createCFwdDecls("c_fwd.h"); //$NON-NLS-1$ - createCDefs("c_def.h"); //$NON-NLS-1$ + createCFwdDecls("c_fwd.h"); + createCDefs("c_def.h"); StringWriter writer = new StringWriter(); - writer.write("#include \"c_fwd.h\" \n"); //$NON-NLS-1$ - writer.write("#include \"c_def.h\" \n"); //$NON-NLS-1$ - writer.write("int v1(); int v2(); int v3(); \n"); //$NON-NLS-1$ - writer.write("static int s1(); \n"); //$NON-NLS-1$ - writer.write("static int s2(); \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" int w1; v1(); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"c_fwd.h\" \n"); + writer.write("#include \"c_def.h\" \n"); + writer.write("int v1(); int v2(); int v3(); \n"); + writer.write("static int s1(); \n"); + writer.write("static int s2(); \n"); + writer.write("void f(int par1){ \n"); + writer.write(" int w1; v1(); \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.c", contents ); //$NON-NLS-1$ - + IFile cpp= importFile("test.c", contents); + writer = new StringWriter(); - writer.write( "static int static_other_file(); \n" ); //$NON-NLS-1$ - importFile( "other.c", writer.toString() ); //$NON-NLS-1$ + writer.write("static int static_other_file(); \n"); + importFile("other.c", writer.toString()); - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - + int offset1= contents.indexOf("v1"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); // renamings that are ok. - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - + // file static stuff - status= checkConditions(cpp, contents.indexOf("s1"), "s2"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("s1"), "s2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: s2 \n" + - "Conflicting element type: File static function"); //$NON-NLS-1$ + "Conflicting element type: File static function"); - status= checkConditions(cpp, contents.indexOf("s1"), "static_other_file"); //$NON-NLS-1$ //$NON-NLS-2$ - assertRefactoringOk(status); + status= checkConditions(cpp, contents.indexOf("s1"), "static_other_file"); + assertRefactoringOk(status); } public void testMethodNameConflicts1() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("class Dummy { \n"); //$NON-NLS-1$ - writer.write(" int v1(); int v2(); \n"); //$NON-NLS-1$ - writer.write(" int member; \n"); //$NON-NLS-1$ - writer.write(" int method(int); \n"); //$NON-NLS-1$ - writer.write(" int method_samesig(); \n"); //$NON-NLS-1$ - writer.write(" static int static_method(int); \n"); //$NON-NLS-1$ - writer.write(" static int static_member; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("int Dummy::method(int par1) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; v1(); \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static int Dummy::static_method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2(); \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("class Dummy { \n"); + writer.write(" int v1(); int v2(); \n"); + writer.write(" int member; \n"); + writer.write(" int method(int); \n"); + writer.write(" int method_samesig(); \n"); + writer.write(" static int static_method(int); \n"); + writer.write(" static int static_member; \n"); + writer.write("}; \n"); + writer.write("int Dummy::method(int par1) { \n"); + writer.write(" { \n"); + writer.write(" int w1; v1(); \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static int Dummy::static_method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; v2(); \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("w1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("w1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Method"); + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Method"); + status= checkConditions(cpp, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w2 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset2, "par2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par2 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "method"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Overloading \n" + "New element: method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "method_samesig"); //$NON-NLS-1$ + "Conflicting element type: Method"); + status= checkConditions(cpp, offset2, "method_samesig"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: method_samesig \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + "Conflicting element type: Method"); + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Overloading \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "Conflicting element type: Method"); } public void testMethodNameConflicts2() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("class Dummy { \n"); //$NON-NLS-1$ - writer.write(" int v1(), v2(), v3(); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("Dummy d; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; d.v1(); \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; d.v2(); \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3; d.v3(); \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("class Dummy { \n"); + writer.write(" int v1(), v2(), v3(); \n"); + writer.write("}; \n"); + writer.write("Dummy d; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" { \n"); + writer.write(" int w1; d.v1(); \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; d.v2(); \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" { \n"); + writer.write(" int w3; d.v3(); \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "par1"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "extern_var"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "var_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ - assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "w2"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "par2"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "extern_var"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "var_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "enum_item"); + assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ - assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "w3"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "par3"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "extern_var"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "var_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "enum_item"); + assertRefactoringOk(status); // renamings depending on scope - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ - assertRefactoringOk(status); - - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto_ov"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "func_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "func_def_ov"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "class_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "struct_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "union_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "class_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "struct_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "union_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "enum_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "typedef_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "namespace_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "st_member"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "st_member"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "un_member"); + assertRefactoringOk(status); + + status= checkConditions(cpp, offset3, "class_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "struct_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "union_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "class_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "struct_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "union_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "enum_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "typedef_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "namespace_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "st_member"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "un_member"); assertRefactoringOk(status); } - + public void testBug72605() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo { \n"); //$NON-NLS-1$ - writer.write(" void m1(int x=0); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void Foo::m1(int x) {} \n"); //$NON-NLS-1$ + writer.write("class Foo { \n"); + writer.write(" void m1(int x=0); \n"); + writer.write("}; \n"); + writer.write("void Foo::m1(int x) {} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - - int offset = contents.indexOf("m1") ; //$NON-NLS-1$ - int offset2= contents.indexOf("m1", offset+1) ; //$NON-NLS-1$ - Change changes = getRefactorChanges(cpp, offset, "z"); //$NON-NLS-1$ - assertTotalChanges( 2, changes ); - changes = getRefactorChanges(cpp, offset2, "z"); //$NON-NLS-1$ - assertTotalChanges( 2, changes ); + IFile cpp= importFile("test.cpp", contents); + + int offset = contents.indexOf("m1"); + int offset2= contents.indexOf("m1", offset + 1); + Change changes = getRefactorChanges(cpp, offset, "z"); + assertTotalChanges(2, changes); + changes = getRefactorChanges(cpp, offset2, "z"); + assertTotalChanges(2, changes); } - + public void testBug72732() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo { \n"); //$NON-NLS-1$ - writer.write(" virtual void mthd() = 0;\n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("class Moo: public Foo{ \n"); //$NON-NLS-1$ - writer.write(" void mthd() = 0; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Foo { \n"); + writer.write(" virtual void mthd() = 0;\n"); + writer.write("}; \n"); + writer.write("class Moo: public Foo{ \n"); + writer.write(" void mthd() = 0; \n"); + writer.write("}; \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - int offset = contents.indexOf("mthd") ; //$NON-NLS-1$ - offset= contents.indexOf("mthd", offset+1) ; //$NON-NLS-1$ - Change changes = getRefactorChanges(cpp, offset, "z"); //$NON-NLS-1$ - assertTotalChanges( 2, changes ); + IFile cpp= importFile("test.cpp", contents); + int offset = contents.indexOf("mthd"); + offset= contents.indexOf("mthd", offset + 1); + Change changes = getRefactorChanges(cpp, offset, "z"); + assertTotalChanges(2, changes); } - + public void testBug330123() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write(" void bar(const int param);\n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Foo{ \n"); + writer.write(" void bar(const int param);\n"); + writer.write("}; \n"); String header = writer.toString(); - IFile h = importFile("Foo.h", header); //$NON-NLS-1$ + IFile h = importFile("Foo.h", header); writer = new StringWriter(); - writer.write("#include \"Foo.h\" \n"); //$NON-NLS-1$ - writer.write("void Foo::bar(const int param) {\n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"Foo.h\" \n"); + writer.write("void Foo::bar(const int param) {\n"); + writer.write("} \n"); String source = writer.toString(); - IFile cpp = importFile("Foo.cpp", source); //$NON-NLS-1$ - int offset = header.indexOf("bar") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(h, offset, "ooga"); //$NON-NLS-1$ - + IFile cpp = importFile("Foo.cpp", source); + int offset = header.indexOf("bar"); + Change changes = getRefactorChanges(h, offset, "ooga"); + assertTotalChanges(2, changes); - assertChange(changes, h, header.indexOf("bar"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("bar"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("bar"), 3, "ooga"); + assertChange(changes, cpp, source.indexOf("bar"), 3, "ooga"); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java index b0f8c541e44..e1d25efa78c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - * Sergey Prigogin (Google) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.rename; @@ -29,211 +29,211 @@ public class RenameMacroTests extends RenameTestBase { } public static Test suite(boolean cleanup) { - TestSuite suite = new TestSuite(RenameMacroTests.class); + TestSuite suite = new TestSuite(RenameMacroTests.class); if (cleanup) { - suite.addTest(new RefactoringTests("cleanupProject")); //$NON-NLS-1$ + suite.addTest(new RefactoringTests("cleanupProject")); } return suite; } public void testMacroRename() throws Exception { StringBuilder buf = new StringBuilder(); - buf.append("#define HALLO x \n"); //$NON-NLS-1$ - buf.append("class v1 { \n"); //$NON-NLS-1$ - buf.append(" int HALLO; \n"); //$NON-NLS-1$ - buf.append("}; \n"); //$NON-NLS-1$ - buf.append("class HALLO { \n"); //$NON-NLS-1$ - buf.append(" int v; \n"); //$NON-NLS-1$ - buf.append("}; \n"); //$NON-NLS-1$ - buf.append("class v3 { \n"); //$NON-NLS-1$ - buf.append(" int v; \n"); //$NON-NLS-1$ - buf.append("}; \n"); //$NON-NLS-1$ - buf.append("class v4 { \n"); //$NON-NLS-1$ - buf.append(" int HALLO(); \n"); //$NON-NLS-1$ - buf.append("}; \n"); //$NON-NLS-1$ - buf.append("int v4::HALLO(){} \n"); //$NON-NLS-1$ - buf.append("void f(int par1){ \n"); //$NON-NLS-1$ - buf.append(" { \n"); //$NON-NLS-1$ - buf.append(" int HALLO; v1::v++; \n"); //$NON-NLS-1$ - buf.append(" } \n"); //$NON-NLS-1$ - buf.append("} \n"); //$NON-NLS-1$ + buf.append("#define HALLO x \n"); + buf.append("class v1 { \n"); + buf.append(" int HALLO; \n"); + buf.append("}; \n"); + buf.append("class HALLO { \n"); + buf.append(" int v; \n"); + buf.append("}; \n"); + buf.append("class v3 { \n"); + buf.append(" int v; \n"); + buf.append("}; \n"); + buf.append("class v4 { \n"); + buf.append(" int HALLO(); \n"); + buf.append("}; \n"); + buf.append("int v4::HALLO(){} \n"); + buf.append("void f(int par1){ \n"); + buf.append(" { \n"); + buf.append(" int HALLO; v1::v++; \n"); + buf.append(" } \n"); + buf.append("} \n"); String contents = buf.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("HALLO"); //$NON-NLS-1$ - int offset2= contents.indexOf("HALLO", offset1 + 1); //$NON-NLS-1$ - - Change ch= getRefactorChanges(cpp, offset1, "WELT"); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("HALLO"); + int offset2= contents.indexOf("HALLO", offset1 + 1); + + Change ch= getRefactorChanges(cpp, offset1, "WELT"); assertTotalChanges(6, ch); int off= offset1; - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); - ch= getRefactorChanges(cpp, offset2, "WELT"); //$NON-NLS-1$ + ch= getRefactorChanges(cpp, offset2, "WELT"); assertTotalChanges(6, ch); off= offset1; - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ - assertChange(ch, cpp, off, 5, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("HALLO", off + 1); //$NON-NLS-1$ + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); + assertChange(ch, cpp, off, 5, "WELT"); + off= contents.indexOf("HALLO", off + 1); } - + public void testMacroNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringBuilder buf = new StringBuilder(); - buf.append("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - buf.append("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - buf.append("#define MACRO 1 \n"); //$NON-NLS-1$ - buf.append("int v1(); int v2(); int v3(); \n"); //$NON-NLS-1$ - buf.append("static int s1(); \n"); //$NON-NLS-1$ - buf.append("static int s2(); \n"); //$NON-NLS-1$ - buf.append("void f(int par1){ \n"); //$NON-NLS-1$ - buf.append(" int w1; v1(); \n"); //$NON-NLS-1$ - buf.append(" extern_var; \n"); //$NON-NLS-1$ - buf.append(" var_def; \n"); //$NON-NLS-1$ - buf.append(" enum_item; \n"); //$NON-NLS-1$ - buf.append("} \n"); //$NON-NLS-1$ + buf.append("#include \"cpp_fwd.hh\" \n"); + buf.append("#include \"cpp_def.hh\" \n"); + buf.append("#define MACRO 1 \n"); + buf.append("int v1(); int v2(); int v3(); \n"); + buf.append("static int s1(); \n"); + buf.append("static int s2(); \n"); + buf.append("void f(int par1){ \n"); + buf.append(" int w1; v1(); \n"); + buf.append(" extern_var; \n"); + buf.append(" var_def; \n"); + buf.append(" enum_item; \n"); + buf.append("} \n"); String contents = buf.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ - + IFile cpp= importFile("test.cpp", contents); + buf = new StringBuilder(); - buf.append("static int static_other_file(); \n"); //$NON-NLS-1$ - importFile("other.cpp", buf.toString()); //$NON-NLS-1$ + buf.append("static int static_other_file(); \n"); + importFile("other.cpp", buf.toString()); waitForIndexer(); - int offset1= contents.indexOf("MACRO"); //$NON-NLS-1$ - + int offset1= contents.indexOf("MACRO"); + // conflicts after renaming - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Name conflict \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("par1"), "MACRO"); //$NON-NLS-1$ //$NON-NLS-2$ - assertRefactoringError(status, "'MACRO' conflicts with the name of an existing macro."); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("par1"), "MACRO"); + assertRefactoringError(status, "'MACRO' conflicts with the name of an existing macro."); + status= checkConditions(cpp, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Name conflict \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Name conflict \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Name conflict \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Name conflict \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); } public void testClassMacroClash() throws Exception { StringBuilder buf = new StringBuilder(); - buf.append("class CC {int a;}; \n"); //$NON-NLS-1$ + buf.append("class CC {int a;}; \n"); String contents = buf.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); buf = new StringBuilder(); - buf.append("#define CC mm \n"); //$NON-NLS-1$ - buf.append("int CC; \n"); //$NON-NLS-1$ + buf.append("#define CC mm \n"); + buf.append("int CC; \n"); String contents2 = buf.toString(); - IFile cpp2= importFile("test2.cpp", contents2); //$NON-NLS-1$ + IFile cpp2= importFile("test2.cpp", contents2); - int offset1= contents.indexOf("CC"); //$NON-NLS-1$ - Change ch= getRefactorChanges(cpp, offset1, "CCC"); //$NON-NLS-1$ + int offset1= contents.indexOf("CC"); + Change ch= getRefactorChanges(cpp, offset1, "CCC"); assertTotalChanges(1, ch); - int offset2= contents2.indexOf("CC"); //$NON-NLS-1$ - ch= getRefactorChanges(cpp2, offset2, "CCC"); //$NON-NLS-1$ + int offset2= contents2.indexOf("CC"); + ch= getRefactorChanges(cpp2, offset2, "CCC"); assertTotalChanges(2, ch); } - + public void testMacroRename_434917() throws Exception { StringBuilder buf = new StringBuilder(); - buf.append("#define CC mm\n"); //$NON-NLS-1$ + buf.append("#define CC mm\n"); String contents = buf.toString(); - IFile header= importFile("test.h", contents); //$NON-NLS-1$ + IFile header= importFile("test.h", contents); buf = new StringBuilder(); buf.append("#include \"test.h\"\n"); - buf.append("int CC;\n"); //$NON-NLS-1$ + buf.append("int CC;\n"); String contents2 = buf.toString(); - IFile source= importFile("test.cpp", contents2); //$NON-NLS-1$ + IFile source= importFile("test.cpp", contents2); - int offset= contents.indexOf("CC"); //$NON-NLS-1$ - Change ch= getRefactorChanges(header, offset, "CCC"); //$NON-NLS-1$ + int offset= contents.indexOf("CC"); + Change ch= getRefactorChanges(header, offset, "CCC"); assertTotalChanges(2, ch); } public void testIncludeGuard() throws Exception { StringBuilder buf = new StringBuilder(); - buf.append("#ifndef _guard \n"); //$NON-NLS-1$ - buf.append("#define _guard \n"); //$NON-NLS-1$ - buf.append(" int HALLO \n"); //$NON-NLS-1$ - buf.append("#endif /* _guard */ \n"); //$NON-NLS-1$ + buf.append("#ifndef _guard \n"); + buf.append("#define _guard \n"); + buf.append(" int HALLO \n"); + buf.append("#endif /* _guard */ \n"); String contents = buf.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("_guard"); //$NON-NLS-1$ - int offset2= contents.indexOf("_guard", offset1 + 1); //$NON-NLS-1$ - Change ch= getRefactorChanges(cpp, offset2, "WELT"); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("_guard"); + int offset2= contents.indexOf("_guard", offset1 + 1); + Change ch= getRefactorChanges(cpp, offset2, "WELT"); assertTotalChanges(2, 0, 1, ch); int off= offset1; - assertChange(ch, cpp, off, 6, "WELT"); //$NON-NLS-1$ - off= contents.indexOf("_guard", off + 1); //$NON-NLS-1$ - assertChange(ch, cpp, off, 6, "WELT"); //$NON-NLS-1$ + assertChange(ch, cpp, off, 6, "WELT"); + off= contents.indexOf("_guard", off + 1); + assertChange(ch, cpp, off, 6, "WELT"); } - + public void testMacroParameters() throws Exception { StringBuilder buf = new StringBuilder(); - buf.append("int var; \n"); //$NON-NLS-1$ - buf.append("#define M1(var) var \n"); //$NON-NLS-1$ - buf.append("#define M2(var, x) (var+x)*var \n"); //$NON-NLS-1$ - buf.append("#define M3 var \n"); //$NON-NLS-1$ + buf.append("int var; \n"); + buf.append("#define M1(var) var \n"); + buf.append("#define M2(var, x) (var+x)*var \n"); + buf.append("#define M3 var \n"); String contents = buf.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("var"); //$NON-NLS-1$ - Change ch= getRefactorChanges(cpp, offset1, "xxx"); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("var"); + Change ch= getRefactorChanges(cpp, offset1, "xxx"); assertTotalChanges(1, 1, 0, ch); } public void testRenameMacroAsMacroArgument() throws Exception { StringBuilder buf = new StringBuilder(); - buf.append("#define M1(var) var \n"); //$NON-NLS-1$ - buf.append("#define M2 1 \n"); //$NON-NLS-1$ - buf.append("int b= M2; \n"); //$NON-NLS-1$ - buf.append("int a= M1(M2); \n"); //$NON-NLS-1$ + buf.append("#define M1(var) var \n"); + buf.append("#define M2 1 \n"); + buf.append("int b= M2; \n"); + buf.append("int a= M1(M2); \n"); String contents = buf.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("M2"); //$NON-NLS-1$ - Change ch= getRefactorChanges(cpp, offset1, "xxx"); //$NON-NLS-1$ - assertTotalChanges(countOccurrences(contents, "M2"), ch); //$NON-NLS-1$ - } + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("M2"); + Change ch= getRefactorChanges(cpp, offset1, "xxx"); + assertTotalChanges(countOccurrences(contents, "M2"), ch); + } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java index 255902bd783..b708541df7e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java @@ -40,213 +40,213 @@ public class RenameRegressionTests extends RenameTestBase { public static Test suite(boolean cleanup) { TestSuite innerSuite= new TestSuite(RenameRegressionTests.class); - innerSuite.addTest(new FailingTest(new RenameRegressionTests("_testMethod_35_72726"),72726)); //$NON-NLS-1$ - - TestSuite suite = new TestSuite("RenameRegressionTests"); //$NON-NLS-1$ + innerSuite.addTest(new FailingTest(new RenameRegressionTests("_testMethod_35_72726"), 72726)); + + TestSuite suite = new TestSuite("RenameRegressionTests"); suite.addTest(innerSuite); suite.addTest(RenameVariableTests.suite(false)); suite.addTest(RenameFunctionTests.suite(false)); suite.addTest(RenameTypeTests.suite(false)); suite.addTest(RenameMacroTests.suite(false)); suite.addTest(RenameTemplatesTests.suite(false)); - + if (cleanup) - suite.addTest(new RenameRegressionTests("cleanupProject")); //$NON-NLS-1$ - + suite.addTest(new RenameRegressionTests("cleanupProject")); + return suite; } - + public void testSimpleRename() throws Exception { StringWriter writer = new StringWriter(); - writer.write("int boo; // boo \n"); //$NON-NLS-1$ - writer.write("#if 0 \n"); //$NON-NLS-1$ - writer.write("boo \n"); //$NON-NLS-1$ - writer.write("#endif \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" boo++; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("int boo; // boo \n"); + writer.write("#if 0 \n"); + writer.write("boo \n"); + writer.write("#endif \n"); + writer.write("void f() { \n"); + writer.write(" boo++; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - Change changes = getRefactorChanges(file, contents.indexOf("boo"), "ooga"); //$NON-NLS-1$ //$NON-NLS-2$ - + IFile file = importFile("t.cpp", contents); + Change changes = getRefactorChanges(file, contents.indexOf("boo"), "ooga"); + assertTotalChanges(2, 1, 1, changes); - assertChange(changes, file, contents.indexOf("boo"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("boo++"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("boo"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("boo++"), 3, "ooga"); } public void testLocalVar() throws Exception { StringWriter writer = new StringWriter(); - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" int boo; \n"); //$NON-NLS-1$ - writer.write(" boo++; \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int boo; \n"); //$NON-NLS-1$ - writer.write(" boo++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write(" boo++; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("void f() { \n"); + writer.write(" int boo; \n"); + writer.write(" boo++; \n"); + writer.write(" { \n"); + writer.write(" int boo; \n"); + writer.write(" boo++; \n"); + writer.write(" } \n"); + writer.write(" boo++; \n"); + writer.write("} \n"); + String contents = writer.toString(); - int offset= contents.indexOf("boo"); //$NON-NLS-1$ - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ - + int offset= contents.indexOf("boo"); + IFile file = importFile("t.cpp", contents); + Change changes = getRefactorChanges(file, offset, "ooga"); + assertTotalChanges(3, changes); - assertChange(changes, file, offset, 3, "ooga"); //$NON-NLS-1$ - offset= contents.indexOf("boo", offset+1); //$NON-NLS-1$ - assertChange(changes, file, offset, 3, "ooga"); //$NON-NLS-1$ - offset= contents.lastIndexOf("boo"); //$NON-NLS-1$ - assertChange(changes, file, offset, 3, "ooga"); //$NON-NLS-1$ + assertChange(changes, file, offset, 3, "ooga"); + offset= contents.indexOf("boo", offset+1); + assertChange(changes, file, offset, 3, "ooga"); + offset= contents.lastIndexOf("boo"); + assertChange(changes, file, offset, 3, "ooga"); } public void testParameter() throws Exception { StringWriter writer = new StringWriter(); - writer.write("void f(int boo) { \n"); //$NON-NLS-1$ - writer.write(" boo++; \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int boo; \n"); //$NON-NLS-1$ - writer.write(" boo++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write(" boo++; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("void f(int boo) { \n"); + writer.write(" boo++; \n"); + writer.write(" { \n"); + writer.write(" int boo; \n"); + writer.write(" boo++; \n"); + writer.write(" } \n"); + writer.write(" boo++; \n"); + writer.write("} \n"); + String contents = writer.toString(); - int offset= contents.indexOf("boo"); //$NON-NLS-1$ - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ - + int offset= contents.indexOf("boo"); + IFile file = importFile("t.cpp", contents); + Change changes = getRefactorChanges(file, offset, "ooga"); + assertTotalChanges(3, changes); - assertChange(changes, file, offset, 3, "ooga"); //$NON-NLS-1$ - offset= contents.indexOf("boo", offset+1); //$NON-NLS-1$ - assertChange(changes, file, offset, 3, "ooga"); //$NON-NLS-1$ - offset= contents.lastIndexOf("boo"); //$NON-NLS-1$ - assertChange(changes, file, offset, 3, "ooga"); //$NON-NLS-1$ + assertChange(changes, file, offset, 3, "ooga"); + offset= contents.indexOf("boo", offset+1); + assertChange(changes, file, offset, 3, "ooga"); + offset= contents.lastIndexOf("boo"); + assertChange(changes, file, offset, 3, "ooga"); } public void testFileStaticVar() throws Exception { StringWriter writer = new StringWriter(); - writer.write("static int boo; \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" boo++; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void g(int boo) { \n"); //$NON-NLS-1$ - writer.write(" boo++; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("static int boo; \n"); + writer.write("void f() { \n"); + writer.write(" boo++; \n"); + writer.write("} \n"); + writer.write("void g(int boo) { \n"); + writer.write(" boo++; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - importFile("t2.cpp", contents); //$NON-NLS-1$ - - int offset= contents.indexOf("boo"); //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ - + IFile file = importFile("t.cpp", contents); + importFile("t2.cpp", contents); + + int offset= contents.indexOf("boo"); + Change changes = getRefactorChanges(file, offset, "ooga"); + assertTotalChanges(2, changes); - assertChange(changes, file, offset, 3, "ooga"); //$NON-NLS-1$ - offset= contents.indexOf("boo", offset+1); //$NON-NLS-1$ - assertChange(changes, file, offset, 3, "ooga"); //$NON-NLS-1$ + assertChange(changes, file, offset, 3, "ooga"); + offset= contents.indexOf("boo", offset+1); + assertChange(changes, file, offset, 3, "ooga"); } public void testClass_1() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Boo/*vp1*/{}; \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" Boo a; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("class Boo/*vp1*/{}; \n"); + writer.write("void f() { \n"); + writer.write(" Boo a; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset= contents.indexOf("Boo/*vp1*/"); //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga"); //$NON-NLS-1$ - + IFile file = importFile("t.cpp", contents); + int offset= contents.indexOf("Boo/*vp1*/"); + Change changes = getRefactorChanges(file, offset, "Ooga"); + assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("Boo/*vp1*/"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Boo a"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("Boo/*vp1*/"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Boo a"), 3, "Ooga"); } public void testAttribute_2() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Boo{ \n"); //$NON-NLS-1$ - writer.write(" int att1;//vp1,res1 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" Boo a; \n"); //$NON-NLS-1$ - writer.write(" a.att1;//res2 \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("class Boo{ \n"); + writer.write(" int att1;//vp1,res1 \n"); + writer.write("}; \n"); + writer.write("void f() { \n"); + writer.write(" Boo a; \n"); + writer.write(" a.att1;//res2 \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("att1;//vp1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ - + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("att1;//vp1") ; + Change changes = getRefactorChanges(file, offset, "ooga"); + assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("att1;//vp1,res1"), 4, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("att1;//res2"), 4, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("att1;//vp1,res1"), 4, "ooga"); + assertChange(changes, file, contents.indexOf("att1;//res2"), 4, "ooga"); } public void testMethod_1() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write("public: \n"); //$NON-NLS-1$ - writer.write(" const void* method1(const char*); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("const void* Foo::method1(const char* x) { \n"); //$NON-NLS-1$ - writer.write(" return (void*) x; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void test() { \n"); //$NON-NLS-1$ - writer.write(" Foo d; \n"); //$NON-NLS-1$ - writer.write(" d.method1(\"hello\"); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("class Foo{ \n"); + writer.write("public: \n"); + writer.write(" const void* method1(const char*); \n"); + writer.write("}; \n"); + writer.write("const void* Foo::method1(const char* x) { \n"); + writer.write(" return (void*) x; \n"); + writer.write("} \n"); + writer.write("void test() { \n"); + writer.write(" Foo d; \n"); + writer.write(" d.method1(\"hello\"); \n"); + writer.write("} \n"); String source = writer.toString(); - IFile cpp = importFile("t.cpp", source); //$NON-NLS-1$ + IFile cpp = importFile("t.cpp", source); //vp1 const - int offset = source.indexOf("method1"); //$NON-NLS-1$ - Change changes = getRefactorChanges(cpp, offset, "m1"); //$NON-NLS-1$ + int offset = source.indexOf("method1"); + Change changes = getRefactorChanges(cpp, offset, "m1"); assertTotalChanges(3, changes); - assertChange(changes, cpp, source.indexOf("method1"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method1(const"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method1(\"hello"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, cpp, source.indexOf("method1"), 7, "m1"); + assertChange(changes, cpp, source.indexOf("method1(const"), 7, "m1"); + assertChange(changes, cpp, source.indexOf("method1(\"hello"), 7, "m1"); } public void testMethod_3() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Boo{ \n"); //$NON-NLS-1$ - writer.write(" int method1(){}//vp1,res1 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" Boo a; \n"); //$NON-NLS-1$ - writer.write(" a.method1();//res2 \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("class Boo{ \n"); + writer.write(" int method1(){}//vp1,res1 \n"); + writer.write("}; \n"); + writer.write("void f() { \n"); + writer.write(" Boo a; \n"); + writer.write(" a.method1();//res2 \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("method1(){}//vp1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ - + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("method1(){}//vp1") ; + Change changes = getRefactorChanges(file, offset, "ooga"); + assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("method1(){}//vp1,res1"), 7, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("method1();//res2"), 7, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("method1(){}//vp1,res1"), 7, "ooga"); + assertChange(changes, file, contents.indexOf("method1();//res2"), 7, "ooga"); } - + public void testConstructor_26() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Boo{ \n"); //$NON-NLS-1$ - writer.write(" Boo(){}//vp1,res1 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" Boo a = new Boo(); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("class Boo{ \n"); + writer.write(" Boo(){}//vp1,res1 \n"); + writer.write("}; \n"); + writer.write("void f() { \n"); + writer.write(" Boo a = new Boo(); \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("Boo(){}") ; //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("Boo(){}") ; try { - getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ + getRefactorChanges(file, offset, "ooga"); } catch (AssertionFailedError e) { - assertTrue(e.getMessage().startsWith("Input check on ooga failed.")); //$NON-NLS-1$ + assertTrue(e.getMessage().startsWith("Input check on ooga failed.")); return; } - fail ("An error should have occurred in the input check."); //$NON-NLS-1$ + fail ("An error should have occurred in the input check."); } // The constructor name is accepted, but the refactoring doesn't remove the return @@ -256,979 +256,979 @@ public class RenameRegressionTests extends RenameTestBase { // better. public void testConstructor_27() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Boo{ \n"); //$NON-NLS-1$ - writer.write(" int foo(){}//vp1 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" Boo a; \n"); //$NON-NLS-1$ - writer.write(" a.foo(); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("class Boo{ \n"); + writer.write(" int foo(){}//vp1 \n"); + writer.write("}; \n"); + writer.write("void f() { \n"); + writer.write(" Boo a; \n"); + writer.write(" a.foo(); \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("foo(){}") ; //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("foo(){}") ; try { - getRefactorChanges(file, offset, "Boo"); //$NON-NLS-1$ + getRefactorChanges(file, offset, "Boo"); } catch (AssertionFailedError e) { //test passes - assertTrue(e.getMessage().startsWith("Input check on Boo failed.")); //$NON-NLS-1$ + assertTrue(e.getMessage().startsWith("Input check on Boo failed.")); return; } - fail ("An error should have occurred in the input check."); //$NON-NLS-1$ + fail ("An error should have occurred in the input check."); } public void testDestructor_28() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Boo{ \n"); //$NON-NLS-1$ - writer.write(" ~Boo(){}//vp1 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" Boo a ; \n"); //$NON-NLS-1$ - writer.write(" a.~Boo(); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("class Boo{ \n"); + writer.write(" ~Boo(){}//vp1 \n"); + writer.write("}; \n"); + writer.write("void f() { \n"); + writer.write(" Boo a ; \n"); + writer.write(" a.~Boo(); \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("~Boo(){}") ; //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("~Boo(){}") ; try { - getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ + getRefactorChanges(file, offset, "ooga"); } catch (AssertionFailedError e) { - assertTrue(e.getMessage().startsWith("Input check on ooga failed.")); //$NON-NLS-1$ + assertTrue(e.getMessage().startsWith("Input check on ooga failed.")); return; } - fail ("An error should have occurred in the input check."); //$NON-NLS-1$ + fail ("An error should have occurred in the input check."); } public void testDestructor_29_72612() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Boo{ \n"); //$NON-NLS-1$ - writer.write(" int foo(){}//vp1 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" Boo a; \n"); //$NON-NLS-1$ - writer.write(" a.foo(); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("class Boo{ \n"); + writer.write(" int foo(){}//vp1 \n"); + writer.write("}; \n"); + writer.write("void f() { \n"); + writer.write(" Boo a; \n"); + writer.write(" a.foo(); \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("foo(){}") ; //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("foo(){}") ; try { - getRefactorChanges(file, offset, "~Boo"); //$NON-NLS-1$ + getRefactorChanges(file, offset, "~Boo"); } catch (AssertionFailedError e) { // test passes - assertTrue(e.getMessage().startsWith("Input check on ~Boo failed.")); //$NON-NLS-1$ + assertTrue(e.getMessage().startsWith("Input check on ~Boo failed.")); return; } - fail ("An error should have occurred in the input check."); //$NON-NLS-1$ + fail ("An error should have occurred in the input check."); } public void testFunction_31() throws Exception { StringWriter writer = new StringWriter(); - writer.write("void foo(){} \n"); //$NON-NLS-1$ - writer.write("void foo/*vp1*/(int i){} \n"); //$NON-NLS-1$ - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write(" int method1(){ \n"); //$NON-NLS-1$ - writer.write(" foo(3); \n"); //$NON-NLS-1$ - writer.write(" foo(); \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - + writer.write("void foo(){} \n"); + writer.write("void foo/*vp1*/(int i){} \n"); + writer.write("class Foo{ \n"); + writer.write(" int method1(){ \n"); + writer.write(" foo(3); \n"); + writer.write(" foo(); \n"); + writer.write(" } \n"); + writer.write("}; \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("foo/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("foo/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "ooga"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("foo/*vp1*/"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("foo(3)"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("foo/*vp1*/"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("foo(3)"), 3, "ooga"); } public void testMethod_32_72717() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Base { \n"); //$NON-NLS-1$ - writer.write(" virtual void foo()=0; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("class Derived: public Base { \n"); //$NON-NLS-1$ - writer.write(" virtual void foo(); \n"); //$NON-NLS-1$ - writer.write(" void foo(char i); \n"); //$NON-NLS-1$ - writer.write(" void moon/*vp1*/(int i); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - + writer.write("class Base { \n"); + writer.write(" virtual void foo()=0; \n"); + writer.write("}; \n"); + writer.write("class Derived: public Base { \n"); + writer.write(" virtual void foo(); \n"); + writer.write(" void foo(char i); \n"); + writer.write(" void moon/*vp1*/(int i); \n"); + writer.write("}; \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("moon/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "foo"); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("moon/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "foo"); assertTotalChanges(1, changes); - assertChange(changes, file, contents.indexOf("moon/*vp1*/"), 4, "foo"); //$NON-NLS-1$//$NON-NLS-2$ - RefactoringStatus status= checkConditions(file, offset, "foo"); //$NON-NLS-1$ + assertChange(changes, file, contents.indexOf("moon/*vp1*/"), 4, "foo"); + RefactoringStatus status= checkConditions(file, offset, "foo"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Overloading \n" + - "New element: foo \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "New element: foo \n" + + "Conflicting element type: Method"); } - + public void testMethod_33_72605() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo { \n"); //$NON-NLS-1$ - writer.write(" void aMethod/*vp1*/(int x=0); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void Foo::aMethod(int x){} \n"); //$NON-NLS-1$ + writer.write("class Foo { \n"); + writer.write(" void aMethod/*vp1*/(int x=0); \n"); + writer.write("}; \n"); + writer.write("void Foo::aMethod(int x){} \n"); String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("aMethod/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("aMethod/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "ooga"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("aMethod/*vp1*/"), 7, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("aMethod(int x)"), 7, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("aMethod/*vp1*/"), 7, "ooga"); + assertChange(changes, file, contents.indexOf("aMethod(int x)"), 7, "ooga"); } public void testMethod_33b_72605() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo { \n"); //$NON-NLS-1$ - writer.write(" void aMethod/*vp1*/(int x=0); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Foo { \n"); + writer.write(" void aMethod/*vp1*/(int x=0); \n"); + writer.write("}; \n"); String header = writer.toString(); - IFile hFile= importFile("t.hh", header); //$NON-NLS-1$ + IFile hFile= importFile("t.hh", header); writer= new StringWriter(); - writer.write("#include \"t.hh\" \n"); //$NON-NLS-1$ - writer.write("void Foo::aMethod(int x){} \n"); //$NON-NLS-1$ + writer.write("#include \"t.hh\" \n"); + writer.write("void Foo::aMethod(int x){} \n"); String source = writer.toString(); - IFile cppfile = importFile("t.cpp", source); //$NON-NLS-1$ + IFile cppfile = importFile("t.cpp", source); waitForIndexer(); - int hoffset = header.indexOf("aMethod") ; //$NON-NLS-1$ - int cppoffset = source.indexOf("aMethod") ; //$NON-NLS-1$ - - Change changes = getRefactorChanges(hFile, hoffset, "ooga"); //$NON-NLS-1$ - assertTotalChanges(2, changes); - assertChange(changes, hFile, hoffset, 7, "ooga"); //$NON-NLS-1$ - assertChange(changes, cppfile, cppoffset, 7, "ooga"); //$NON-NLS-1$ + int hoffset = header.indexOf("aMethod") ; + int cppoffset = source.indexOf("aMethod") ; - changes = getRefactorChanges(cppfile, cppoffset, "ooga"); //$NON-NLS-1$ + Change changes = getRefactorChanges(hFile, hoffset, "ooga"); assertTotalChanges(2, changes); - assertChange(changes, hFile, hoffset, 7, "ooga"); //$NON-NLS-1$ - assertChange(changes, cppfile, cppoffset, 7, "ooga"); //$NON-NLS-1$ + assertChange(changes, hFile, hoffset, 7, "ooga"); + assertChange(changes, cppfile, cppoffset, 7, "ooga"); + + changes = getRefactorChanges(cppfile, cppoffset, "ooga"); + assertTotalChanges(2, changes); + assertChange(changes, hFile, hoffset, 7, "ooga"); + assertChange(changes, cppfile, cppoffset, 7, "ooga"); } public void testMethod_34() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Base{ \n"); //$NON-NLS-1$ - writer.write(" virtual void v/*vp1*/()=0; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("class Derived: Base { \n"); //$NON-NLS-1$ - writer.write(" void v(){}; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Base{ \n"); + writer.write(" virtual void v/*vp1*/()=0; \n"); + writer.write("}; \n"); + writer.write("class Derived: Base { \n"); + writer.write(" void v(){}; \n"); + writer.write("}; \n"); String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("v/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("v/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "ooga"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("v/*vp1*/"), 1, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("v(){}"), 1, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("v/*vp1*/"), 1, "ooga"); + assertChange(changes, file, contents.indexOf("v(){}"), 1, "ooga"); } // defect is input for new name is not allowed public void _testMethod_35_72726() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write(" Foo& operator *=/*vp1*/(const Foo &rhs);\n"); //$NON-NLS-1$ - writer.write(" Foo& operator==/*vp2*/(const Foo &rhs);\n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("Foo& Foo::operator *=(const Foo &rhs){ \n"); //$NON-NLS-1$ - writer.write(" return *this; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("Foo& Foo::operator==(const Foo &rhs){ \n"); //$NON-NLS-1$ - writer.write(" return *this; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Foo{ \n"); + writer.write(" Foo& operator *=/*vp1*/(const Foo &rhs);\n"); + writer.write(" Foo& operator==/*vp2*/(const Foo &rhs);\n"); + writer.write("}; \n"); + writer.write("Foo& Foo::operator *=(const Foo &rhs){ \n"); + writer.write(" return *this; \n"); + writer.write("}; \n"); + writer.write("Foo& Foo::operator==(const Foo &rhs){ \n"); + writer.write(" return *this; \n"); + writer.write("}; \n"); String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); // vp1 with space - int offset = contents.indexOf("operator *=/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "operator +="); //$NON-NLS-1$ + int offset = contents.indexOf("operator *=/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "operator +="); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("operator *=/*vp1*/"), 11, "operator +="); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("operator *=(const"), 11, "operator +="); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("operator *=/*vp1*/"), 11, "operator +="); + assertChange(changes, file, contents.indexOf("operator *=(const"), 11, "operator +="); // vp2 without space - offset = contents.indexOf("operator==/*vp2*/") ; //$NON-NLS-1$ - changes = getRefactorChanges(file, offset, "operator="); //$NON-NLS-1$ + offset = contents.indexOf("operator==/*vp2*/") ; + changes = getRefactorChanges(file, offset, "operator="); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("operator==/*vp2*/"), 11, "operator="); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("operator==(const"), 11, "operator="); //$NON-NLS-1$//$NON-NLS-2$ - + assertChange(changes, file, contents.indexOf("operator==/*vp2*/"), 11, "operator="); + assertChange(changes, file, contents.indexOf("operator==(const"), 11, "operator="); + } public void testMethod_39() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write(" const void* method1(const char*); \n"); //$NON-NLS-1$ - writer.write(" const int method2(int j); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Foo{ \n"); + writer.write(" const void* method1(const char*); \n"); + writer.write(" const int method2(int j); \n"); + writer.write("}; \n"); String header = writer.toString(); - IFile h = importFile("t.hh", header); //$NON-NLS-1$ - + IFile h = importFile("t.hh", header); + writer = new StringWriter(); - writer.write("#include \"t.hh\" \n"); //$NON-NLS-1$ - writer.write("const void* Foo::method1(const char* x){return (void*) x;} \n"); //$NON-NLS-1$ - writer.write("const int Foo::method2(int){return 5;} \n"); //$NON-NLS-1$ - writer.write("void test() { \n"); //$NON-NLS-1$ - writer.write(" Foo d; \n"); //$NON-NLS-1$ - writer.write(" d.method1(\"hello\"); \n"); //$NON-NLS-1$ - writer.write(" int i =d.method2(3); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"t.hh\" \n"); + writer.write("const void* Foo::method1(const char* x){return (void*) x;} \n"); + writer.write("const int Foo::method2(int){return 5;} \n"); + writer.write("void test() { \n"); + writer.write(" Foo d; \n"); + writer.write(" d.method1(\"hello\"); \n"); + writer.write(" int i =d.method2(3); \n"); + writer.write("} \n"); String source = writer.toString(); - IFile cpp = importFile("t.cpp", source); //$NON-NLS-1$ + IFile cpp = importFile("t.cpp", source); waitForIndexer(); - + // vp1 const - int offset = header.indexOf("method1"); //$NON-NLS-1$ - Change changes = getRefactorChanges(h, offset, "m1"); //$NON-NLS-1$ + int offset = header.indexOf("method1"); + Change changes = getRefactorChanges(h, offset, "m1"); assertTotalChanges(3, changes); - assertChange(changes, h, header.indexOf("method1"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method1(const"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method1(\"hello"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("method1"), 7, "m1"); + assertChange(changes, cpp, source.indexOf("method1(const"), 7, "m1"); + assertChange(changes, cpp, source.indexOf("method1(\"hello"), 7, "m1"); // vp2 const in definition with :: - offset = source.indexOf("method2(int"); //$NON-NLS-1$ - changes = getRefactorChanges(cpp, offset, "m2"); //$NON-NLS-1$ + offset = source.indexOf("method2(int"); + changes = getRefactorChanges(cpp, offset, "m2"); assertTotalChanges(3, changes); - assertChange(changes, h, header.indexOf("method2"), 7, "m2"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method2(int"), 7, "m2"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method2(3"), 7, "m2"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("method2"), 7, "m2"); + assertChange(changes, cpp, source.indexOf("method2(int"), 7, "m2"); + assertChange(changes, cpp, source.indexOf("method2(3"), 7, "m2"); } public void testMethod_40() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write(" static int method1/*vp1*/(const char* x); \n"); //$NON-NLS-1$ - writer.write(" static int method2/*vp2*/(int); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Foo{ \n"); + writer.write(" static int method1/*vp1*/(const char* x); \n"); + writer.write(" static int method2/*vp2*/(int); \n"); + writer.write("}; \n"); String header = writer.toString(); - IFile h = importFile("t.hh", header); //$NON-NLS-1$ - + IFile h = importFile("t.hh", header); + writer = new StringWriter(); - writer.write("#include \"t.hh\" \n"); //$NON-NLS-1$ - writer.write("static int Foo::method1(const char* x){return 5;} \n"); //$NON-NLS-1$ - writer.write("static int Foo::method2(int x){return (2);}; \n"); //$NON-NLS-1$ - writer.write("void test() { \n"); //$NON-NLS-1$ - writer.write(" Foo::method1(\"hello\"); \n"); //$NON-NLS-1$ - writer.write(" int i =Foo::method2(3); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"t.hh\" \n"); + writer.write("static int Foo::method1(const char* x){return 5;} \n"); + writer.write("static int Foo::method2(int x){return (2);}; \n"); + writer.write("void test() { \n"); + writer.write(" Foo::method1(\"hello\"); \n"); + writer.write(" int i =Foo::method2(3); \n"); + writer.write("} \n"); String source = writer.toString(); - IFile cpp = importFile("t.cpp", source); //$NON-NLS-1$ + IFile cpp = importFile("t.cpp", source); waitForIndexer(); // vp1 static method declaration - int offset = header.indexOf("method1/*vp1*/"); //$NON-NLS-1$ - Change changes = getRefactorChanges(h, offset, "m1"); //$NON-NLS-1$ + int offset = header.indexOf("method1/*vp1*/"); + Change changes = getRefactorChanges(h, offset, "m1"); assertTotalChanges(3, changes); - assertChange(changes, h, header.indexOf("method1/*vp1*/"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method1(const"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method1(\"hello"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("method1/*vp1*/"), 7, "m1"); + assertChange(changes, cpp, source.indexOf("method1(const"), 7, "m1"); + assertChange(changes, cpp, source.indexOf("method1(\"hello"), 7, "m1"); // vp2 static method definition - offset = source.indexOf("Foo::method2")+5; //$NON-NLS-1$ - changes = getRefactorChanges(cpp, offset, "m2"); //$NON-NLS-1$ + offset = source.indexOf("Foo::method2")+5; + changes = getRefactorChanges(cpp, offset, "m2"); assertTotalChanges(3, changes); - assertChange(changes, h, header.indexOf("method2/*vp2*/"), 7, "m2"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method2(int x"), 7, "m2"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method2(3"), 7, "m2"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("method2/*vp2*/"), 7, "m2"); + assertChange(changes, cpp, source.indexOf("method2(int x"), 7, "m2"); + assertChange(changes, cpp, source.indexOf("method2(3"), 7, "m2"); } - + public void testMethod_41() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write("public: \n"); //$NON-NLS-1$ - writer.write(" volatile int method1/*vp1*/(int); \n"); //$NON-NLS-1$ - writer.write("private: \n"); //$NON-NLS-1$ - writer.write(" int b; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Foo{ \n"); + writer.write("public: \n"); + writer.write(" volatile int method1/*vp1*/(int); \n"); + writer.write("private: \n"); + writer.write(" int b; \n"); + writer.write("}; \n"); String header = writer.toString(); - IFile h = importFile("t.hh", header); //$NON-NLS-1$ - + IFile h = importFile("t.hh", header); + writer = new StringWriter(); - writer.write("#include \"t.hh\" \n"); //$NON-NLS-1$ - writer.write("volatile int Foo::method1(int x){return (2);}; \n"); //$NON-NLS-1$ - writer.write("void test() { \n"); //$NON-NLS-1$ - writer.write(" Foo d; \n"); //$NON-NLS-1$ - writer.write(" int i =d.method1(1); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"t.hh\" \n"); + writer.write("volatile int Foo::method1(int x){return (2);}; \n"); + writer.write("void test() { \n"); + writer.write(" Foo d; \n"); + writer.write(" int i =d.method1(1); \n"); + writer.write("} \n"); String source = writer.toString(); - IFile cpp = importFile("t.cpp", source); //$NON-NLS-1$ + IFile cpp = importFile("t.cpp", source); waitForIndexer(); // vp1 volatile - int offset = header.indexOf("method1/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(h, offset, "m1"); //$NON-NLS-1$ + int offset = header.indexOf("method1/*vp1*/") ; + Change changes = getRefactorChanges(h, offset, "m1"); assertTotalChanges(3, changes); - assertChange(changes, h, header.indexOf("method1/*vp1*/"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method1(int x"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method1(1"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("method1/*vp1*/"), 7, "m1"); + assertChange(changes, cpp, source.indexOf("method1(int x"), 7, "m1"); + assertChange(changes, cpp, source.indexOf("method1(1"), 7, "m1"); } public void testMethod_43() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write("public: \n"); //$NON-NLS-1$ - writer.write(" inline void method1/*vp1*/(int i) {b=i;} \n"); //$NON-NLS-1$ - writer.write("private: \n"); //$NON-NLS-1$ - writer.write(" int b; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Foo{ \n"); + writer.write("public: \n"); + writer.write(" inline void method1/*vp1*/(int i) {b=i;} \n"); + writer.write("private: \n"); + writer.write(" int b; \n"); + writer.write("}; \n"); String header = writer.toString(); - IFile h = importFile("t.hh", header); //$NON-NLS-1$ - + IFile h = importFile("t.hh", header); + writer = new StringWriter(); - writer.write("#include \"t.hh\" \n"); //$NON-NLS-1$ - writer.write("void test() { \n"); //$NON-NLS-1$ - writer.write(" Foo* d; \n"); //$NON-NLS-1$ - writer.write(" d->method1(1); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"t.hh\" \n"); + writer.write("void test() { \n"); + writer.write(" Foo* d; \n"); + writer.write(" d->method1(1); \n"); + writer.write("} \n"); String source = writer.toString(); - IFile cpp = importFile("t.cpp", source); //$NON-NLS-1$ + IFile cpp = importFile("t.cpp", source); waitForIndexer(); - + // vp1 inline - int offset = header.indexOf("method1/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(h, offset, "m1"); //$NON-NLS-1$ + int offset = header.indexOf("method1/*vp1*/") ; + Change changes = getRefactorChanges(h, offset, "m1"); assertTotalChanges(2, changes); - assertChange(changes, h, header.indexOf("method1/*vp1*/"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("method1(1"), 7, "m1"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("method1/*vp1*/"), 7, "m1"); + assertChange(changes, cpp, source.indexOf("method1(1"), 7, "m1"); } public void testMethod_44() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Base{ \n"); //$NON-NLS-1$ - writer.write(" virtual void v(); \n"); //$NON-NLS-1$ - writer.write(" int i; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void Base::v(){} \n"); //$NON-NLS-1$ - writer.write("class Derived: Base { \n"); //$NON-NLS-1$ - writer.write(" virtual void v/*vp1*/(){}//explicitly virtual \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("class Derived2: Derived {\n"); //$NON-NLS-1$ - writer.write(" void v(){i++;} \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Base{ \n"); + writer.write(" virtual void v(); \n"); + writer.write(" int i; \n"); + writer.write("}; \n"); + writer.write("void Base::v(){} \n"); + writer.write("class Derived: Base { \n"); + writer.write(" virtual void v/*vp1*/(){}//explicitly virtual \n"); + writer.write("}; \n"); + writer.write("class Derived2: Derived {\n"); + writer.write(" void v(){i++;} \n"); + writer.write("}; \n"); String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); // vp1 implicit virtual method - int offset = contents.indexOf("v/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "v1"); //$NON-NLS-1$ + int offset = contents.indexOf("v/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "v1"); assertTotalChanges(4, changes); - assertChange(changes, file, contents.indexOf("v();"), 1, "v1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("v(){}"), 1, "v1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("v/*vp1*/"), 1, "v1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("v(){i++;}"), 1, "v1"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("v();"), 1, "v1"); + assertChange(changes, file, contents.indexOf("v(){}"), 1, "v1"); + assertChange(changes, file, contents.indexOf("v/*vp1*/"), 1, "v1"); + assertChange(changes, file, contents.indexOf("v(){i++;}"), 1, "v1"); } - + public void testMethod_45() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Base{ \n"); //$NON-NLS-1$ - writer.write(" virtual void v(); \n"); //$NON-NLS-1$ - writer.write(" int i; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void Base::v(){} \n"); //$NON-NLS-1$ - writer.write("class Derived: Base { \n"); //$NON-NLS-1$ - writer.write(" void v/*vp1*/(){}//implicitly virtual \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("class Derived2: Derived {\n"); //$NON-NLS-1$ - writer.write(" void v(){i++;} \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Base{ \n"); + writer.write(" virtual void v(); \n"); + writer.write(" int i; \n"); + writer.write("}; \n"); + writer.write("void Base::v(){} \n"); + writer.write("class Derived: Base { \n"); + writer.write(" void v/*vp1*/(){}//implicitly virtual \n"); + writer.write("}; \n"); + writer.write("class Derived2: Derived {\n"); + writer.write(" void v(){i++;} \n"); + writer.write("}; \n"); String contents = writer.toString(); - IFile file = importFile("t45.cpp", contents); //$NON-NLS-1$ + IFile file = importFile("t45.cpp", contents); waitForIndexer(); // vp1 implicit virtual method - int offset = contents.indexOf("v/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "v1"); //$NON-NLS-1$ + int offset = contents.indexOf("v/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "v1"); assertTotalChanges(4, changes); - assertChange(changes, file, contents.indexOf("v()"), 1, "v1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("v(){}"), 1, "v1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("v/*vp1*/"), 1, "v1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("v(){i"), 1, "v1"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("v()"), 1, "v1"); + assertChange(changes, file, contents.indexOf("v(){}"), 1, "v1"); + assertChange(changes, file, contents.indexOf("v/*vp1*/"), 1, "v1"); + assertChange(changes, file, contents.indexOf("v(){i"), 1, "v1"); } public void testStruct_46() throws Exception { StringWriter writer = new StringWriter(); - writer.write("struct st1/*vp1*/{}; \n"); //$NON-NLS-1$ - writer.write("class c1/*vp1*/{ \n"); //$NON-NLS-1$ - writer.write(" public: struct st2/*vp2*/{} s; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("namespace N{ \n"); //$NON-NLS-1$ - writer.write(" struct st3/*vp3*/{}; \n"); //$NON-NLS-1$ - writer.write(" class c2/*vp1*/{ \n"); //$NON-NLS-1$ - writer.write(" st1 s; \n"); //$NON-NLS-1$ - writer.write(" st3 ss; \n"); //$NON-NLS-1$ - writer.write(" c2() { \n"); //$NON-NLS-1$ - writer.write(" c1::st2 s; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write(" }; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("struct st1/*vp1*/{}; \n"); + writer.write("class c1/*vp1*/{ \n"); + writer.write(" public: struct st2/*vp2*/{} s; \n"); + writer.write("}; \n"); + writer.write("namespace N{ \n"); + writer.write(" struct st3/*vp3*/{}; \n"); + writer.write(" class c2/*vp1*/{ \n"); + writer.write(" st1 s; \n"); + writer.write(" st3 ss; \n"); + writer.write(" c2() { \n"); + writer.write(" c1::st2 s; \n"); + writer.write(" } \n"); + writer.write(" }; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); // vp1 global declaration - int offset = contents.indexOf("st1/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga1"); //$NON-NLS-1$ + int offset = contents.indexOf("st1/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "Ooga1"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("st1/*vp1*/"), 3, "Ooga1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("st1 s"), 3, "Ooga1"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("st1/*vp1*/"), 3, "Ooga1"); + assertChange(changes, file, contents.indexOf("st1 s"), 3, "Ooga1"); // vp2 Declared in class - offset = contents.indexOf("st2/*vp2*/") ; //$NON-NLS-1$ - changes = getRefactorChanges(file, offset, "Ooga2"); //$NON-NLS-1$ + offset = contents.indexOf("st2/*vp2*/") ; + changes = getRefactorChanges(file, offset, "Ooga2"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("st2/*vp2*/"), 3, "Ooga2"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("st2 s"), 3, "Ooga2"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("st2/*vp2*/"), 3, "Ooga2"); + assertChange(changes, file, contents.indexOf("st2 s"), 3, "Ooga2"); // vp3 Declared in namespace - offset = contents.indexOf("st3/*vp3*/") ; //$NON-NLS-1$ - changes = getRefactorChanges(file, offset, "Ooga3"); //$NON-NLS-1$ + offset = contents.indexOf("st3/*vp3*/") ; + changes = getRefactorChanges(file, offset, "Ooga3"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("st3/*vp3*/"), 3, "Ooga3"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("st3 ss"), 3, "Ooga3"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("st3/*vp3*/"), 3, "Ooga3"); + assertChange(changes, file, contents.indexOf("st3 ss"), 3, "Ooga3"); } public void testUnion_47() throws Exception { StringWriter writer = new StringWriter(); - writer.write("union st1/*vp1*/{}; \n"); //$NON-NLS-1$ - writer.write("class c1/*vp1*/{ \n"); //$NON-NLS-1$ - writer.write(" public: union st2/*vp2*/{} s; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("namespace N{ \n"); //$NON-NLS-1$ - writer.write(" union st3/*vp3*/{}; \n"); //$NON-NLS-1$ - writer.write(" class c2/*vp1*/{ \n"); //$NON-NLS-1$ - writer.write(" st1 s; \n"); //$NON-NLS-1$ - writer.write(" st3 ss; \n"); //$NON-NLS-1$ - writer.write(" c2() { \n"); //$NON-NLS-1$ - writer.write(" c1::st2 s; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write(" }; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("union st1/*vp1*/{}; \n"); + writer.write("class c1/*vp1*/{ \n"); + writer.write(" public: union st2/*vp2*/{} s; \n"); + writer.write("}; \n"); + writer.write("namespace N{ \n"); + writer.write(" union st3/*vp3*/{}; \n"); + writer.write(" class c2/*vp1*/{ \n"); + writer.write(" st1 s; \n"); + writer.write(" st3 ss; \n"); + writer.write(" c2() { \n"); + writer.write(" c1::st2 s; \n"); + writer.write(" } \n"); + writer.write(" }; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); // vp1 global declaration - int offset = contents.indexOf("st1/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga1"); //$NON-NLS-1$ + int offset = contents.indexOf("st1/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "Ooga1"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("st1/*vp1*/"), 3, "Ooga1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("st1 s"), 3, "Ooga1"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("st1/*vp1*/"), 3, "Ooga1"); + assertChange(changes, file, contents.indexOf("st1 s"), 3, "Ooga1"); // vp2 Declared in class - offset = contents.indexOf("st2/*vp2*/") ; //$NON-NLS-1$ - changes = getRefactorChanges(file, offset, "Ooga2"); //$NON-NLS-1$ + offset = contents.indexOf("st2/*vp2*/") ; + changes = getRefactorChanges(file, offset, "Ooga2"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("st2/*vp2*/"), 3, "Ooga2"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("st2 s"), 3, "Ooga2"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("st2/*vp2*/"), 3, "Ooga2"); + assertChange(changes, file, contents.indexOf("st2 s"), 3, "Ooga2"); // vp3 Declared in namespace - offset = contents.indexOf("st3/*vp3*/") ; //$NON-NLS-1$ - changes = getRefactorChanges(file, offset, "Ooga3"); //$NON-NLS-1$ + offset = contents.indexOf("st3/*vp3*/") ; + changes = getRefactorChanges(file, offset, "Ooga3"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("st3/*vp3*/"), 3, "Ooga3"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("st3 ss"), 3, "Ooga3"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("st3/*vp3*/"), 3, "Ooga3"); + assertChange(changes, file, contents.indexOf("st3 ss"), 3, "Ooga3"); } public void testEnumeration_48() throws Exception { StringWriter writer = new StringWriter(); - writer.write("enum e1/*vp1*/{E0}; \n"); //$NON-NLS-1$ - writer.write("class c1 { \n"); //$NON-NLS-1$ - writer.write(" public: enum e2/*vp2*/{E1} s; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("namespace N{ \n"); //$NON-NLS-1$ - writer.write(" enum e3/*vp3*/{}; \n"); //$NON-NLS-1$ - writer.write(" class c2/*vp1*/{ \n"); //$NON-NLS-1$ - writer.write(" e1 s; \n"); //$NON-NLS-1$ - writer.write(" e3 ss; \n"); //$NON-NLS-1$ - writer.write(" c2() { \n"); //$NON-NLS-1$ - writer.write(" c1::e2 s; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write(" }; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("enum e1/*vp1*/{E0}; \n"); + writer.write("class c1 { \n"); + writer.write(" public: enum e2/*vp2*/{E1} s; \n"); + writer.write("}; \n"); + writer.write("namespace N{ \n"); + writer.write(" enum e3/*vp3*/{}; \n"); + writer.write(" class c2/*vp1*/{ \n"); + writer.write(" e1 s; \n"); + writer.write(" e3 ss; \n"); + writer.write(" c2() { \n"); + writer.write(" c1::e2 s; \n"); + writer.write(" } \n"); + writer.write(" }; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); // vp1 global declaration - int offset = contents.indexOf("e1/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga1"); //$NON-NLS-1$ + int offset = contents.indexOf("e1/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "Ooga1"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("e1/*vp1*/"), 2, "Ooga1"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("e1 s"), 2, "Ooga1"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("e1/*vp1*/"), 2, "Ooga1"); + assertChange(changes, file, contents.indexOf("e1 s"), 2, "Ooga1"); // vp2 Declared in class - offset = contents.indexOf("e2/*vp2*/") ; //$NON-NLS-1$ - changes = getRefactorChanges(file, offset, "Ooga2"); //$NON-NLS-1$ + offset = contents.indexOf("e2/*vp2*/") ; + changes = getRefactorChanges(file, offset, "Ooga2"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("e2/*vp2*/"), 2, "Ooga2"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("e2 s"), 2, "Ooga2"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("e2/*vp2*/"), 2, "Ooga2"); + assertChange(changes, file, contents.indexOf("e2 s"), 2, "Ooga2"); // vp3 Declared in namespace - offset = contents.indexOf("e3/*vp3*/") ; //$NON-NLS-1$ - changes = getRefactorChanges(file, offset, "Ooga3"); //$NON-NLS-1$ + offset = contents.indexOf("e3/*vp3*/") ; + changes = getRefactorChanges(file, offset, "Ooga3"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("e3/*vp3*/"), 2, "Ooga3"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("e3 ss"), 2, "Ooga3"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("e3/*vp3*/"), 2, "Ooga3"); + assertChange(changes, file, contents.indexOf("e3 ss"), 2, "Ooga3"); } public void testTemplate_49_72626() throws Exception { StringWriter writer = new StringWriter(); - writer.write("template \n"); //$NON-NLS-1$ - writer.write("class Array/*vp1*/ { \n"); //$NON-NLS-1$ - writer.write(" public: Array(){ \n"); //$NON-NLS-1$ - writer.write(" a=new Type[10]; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write(" virtual Type& operator[](int i){return a[i];} \n"); //$NON-NLS-1$ - writer.write(" protected: Type *a; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void f(){ \n"); //$NON-NLS-1$ - writer.write(" Array a; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("template \n"); + writer.write("class Array/*vp1*/ { \n"); + writer.write(" public: Array(){ \n"); + writer.write(" a=new Type[10]; \n"); + writer.write(" } \n"); + writer.write(" virtual Type& operator[](int i){return a[i];} \n"); + writer.write(" protected: Type *a; \n"); + writer.write("}; \n"); + writer.write("void f(){ \n"); + writer.write(" Array a; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("Array") ; //$NON-NLS-1$ - Change changes= getRefactorChanges(file, offset, "Arr2"); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("Array") ; + Change changes= getRefactorChanges(file, offset, "Arr2"); assertTotalChanges(3, changes); - assertChange(changes, file, offset, 5, "Arr2"); //$NON-NLS-1$ - assertChange(changes, file, offset=contents.indexOf("Array", offset+1), 5, "Arr2"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, offset=contents.indexOf("Array", offset+1), 5, "Arr2"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, offset, 5, "Arr2"); + assertChange(changes, file, offset=contents.indexOf("Array", offset+1), 5, "Arr2"); + assertChange(changes, file, offset=contents.indexOf("Array", offset+1), 5, "Arr2"); } public void testClass_52() throws Exception { StringWriter writer = new StringWriter(); - writer.write("namespace N1 { \n"); //$NON-NLS-1$ - writer.write("class Boo{}; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("namespace N2 { \n"); //$NON-NLS-1$ - writer.write("class Boo/*vp1*/{}; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" N1::Boo c1; \n"); //$NON-NLS-1$ - writer.write(" N2::Boo c2; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("namespace N1 { \n"); + writer.write("class Boo{}; \n"); + writer.write("} \n"); + writer.write("namespace N2 { \n"); + writer.write("class Boo/*vp1*/{}; \n"); + writer.write("} \n"); + writer.write("void f() { \n"); + writer.write(" N1::Boo c1; \n"); + writer.write(" N2::Boo c2; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("Boo/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga"); //$NON-NLS-1$ - + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("Boo/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "Ooga"); + assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("Boo/*vp1*/"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Boo c2"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("Boo/*vp1*/"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Boo c2"), 3, "Ooga"); } public void testClass_53() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo/*vp1*/ {//ren1 \n"); //$NON-NLS-1$ - writer.write(" Foo();//ren2 \n"); //$NON-NLS-1$ - writer.write(" virtual ~Foo();//ren3 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("Foo::Foo() {}//ren4,5 \n"); //$NON-NLS-1$ - writer.write("Foo::~Foo() {}//ren6,7 \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" Foo *f=new Foo();//ren8,9 \n"); //$NON-NLS-1$ - writer.write(" f->~Foo();//ren10 \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("class Foo/*vp1*/ {//ren1 \n"); + writer.write(" Foo();//ren2 \n"); + writer.write(" virtual ~Foo();//ren3 \n"); + writer.write("}; \n"); + writer.write("Foo::Foo() {}//ren4,5 \n"); + writer.write("Foo::~Foo() {}//ren6,7 \n"); + writer.write("void f() { \n"); + writer.write(" Foo *f=new Foo();//ren8,9 \n"); + writer.write(" f->~Foo();//ren10 \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("Foo/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga"); //$NON-NLS-1$ - + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("Foo/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "Ooga"); + assertTotalChanges(10, changes); - assertChange(changes, file, contents.indexOf("Foo/*vp1*/"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo();//ren2"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo();//ren3"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo::Foo() {}//ren4,5"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo() {}//ren4,5"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo::~Foo() {}//ren6,7"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo() {}//ren6,7"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo *f=new Foo();//ren8,9"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo();//ren8,9"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo();//ren10"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("Foo/*vp1*/"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo();//ren2"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo();//ren3"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo::Foo() {}//ren4,5"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo() {}//ren4,5"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo::~Foo() {}//ren6,7"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo() {}//ren6,7"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo *f=new Foo();//ren8,9"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo();//ren8,9"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo();//ren10"), 3, "Ooga"); } public void testAttribute_54() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Boo{ \n"); //$NON-NLS-1$ - writer.write(" static int att;//vp1,rn1 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" Boo a; \n"); //$NON-NLS-1$ - writer.write(" a.att;//rn2 \n"); //$NON-NLS-1$ - writer.write(" Boo::att;//rn3 \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("class Boo{ \n"); + writer.write(" static int att;//vp1,rn1 \n"); + writer.write("}; \n"); + writer.write("void f() { \n"); + writer.write(" Boo a; \n"); + writer.write(" a.att;//rn2 \n"); + writer.write(" Boo::att;//rn3 \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("att;//vp1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ - + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("att;//vp1") ; + Change changes = getRefactorChanges(file, offset, "ooga"); + assertTotalChanges(3, changes); - assertChange(changes, file, contents.indexOf("att;//vp1"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("att;//rn2"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("att;//rn3"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("att;//vp1"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("att;//rn2"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("att;//rn3"), 3, "ooga"); } public void testClass_55() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write(" class Hoo{//vp1 \n"); //$NON-NLS-1$ - writer.write(" public: Hoo(); \n"); //$NON-NLS-1$ - writer.write(" }; \n"); //$NON-NLS-1$ - writer.write(" Foo(){ \n"); //$NON-NLS-1$ - writer.write(" Foo::Hoo h; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("Foo::Hoo::Hoo(){} \n"); //$NON-NLS-1$ - + writer.write("class Foo{ \n"); + writer.write(" class Hoo{//vp1 \n"); + writer.write(" public: Hoo(); \n"); + writer.write(" }; \n"); + writer.write(" Foo(){ \n"); + writer.write(" Foo::Hoo h; \n"); + writer.write(" } \n"); + writer.write("}; \n"); + writer.write("Foo::Hoo::Hoo(){} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("Hoo{") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ - + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("Hoo{") ; + Change changes = getRefactorChanges(file, offset, "ooga"); + assertTotalChanges(5, changes); - assertChange(changes, file, contents.indexOf("Hoo{//vp1"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Hoo();"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Hoo h;"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Hoo::Hoo(){}"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Hoo(){}"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("Hoo{//vp1"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("Hoo();"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("Hoo h;"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("Hoo::Hoo(){}"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("Hoo(){}"), 3, "ooga"); } public void testClass_55_79231() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Boo{};//vp1 \n"); //$NON-NLS-1$ - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write(" Foo() { \n"); //$NON-NLS-1$ - writer.write(" class Boo{}; \n"); //$NON-NLS-1$ - writer.write(" Boo t; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - + writer.write("class Boo{};//vp1 \n"); + writer.write("class Foo{ \n"); + writer.write(" Foo() { \n"); + writer.write(" class Boo{}; \n"); + writer.write(" Boo t; \n"); + writer.write(" } \n"); + writer.write("}; \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - // defect is that the inner class defined in a method is also renamed, when it + IFile file = importFile("t.cpp", contents); + // defect is that the inner class defined in a method is also renamed, when it // shouldn't be. - int offset = contents.indexOf("Boo{};//vp1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga"); //$NON-NLS-1$ - + int offset = contents.indexOf("Boo{};//vp1") ; + Change changes = getRefactorChanges(file, offset, "Ooga"); + assertTotalChanges(1, changes); - assertChange(changes, file, contents.indexOf("Boo{};//vp1"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("Boo{};//vp1"), 3, "Ooga"); } public void testClass_55_72748() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{};//vp1 \n"); //$NON-NLS-1$ - writer.write("void f(){ \n"); //$NON-NLS-1$ - writer.write(" Foo *somePtr; \n"); //$NON-NLS-1$ - writer.write(" if (somePtr == reinterpret_cast(0)){} \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("class Foo{};//vp1 \n"); + writer.write("void f(){ \n"); + writer.write(" Foo *somePtr; \n"); + writer.write(" if (somePtr == reinterpret_cast(0)){} \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - // defect is that the Foo in <> is not renamed - int offset = contents.indexOf("Foo{};//vp1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga"); //$NON-NLS-1$ - + IFile file = importFile("t.cpp", contents); + // defect is that the Foo in <> is not renamed + int offset = contents.indexOf("Foo{};//vp1") ; + Change changes = getRefactorChanges(file, offset, "Ooga"); + assertTotalChanges(3, changes); - assertChange(changes, file, contents.indexOf("Foo{};//vp1"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo *somePtr"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo*>(0)"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("Foo{};//vp1"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo *somePtr"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo*>(0)"), 3, "Ooga"); } public void testClass_56() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{};//vp1,rn1 \n"); //$NON-NLS-1$ - writer.write("class Derived: public Foo{//rn2 \n"); //$NON-NLS-1$ - writer.write(" Derived():Foo(){}//rn3 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - + writer.write("class Foo{};//vp1,rn1 \n"); + writer.write("class Derived: public Foo{//rn2 \n"); + writer.write(" Derived():Foo(){}//rn3 \n"); + writer.write("}; \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - // defect is that the inner class defined in a method is also renamed, when it + IFile file = importFile("t.cpp", contents); + // defect is that the inner class defined in a method is also renamed, when it // shouldn't be. - int offset = contents.indexOf("Foo{};//vp1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga"); //$NON-NLS-1$ - + int offset = contents.indexOf("Foo{};//vp1") ; + Change changes = getRefactorChanges(file, offset, "Ooga"); + assertTotalChanges(3, changes); - assertChange(changes, file, contents.indexOf("Foo{};//vp1"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo{//rn2"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo(){}//rn3"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("Foo{};//vp1"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo{//rn2"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo(){}//rn3"), 3, "Ooga"); } public void testAttribute_61() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write(" private: static int count;//vp1 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Foo{ \n"); + writer.write(" private: static int count;//vp1 \n"); + writer.write("}; \n"); String header = writer.toString(); - IFile h = importFile("Foo.hh", header); //$NON-NLS-1$ + IFile h = importFile("Foo.hh", header); writer = new StringWriter(); - writer.write("#include \"Foo.hh\" \n"); //$NON-NLS-1$ - writer.write("int Foo::count=10; \n"); //$NON-NLS-1$ - + writer.write("#include \"Foo.hh\" \n"); + writer.write("int Foo::count=10; \n"); + String source = writer.toString(); - IFile cpp = importFile("Foo.cpp", source); //$NON-NLS-1$ - int offset = header.indexOf("count") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(h, offset, "ooga"); //$NON-NLS-1$ - + IFile cpp = importFile("Foo.cpp", source); + int offset = header.indexOf("count") ; + Change changes = getRefactorChanges(h, offset, "ooga"); + assertTotalChanges(2, changes); - assertChange(changes, h, header.indexOf("count"), 5, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("count"), 5, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("count"), 5, "ooga"); + assertChange(changes, cpp, source.indexOf("count"), 5, "ooga"); } public void testEnumerator_62() throws Exception { StringWriter writer = new StringWriter(); - writer.write("enum Foo{E0, E1};//vp1 \n"); //$NON-NLS-1$ + writer.write("enum Foo{E0, E1};//vp1 \n"); String header = writer.toString(); - IFile h = importFile("Foo.hh", header); //$NON-NLS-1$ + IFile h = importFile("Foo.hh", header); writer = new StringWriter(); - writer.write("#include \"Foo.hh\" \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" int i=E1; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("#include \"Foo.hh\" \n"); + writer.write("void f() { \n"); + writer.write(" int i=E1; \n"); + writer.write("} \n"); + String source = writer.toString(); - IFile cpp=importFile("Foo.cpp", source); //$NON-NLS-1$ + IFile cpp=importFile("Foo.cpp", source); waitForIndexer(); - - int offset = header.indexOf("E1") ; //$NON-NLS-1$ - getRefactorChanges(h, offset, "Ooga"); //$NON-NLS-1$ - Change changes = getRefactorChanges(h, offset, "ooga"); //$NON-NLS-1$ - + + int offset = header.indexOf("E1") ; + getRefactorChanges(h, offset, "Ooga"); + Change changes = getRefactorChanges(h, offset, "ooga"); + assertTotalChanges(2, changes); - assertChange(changes, h, header.indexOf("E1"), 2, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("E1"), 2, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("E1"), 2, "ooga"); + assertChange(changes, cpp, source.indexOf("E1"), 2, "ooga"); } public void testAttribute_63() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write(" int att; \n"); //$NON-NLS-1$ - writer.write(" Foo(int i); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Foo{ \n"); + writer.write(" int att; \n"); + writer.write(" Foo(int i); \n"); + writer.write("}; \n"); String header = writer.toString(); - IFile h = importFile("Foo.hh", header); //$NON-NLS-1$ + IFile h = importFile("Foo.hh", header); writer = new StringWriter(); - writer.write("#include \"Foo.hh\" \n"); //$NON-NLS-1$ - writer.write("Foo::Foo(int i): att(i) {} \n"); //$NON-NLS-1$ - + writer.write("#include \"Foo.hh\" \n"); + writer.write("Foo::Foo(int i): att(i) {} \n"); + String source = writer.toString(); - IFile cpp = importFile("Foo.cpp", source); //$NON-NLS-1$ + IFile cpp = importFile("Foo.cpp", source); waitForIndexer(); - - int offset = header.indexOf("att") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(h, offset, "ooga"); //$NON-NLS-1$ - + + int offset = header.indexOf("att") ; + Change changes = getRefactorChanges(h, offset, "ooga"); + assertTotalChanges(2, changes); - assertChange(changes, h, header.indexOf("att"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("att"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("att"), 3, "ooga"); + assertChange(changes, cpp, source.indexOf("att"), 3, "ooga"); } public void testAttribute_64() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Foo{ \n"); //$NON-NLS-1$ - writer.write(" private: \n"); //$NON-NLS-1$ - writer.write(" int b;//vp1,rn1 \n"); //$NON-NLS-1$ - writer.write(" int m(int b) { \n"); //$NON-NLS-1$ - writer.write(" return b; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write(" int n() { \n"); //$NON-NLS-1$ - writer.write(" return b;//rn2 \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write(" int o() { \n"); //$NON-NLS-1$ - writer.write(" int b=2; \n"); //$NON-NLS-1$ - writer.write(" return b; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class Foo{ \n"); + writer.write(" private: \n"); + writer.write(" int b;//vp1,rn1 \n"); + writer.write(" int m(int b) { \n"); + writer.write(" return b; \n"); + writer.write(" } \n"); + writer.write(" int n() { \n"); + writer.write(" return b;//rn2 \n"); + writer.write(" } \n"); + writer.write(" int o() { \n"); + writer.write(" int b=2; \n"); + writer.write(" return b; \n"); + writer.write(" } \n"); + writer.write("}; \n"); String header = writer.toString(); - IFile h = importFile("Foo.hh", header); //$NON-NLS-1$ - int offset = header.indexOf("b;//vp1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(h, offset, "ooga"); //$NON-NLS-1$ - + IFile h = importFile("Foo.hh", header); + int offset = header.indexOf("b;//vp1") ; + Change changes = getRefactorChanges(h, offset, "ooga"); + assertTotalChanges(2, changes); - assertChange(changes, h, header.indexOf("b;//vp1"), 1, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, h, header.indexOf("b;//rn2"), 1, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("b;//vp1"), 1, "ooga"); + assertChange(changes, h, header.indexOf("b;//rn2"), 1, "ooga"); } public void testAttribute_65() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class A{ \n"); //$NON-NLS-1$ - writer.write(" int x(); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("class B{ \n"); //$NON-NLS-1$ - writer.write(" friend class A; \n"); //$NON-NLS-1$ - writer.write(" private: \n"); //$NON-NLS-1$ - writer.write(" int att; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ + writer.write("class A{ \n"); + writer.write(" int x(); \n"); + writer.write("}; \n"); + writer.write("class B{ \n"); + writer.write(" friend class A; \n"); + writer.write(" private: \n"); + writer.write(" int att; \n"); + writer.write("}; \n"); String header = writer.toString(); - IFile h = importFile("Foo.hh", header); //$NON-NLS-1$ + IFile h = importFile("Foo.hh", header); writer = new StringWriter(); - writer.write("#include \"Foo.hh\" \n"); //$NON-NLS-1$ - writer.write("int A::x() { \n"); //$NON-NLS-1$ - writer.write(" B b; \n"); //$NON-NLS-1$ - writer.write(" int att=b.att; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"Foo.hh\" \n"); + writer.write("int A::x() { \n"); + writer.write(" B b; \n"); + writer.write(" int att=b.att; \n"); + writer.write("} \n"); String source = writer.toString(); - IFile cpp = importFile("Foo.cpp", source); //$NON-NLS-1$ - int offset = header.indexOf("att") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(h, offset, "ooga"); //$NON-NLS-1$ - + IFile cpp = importFile("Foo.cpp", source); + int offset = header.indexOf("att") ; + Change changes = getRefactorChanges(h, offset, "ooga"); + assertTotalChanges(2, changes); - assertChange(changes, h, header.indexOf("att"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, cpp, source.indexOf("att;"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("att"), 3, "ooga"); + assertChange(changes, cpp, source.indexOf("att;"), 3, "ooga"); } public void testNamespace_66() throws Exception { StringWriter writer = new StringWriter(); - writer.write("namespace Foo/*vp1*/{ \n"); //$NON-NLS-1$ - writer.write(" namespace Baz/*vp2*/ { \n"); //$NON-NLS-1$ - writer.write(" int i; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write(" using namespace Baz; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" Foo::i = 1; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("namespace Foo/*vp1*/{ \n"); + writer.write(" namespace Baz/*vp2*/ { \n"); + writer.write(" int i; \n"); + writer.write(" } \n"); + writer.write(" using namespace Baz; \n"); + writer.write("} \n"); + writer.write("void f() { \n"); + writer.write(" Foo::i = 1; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); // vp1 Foo with ref in function - int offset = contents.indexOf("Foo/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga"); //$NON-NLS-1$ + int offset = contents.indexOf("Foo/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "Ooga"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("Foo/*vp1*/"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo::"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("Foo/*vp1*/"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo::"), 3, "Ooga"); // vp2 nested Baz with ref in using - offset = contents.indexOf("Baz/*vp2*/") ; //$NON-NLS-1$ - changes = getRefactorChanges(file, offset, "Wooga"); //$NON-NLS-1$ + offset = contents.indexOf("Baz/*vp2*/") ; + changes = getRefactorChanges(file, offset, "Wooga"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("Baz/*vp2*/"), 3, "Wooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Baz;"), 3, "Wooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("Baz/*vp2*/"), 3, "Wooga"); + assertChange(changes, file, contents.indexOf("Baz;"), 3, "Wooga"); } public void testNamespace_66_79281() throws Exception { StringWriter writer = new StringWriter(); - writer.write("namespace Foo{ \n"); //$NON-NLS-1$ - writer.write(" int i; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("namespace Bar/*vp1*/ = Foo; \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" Bar::i = 1; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("namespace Foo{ \n"); + writer.write(" int i; \n"); + writer.write("} \n"); + writer.write("namespace Bar/*vp1*/ = Foo; \n"); + writer.write("void f() { \n"); + writer.write(" Bar::i = 1; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("Bar/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga"); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("Bar/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "Ooga"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("Bar/*vp1*/"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Bar::"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - } + assertChange(changes, file, contents.indexOf("Bar/*vp1*/"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Bar::"), 3, "Ooga"); + } public void testNamespace_66_79282() throws Exception { StringWriter writer = new StringWriter(); - writer.write("namespace Foo/*vp1*/{} \n"); //$NON-NLS-1$ - writer.write("namespace Bar = Foo; \n"); //$NON-NLS-1$ - + writer.write("namespace Foo/*vp1*/{} \n"); + writer.write("namespace Bar = Foo; \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); // defect is Foo on line 2 is not renamed - int offset = contents.indexOf("Foo/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "Ooga"); //$NON-NLS-1$ + int offset = contents.indexOf("Foo/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "Ooga"); assertTotalChanges(2, changes); - assertChange(changes, file, contents.indexOf("Foo/*vp1*/"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("Foo;"), 3, "Ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, file, contents.indexOf("Foo/*vp1*/"), 3, "Ooga"); + assertChange(changes, file, contents.indexOf("Foo;"), 3, "Ooga"); } public void testFunction_67() throws Exception { StringWriter writer = new StringWriter(); - writer.write("void foo/*vp1*/(){}//rn1 \n"); //$NON-NLS-1$ - writer.write("void bar(){ \n"); //$NON-NLS-1$ - writer.write(" foo();//rn2 \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("namespace N{ \n"); //$NON-NLS-1$ - writer.write(" class A{ \n"); //$NON-NLS-1$ - writer.write(" A() {foo();}//rn3 \n"); //$NON-NLS-1$ - writer.write(" }; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("void foo/*vp1*/(){}//rn1 \n"); + writer.write("void bar(){ \n"); + writer.write(" foo();//rn2 \n"); + writer.write("} \n"); + writer.write("namespace N{ \n"); + writer.write(" class A{ \n"); + writer.write(" A() {foo();}//rn3 \n"); + writer.write(" }; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("foo/*vp1*/") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("foo/*vp1*/") ; + Change changes = getRefactorChanges(file, offset, "ooga"); assertTotalChanges(3, changes); - assertChange(changes, file, contents.indexOf("foo/*vp1*/"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("foo();//rn2"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("foo();}//rn3"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - } + assertChange(changes, file, contents.indexOf("foo/*vp1*/"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("foo();//rn2"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("foo();}//rn3"), 3, "ooga"); + } public void testVariable_68() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class A{ \n"); //$NON-NLS-1$ - writer.write(" public: int i; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("A var;//vp1,rn1 \n"); //$NON-NLS-1$ - writer.write("void f(){ \n"); //$NON-NLS-1$ - writer.write(" int j = ::var.i;//rn2 \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("class B{ \n"); //$NON-NLS-1$ - writer.write(" void g(){ \n"); //$NON-NLS-1$ - writer.write(" var.i=3;//rn3 \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - + writer.write("class A{ \n"); + writer.write(" public: int i; \n"); + writer.write("}; \n"); + writer.write("A var;//vp1,rn1 \n"); + writer.write("void f(){ \n"); + writer.write(" int j = ::var.i;//rn2 \n"); + writer.write("} \n"); + writer.write("class B{ \n"); + writer.write(" void g(){ \n"); + writer.write(" var.i=3;//rn3 \n"); + writer.write(" } \n"); + writer.write("}; \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("var;//vp1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("var;//vp1") ; + Change changes = getRefactorChanges(file, offset, "ooga"); assertTotalChanges(3, changes); - assertChange(changes, file, contents.indexOf("var;//vp1"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("var.i;//rn2"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - assertChange(changes, file, contents.indexOf("var.i=3;//rn3"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - } + assertChange(changes, file, contents.indexOf("var;//vp1"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("var.i;//rn2"), 3, "ooga"); + assertChange(changes, file, contents.indexOf("var.i=3;//rn3"), 3, "ooga"); + } public void testVariable_68_79295() throws Exception { StringWriter writer = new StringWriter(); - writer.write("int var;//vp1 \n"); //$NON-NLS-1$ - writer.write("void f(int var){ \n"); //$NON-NLS-1$ - writer.write(" int i = var; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - + writer.write("int var;//vp1 \n"); + writer.write("void f(int var){ \n"); + writer.write(" int i = var; \n"); + writer.write("} \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); //defect is the argument and local variable var are incorrectly renamed - int offset = contents.indexOf("var;//vp1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(file, offset, "ooga"); //$NON-NLS-1$ + int offset = contents.indexOf("var;//vp1") ; + Change changes = getRefactorChanges(file, offset, "ooga"); assertTotalChanges(1, changes); - assertChange(changes, file, contents.indexOf("var;//vp1"), 3, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ - } + assertChange(changes, file, contents.indexOf("var;//vp1"), 3, "ooga"); + } // similar to test 92, except this one will continue with warning, or error status // while case in 92 must stop refactor with fatal status public void testClass_81_72620() throws Exception { StringWriter writer = new StringWriter(); - writer.write("union u_haul{}; \n"); //$NON-NLS-1$ - writer.write("struct s_haul{}; \n"); //$NON-NLS-1$ + writer.write("union u_haul{}; \n"); + writer.write("struct s_haul{}; \n"); String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("s_haul") ; //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("s_haul") ; try { - getRefactorChanges(file, offset, "u_haul"); //$NON-NLS-1$ + getRefactorChanges(file, offset, "u_haul"); } catch (AssertionFailedError e) { - assertTrue(e.getMessage().startsWith("Input check on u_haul failed.")); //$NON-NLS-1$ + assertTrue(e.getMessage().startsWith("Input check on u_haul failed.")); return; } - fail ("An error should have occurred in the input check."); //$NON-NLS-1$ + fail ("An error should have occurred in the input check."); } public void testVariable_88_72617() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class A{}; \n"); //$NON-NLS-1$ - writer.write("A a;//vp1 \n"); //$NON-NLS-1$ + writer.write("class A{}; \n"); + writer.write("A a;//vp1 \n"); String header = writer.toString(); - IFile h = importFile("Foo.hh", header); //$NON-NLS-1$ + IFile h = importFile("Foo.hh", header); writer = new StringWriter(); - writer.write("#include \"Foo.hh\" \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" A a; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"Foo.hh\" \n"); + writer.write("void f() { \n"); + writer.write(" A a; \n"); + writer.write("} \n"); String source = writer.toString(); - importFile("Foo.cpp", source); //$NON-NLS-1$ - int offset = header.indexOf("a;//vp1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(h, offset, "ooga"); //$NON-NLS-1$ - + importFile("Foo.cpp", source); + int offset = header.indexOf("a;//vp1") ; + Change changes = getRefactorChanges(h, offset, "ooga"); + assertTotalChanges(1, changes); - assertChange(changes, h, header.indexOf("a;//vp1"), 1, "ooga"); //$NON-NLS-1$//$NON-NLS-2$ + assertChange(changes, h, header.indexOf("a;//vp1"), 1, "ooga"); } // Two ways to test name collision on same type: @@ -1237,51 +1237,51 @@ public class RenameRegressionTests extends RenameTestBase { // and getRefactorSeverity public void testClass_92A() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class Boo{}; \n"); //$NON-NLS-1$ - writer.write(" void f() {} \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("class Foo/*vp1*/{}; \n"); //$NON-NLS-1$ - + writer.write("class Boo{}; \n"); + writer.write(" void f() {} \n"); + writer.write("}; \n"); + writer.write("class Foo/*vp1*/{}; \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("Foo/*vp1*/") ; //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("Foo/*vp1*/") ; try { - getRefactorChanges(file, offset, "Boo"); //$NON-NLS-1$ + getRefactorChanges(file, offset, "Boo"); } catch (AssertionFailedError e) { - assertTrue(e.getMessage().startsWith("Input check on Boo failed.")); //$NON-NLS-1$ + assertTrue(e.getMessage().startsWith("Input check on Boo failed.")); return; } - fail ("An error or warning should have occurred in the input check."); //$NON-NLS-1$ + fail ("An error or warning should have occurred in the input check."); } public void testClass_92B() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class A{}; \n"); //$NON-NLS-1$ - writer.write("class B{};//vp1 \n"); //$NON-NLS-1$ - + writer.write("class A{}; \n"); + writer.write("class B{};//vp1 \n"); + String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("B{};//vp1") ; //$NON-NLS-1$ - - String[] messages = getRefactorMessages(file, offset, "A"); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("B{};//vp1") ; + + String[] messages = getRefactorMessages(file, offset, "A"); assertEquals(1, messages.length); assertEquals("A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: A \n" + - "Conflicting element type: Type", messages[0]); //$NON-NLS-1$ + "Conflicting element type: Type", messages[0]); // assert that you cannot refactor because severity is FATAL (4) - int s = getRefactorSeverity(file, offset, "A"); //$NON-NLS-1$ + int s = getRefactorSeverity(file, offset, "A"); assertEquals(RefactoringStatus.ERROR,s); } - + public void testRenameParticipant() throws Exception { TestRenameParticipant.reset(); StringWriter writer = new StringWriter(); - writer.write("class A{}; "); //$NON-NLS-1$ + writer.write("class A{}; "); String contents = writer.toString(); - IFile file = importFile("t.cpp", contents); //$NON-NLS-1$ - int offset = contents.indexOf("A") ; //$NON-NLS-1$ - getRefactorChanges(file, offset, "B"); //$NON-NLS-1$ + IFile file = importFile("t.cpp", contents); + int offset = contents.indexOf("A") ; + getRefactorChanges(file, offset, "B"); assertEquals(1, TestRenameParticipant.getConditionCheckCount()); assertEquals(1, TestRenameParticipant.getCreateChangeCount()); Object element= TestRenameParticipant.getElement(); @@ -1289,10 +1289,10 @@ public class RenameRegressionTests extends RenameTestBase { assertNotNull(element); assertTrue(element instanceof IBinding); IBinding binding= (IBinding) element; - assertEquals(binding.getName(), "A"); //$NON-NLS-1$ - + assertEquals(binding.getName(), "A"); + RenameArguments args= TestRenameParticipant.staticGetArguments(); assertNotNull(args); - assertEquals("B", args.getNewName()); //$NON-NLS-1$ + assertEquals("B", args.getNewName()); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java index 1ad2794de14..d10b0b758e0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.rename; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java index bdba4bf2b83..d4c62282096 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java @@ -34,2285 +34,2285 @@ public class RenameTypeTests extends RenameTestBase { } public static Test suite(boolean cleanup) { - TestSuite suite = new TestSuite(RenameTypeTests.class); + TestSuite suite = new TestSuite(RenameTypeTests.class); if (cleanup) { - suite.addTest(new RefactoringTests("cleanupProject")); //$NON-NLS-1$ + suite.addTest(new RefactoringTests("cleanupProject")); } return suite; } public void testClassNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("class v1 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("class v2 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("class v3 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("class v4 { \n"); //$NON-NLS-1$ - writer.write(" int function(); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("int v4::function(){} \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; v1::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3; v3::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("class v1 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("class v2 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("class v3 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("class v4 { \n"); + writer.write(" int function(); \n"); + writer.write("}; \n"); + writer.write("int v4::function(){} \n"); + writer.write("void f(int par1){ \n"); + writer.write(" { \n"); + writer.write(" int w1; v1::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; v2::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" { \n"); + writer.write(" int w3; v3::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - int offset4= contents.indexOf("v4"); //$NON-NLS-1$ - + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + int offset4= contents.indexOf("v4"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset1, "par1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "par2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "w3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "par3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringOk(status); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_def_ov"); assertRefactoringOk(status); // renamings colliding with types. // renamings colliding with types. - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset2, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ - assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset3, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "un_member"); + assertRefactoringOk(status); + + status= checkConditions(cpp, offset4, "class_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: class_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "struct_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: struct_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "union_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: union_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "class_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: class_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "struct_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: struct_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "union_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: union_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "enum_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: enum_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "typedef_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: typedef_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "namespace_def"); + assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: namespace_def \n" + + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset4, "st_member"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset4, "un_member"); assertRefactoringOk(status); } public void testNamespaceNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("namespace v4 { \n"); //$NON-NLS-1$ - writer.write(" int function(); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("namespace v1 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("namespace v2 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("namespace v3 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("int v4::function(){} \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; v1::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3; v3::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("namespace v4 { \n"); + writer.write(" int function(); \n"); + writer.write("}; \n"); + writer.write("namespace v1 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("namespace v2 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("namespace v3 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("int v4::function(){} \n"); + writer.write("void f(int par1){ \n"); + writer.write(" { \n"); + writer.write(" int w1; v1::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; v2::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" { \n"); + writer.write(" int w3; v3::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - int offset4= contents.indexOf("v4"); //$NON-NLS-1$ - + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + int offset4= contents.indexOf("v4"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "par1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "par2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "w3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "par3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringOk(status); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_def_ov"); assertRefactoringOk(status); // renamings colliding with types. - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset2, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ - assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset3, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "un_member"); + assertRefactoringOk(status); + + status= checkConditions(cpp, offset4, "class_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: class_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "struct_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: struct_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "union_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: union_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "class_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: class_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "struct_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: struct_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "union_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: union_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "enum_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: enum_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "typedef_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: typedef_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "namespace_def"); + assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: namespace_def \n" + + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset4, "st_member"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset4, "un_member"); assertRefactoringOk(status); } public void testStructNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("struct v4 { \n"); //$NON-NLS-1$ - writer.write(" int function(); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("struct v1 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("struct v2 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("struct v3 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("int v4::function(){} \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; v1::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3; v3::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("struct v4 { \n"); + writer.write(" int function(); \n"); + writer.write("}; \n"); + writer.write("struct v1 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("struct v2 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("struct v3 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("int v4::function(){} \n"); + writer.write("void f(int par1){ \n"); + writer.write(" { \n"); + writer.write(" int w1; v1::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; v2::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" { \n"); + writer.write(" int w3; v3::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + int offset4= contents.indexOf("v4"); - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - int offset4= contents.indexOf("v4"); //$NON-NLS-1$ - // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "par1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "par2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "w3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "par3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringOk(status); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_def_ov"); assertRefactoringOk(status); // renamings colliding with types. - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset2, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ - assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset3, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "un_member"); + assertRefactoringOk(status); + + status= checkConditions(cpp, offset4, "class_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: class_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "struct_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: struct_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "union_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: union_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "class_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: class_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "struct_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: struct_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "union_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: union_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "enum_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: enum_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "typedef_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: typedef_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "namespace_def"); + assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: namespace_def \n" + + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset4, "st_member"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset4, "un_member"); assertRefactoringOk(status); } public void testStructNameConflictsPlainC() throws Exception { - createCFwdDecls("c_fwd.h"); //$NON-NLS-1$ - createCDefs("c_def.h"); //$NON-NLS-1$ + createCFwdDecls("c_fwd.h"); + createCDefs("c_def.h"); StringWriter writer = new StringWriter(); - writer.write("#include \"c_fwd.h\" \n"); //$NON-NLS-1$ - writer.write("#include \"c_def.h\" \n"); //$NON-NLS-1$ - writer.write("struct v1 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("struct v2 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("struct v3 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; v1::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"c_fwd.h\" \n"); + writer.write("#include \"c_def.h\" \n"); + writer.write("struct v1 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("struct v2 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("struct v3 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" { \n"); + writer.write(" int w1; v1::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "par1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); // renamings colliding with types. - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); } public void testUnionNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("union v4 { \n"); //$NON-NLS-1$ - writer.write(" int function(); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("union v1 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("union v2 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("union v3 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("int v4::function(){} \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; v1::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3; v3::v++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("union v4 { \n"); + writer.write(" int function(); \n"); + writer.write("}; \n"); + writer.write("union v1 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("union v2 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("union v3 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("int v4::function(){} \n"); + writer.write("void f(int par1){ \n"); + writer.write(" { \n"); + writer.write(" int w1; v1::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; v2::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" { \n"); + writer.write(" int w3; v3::v++; \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - int offset4= contents.indexOf("v4"); //$NON-NLS-1$ - + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + int offset4= contents.indexOf("v4"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "par1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "par2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "w3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "par3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringOk(status); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset4, "func_def_ov"); assertRefactoringOk(status); // renamings colliding with types. - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset2, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ - assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ - assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + - "Type of problem: Redeclaration \n" + - "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset4, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset3, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset4, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "un_member"); + assertRefactoringOk(status); + + status= checkConditions(cpp, offset4, "class_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: class_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "struct_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: struct_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "union_fwd"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: union_fwd \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "class_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: class_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "struct_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: struct_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "union_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: union_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "enum_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: enum_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "typedef_def"); + assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: typedef_def \n" + + "Conflicting element type: Type"); + status= checkConditions(cpp, offset4, "namespace_def"); + assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + + "Type of problem: Redeclaration \n" + + "New element: namespace_def \n" + + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset4, "st_member"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset4, "un_member"); assertRefactoringOk(status); } public void testUnionNameConflictsPlainC() throws Exception { - createCFwdDecls("c_fwd.h"); //$NON-NLS-1$ - createCDefs("c_def.h"); //$NON-NLS-1$ + createCFwdDecls("c_fwd.h"); + createCDefs("c_def.h"); StringWriter writer = new StringWriter(); - writer.write("#include \"c_fwd.h\" \n"); //$NON-NLS-1$ - writer.write("#include \"c_def.h\" \n"); //$NON-NLS-1$ - writer.write("union v1 { \n"); //$NON-NLS-1$ - writer.write(" int v; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("union v1 vv1; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" int w1; vv1.v++; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"c_fwd.h\" \n"); + writer.write("#include \"c_def.h\" \n"); + writer.write("union v1 { \n"); + writer.write(" int v; \n"); + writer.write("}; \n"); + writer.write("union v1 vv1; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" int w1; vv1.v++; \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.c", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - + IFile cpp= importFile("test.c", contents); + + int offset1= contents.indexOf("v1"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "par1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); // renamings colliding with types. - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); } public void testEnumNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("enum v1 { \n"); //$NON-NLS-1$ - writer.write(" v11 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("enum v2 { \n"); //$NON-NLS-1$ - writer.write(" v22 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("enum v3 { \n"); //$NON-NLS-1$ - writer.write(" v33 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" int w1; v1 v; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2 v; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" int w3; v3 v; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("enum v1 { \n"); + writer.write(" v11 \n"); + writer.write("}; \n"); + writer.write("enum v2 { \n"); + writer.write(" v22 \n"); + writer.write("}; \n"); + writer.write("enum v3 { \n"); + writer.write(" v33 \n"); + writer.write("}; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" int w1; v1 v; \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" int w2; v2 v; \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" int w3; v3 v; \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "par1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "par2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "w3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "par3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringOk(status); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def_ov"); assertRefactoringOk(status); // renamings colliding with types. - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset2, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "un_member"); assertRefactoringOk(status); - - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ + + status= checkConditions(cpp, offset3, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset3, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "un_member"); assertRefactoringOk(status); } public void testEnumNameConflictsPlainC() throws Exception { - createCppFwdDecls("c_fwd.h"); //$NON-NLS-1$ - createCppDefs("c_def.h"); //$NON-NLS-1$ + createCppFwdDecls("c_fwd.h"); + createCppDefs("c_def.h"); StringWriter writer = new StringWriter(); - writer.write("#include \"c_fwd.h\" \n"); //$NON-NLS-1$ - writer.write("#include \"c_def.h\" \n"); //$NON-NLS-1$ - writer.write("enum v1 { \n"); //$NON-NLS-1$ - writer.write(" v11 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("enum v2 { \n"); //$NON-NLS-1$ - writer.write(" v22 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("enum v3 { \n"); //$NON-NLS-1$ - writer.write(" v33 \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" int w1; enum v1 v; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"c_fwd.h\" \n"); + writer.write("#include \"c_def.h\" \n"); + writer.write("enum v1 { \n"); + writer.write(" v11 \n"); + writer.write("}; \n"); + writer.write("enum v2 { \n"); + writer.write(" v22 \n"); + writer.write("}; \n"); + writer.write("enum v3 { \n"); + writer.write(" v33 \n"); + writer.write("}; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" int w1; enum v1 v; \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.c", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - + IFile cpp= importFile("test.c", contents); + + int offset1= contents.indexOf("v1"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "par1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); // renamings colliding with types. - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); } public void testTypedefNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("typedef int v1; \n"); //$NON-NLS-1$ - writer.write("typedef long v2; \n"); //$NON-NLS-1$ - writer.write("typedef struct {int a;} v3; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" int w1; v1 v; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2 v; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3; v3 v; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("typedef int v1; \n"); + writer.write("typedef long v2; \n"); + writer.write("typedef struct {int a;} v3; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" int w1; v1 v; \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; v2 v; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" { \n"); + writer.write(" int w3; v3 v; \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "par1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "par2"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "w3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "par3"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringOk(status); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def_ov"); assertRefactoringOk(status); // renamings colliding with types. - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset2, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "un_member"); assertRefactoringOk(status); - - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ + + status= checkConditions(cpp, offset3, "class_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: class_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset3, "namespace_def"); assertRefactoringWarning(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: namespace_def \n" + - "Conflicting element type: Namespace"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Namespace"); + status= checkConditions(cpp, offset3, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "un_member"); assertRefactoringOk(status); } - + public void testTypedefNameConflictsPlainC() throws Exception { - createCFwdDecls("c_fwd.h"); //$NON-NLS-1$ - createCDefs("c_def.h"); //$NON-NLS-1$ + createCFwdDecls("c_fwd.h"); + createCDefs("c_def.h"); StringWriter writer = new StringWriter(); - writer.write("#include \"c_fwd.h\" \n"); //$NON-NLS-1$ - writer.write("#include \"c_def.h\" \n"); //$NON-NLS-1$ - writer.write("typedef int v1; \n"); //$NON-NLS-1$ - writer.write("typedef long v2; \n"); //$NON-NLS-1$ - writer.write("typedef struct {int a;} v3; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" int w1; v1 v; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"c_fwd.h\" \n"); + writer.write("#include \"c_def.h\" \n"); + writer.write("typedef int v1; \n"); + writer.write("typedef long v2; \n"); + writer.write("typedef struct {int a;} v3; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" int w1; v1 v; \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.c", contents); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - + IFile cpp= importFile("test.c", contents); + + int offset1= contents.indexOf("v1"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "par1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); // renamings colliding with types. - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_fwd \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: struct_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: union_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: typedef_def \n" + - "Conflicting element type: Type"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + "Conflicting element type: Type"); + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); } public void testRenameClass() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class String \n"); //$NON-NLS-1$ - writer.write("{ \n"); //$NON-NLS-1$ - writer.write("public: \n"); //$NON-NLS-1$ - writer.write(" String(); \n"); //$NON-NLS-1$ - writer.write(" String(const String &other); \n"); //$NON-NLS-1$ - writer.write(" ~String(); \n"); //$NON-NLS-1$ - writer.write(" String &operator=(const String &other); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write(" String::String() {} \n"); //$NON-NLS-1$ - writer.write(" String::String(const String &other) {}; \n"); //$NON-NLS-1$ - writer.write(" String::~String() {}; \n"); //$NON-NLS-1$ - writer.write(" String& String::operator=(const String &other) \n"); //$NON-NLS-1$ - writer.write(" {return *this;} \n"); //$NON-NLS-1$ + writer.write("class String \n"); + writer.write("{ \n"); + writer.write("public: \n"); + writer.write(" String(); \n"); + writer.write(" String(const String &other); \n"); + writer.write(" ~String(); \n"); + writer.write(" String &operator=(const String &other); \n"); + writer.write("}; \n"); + writer.write(" String::String() {} \n"); + writer.write(" String::String(const String &other) {}; \n"); + writer.write(" String::~String() {}; \n"); + writer.write(" String& String::operator=(const String &other) \n"); + writer.write(" {return *this;} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset= contents.indexOf("String"); - int offset= contents.indexOf("String"); //$NON-NLS-1$ - // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset, "CString"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset, "CString"); assertRefactoringOk(status); - Change ch= getRefactorChanges(cpp, offset, "CString"); //$NON-NLS-1$ - assertTotalChanges(countOccurrences(contents, "String"), ch); //$NON-NLS-1$ + Change ch= getRefactorChanges(cpp, offset, "CString"); + assertTotalChanges(countOccurrences(contents, "String"), ch); } public void testUsingDeclaration_332895() throws Exception { StringWriter writer = new StringWriter(); - writer.write("namespace ns { \n"); //$NON-NLS-1$ - writer.write("typedef int MyType; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write(" \n"); //$NON-NLS-1$ - writer.write("using ns::MyType; \n"); //$NON-NLS-1$ - writer.write("MyType a; \n"); //$NON-NLS-1$ + writer.write("namespace ns { \n"); + writer.write("typedef int MyType; \n"); + writer.write("} \n"); + writer.write(" \n"); + writer.write("using ns::MyType; \n"); + writer.write("MyType a; \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); - int offset= contents.indexOf("MyType"); //$NON-NLS-1$ - - RefactoringStatus status= checkConditions(cpp, offset, "YourType"); //$NON-NLS-1$ + int offset= contents.indexOf("MyType"); + + RefactoringStatus status= checkConditions(cpp, offset, "YourType"); assertRefactoringOk(status); - Change ch= getRefactorChanges(cpp, offset, "YourType"); //$NON-NLS-1$ - assertTotalChanges(countOccurrences(contents, "MyType"), ch); //$NON-NLS-1$ + Change ch= getRefactorChanges(cpp, offset, "YourType"); + assertTotalChanges(countOccurrences(contents, "MyType"), ch); } public void testBug72888() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class MyEx {}; \n"); //$NON-NLS-1$ - writer.write("void someFunc() { \n"); //$NON-NLS-1$ - writer.write(" throw MyEx(); \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("int main(){ \n"); //$NON-NLS-1$ - writer.write(" try { \n"); //$NON-NLS-1$ - writer.write(" someFunc(); \n"); //$NON-NLS-1$ - writer.write(" } catch(MyEx &e) {} \n"); //$NON-NLS-1$ - writer.write(" return 0; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("class MyEx {}; \n"); + writer.write("void someFunc() { \n"); + writer.write(" throw MyEx(); \n"); + writer.write("}; \n"); + writer.write("int main(){ \n"); + writer.write(" try { \n"); + writer.write(" someFunc(); \n"); + writer.write(" } catch(MyEx &e) {} \n"); + writer.write(" return 0; \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents); //$NON-NLS-1$ - - int offset = contents.indexOf("MyEx") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(cpp, offset, "xx"); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset = contents.indexOf("MyEx") ; + Change changes = getRefactorChanges(cpp, offset, "xx"); assertTotalChanges(3, changes); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java index 2cf48501efc..6fbcee5dec4 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.rename; @@ -32,1970 +32,1970 @@ public class RenameVariableTests extends RenameTestBase { return suite(true); } - public static Test suite( boolean cleanup ) { - TestSuite suite = new TestSuite(RenameVariableTests.class); + public static Test suite(boolean cleanup) { + TestSuite suite = new TestSuite(RenameVariableTests.class); if (cleanup) { - suite.addTest( new RefactoringTests("cleanupProject") ); //$NON-NLS-1$ + suite.addTest(new RefactoringTests("cleanupProject")); } return suite; } - - public void testLocalNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ - StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("void f(int par1) { \n"); //$NON-NLS-1$ - writer.write(" int v1, x1; \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; v1++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" int v2; \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" int v3; \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3; v3++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - + public void testLocalNameConflicts() throws Exception { + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); + StringWriter writer = new StringWriter(); + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("void f(int par1) { \n"); + writer.write(" int v1, x1; \n"); + writer.write(" { \n"); + writer.write(" int w1; v1++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" int v2; \n"); + writer.write(" { \n"); + writer.write(" int w2; v2++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" int v3; \n"); + writer.write(" { \n"); + writer.write(" int w3; v3++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + String contents = writer.toString(); + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("w1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("w1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("x1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("x1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: v1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w2 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset2, "par2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par2 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "w3"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w3 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset3, "par3"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par3 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset3, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset3, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset3, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); // renamings depending on scope - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + "Conflicting element type: Method"); + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "Conflicting element type: Method"); // lookup inside a static method also returns non-static members // we may want to have a check whether a binding is accessible or not. - -// status= checkConditions(cpp, offset3, "member"); //$NON-NLS-1$ + +// status= checkConditions(cpp, offset3, "member"); // assertRefactoringOk(status); -// status= checkConditions(cpp, offset3, "method"); //$NON-NLS-1$ +// status= checkConditions(cpp, offset3, "method"); // assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "Conflicting element type: Method"); // renamings that are ok. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def_ov"); assertRefactoringOk(status); // renamings that are ok. - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset3, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "un_member"); assertRefactoringOk(status); } - - public void testLocalNameConflictsPlainC() throws Exception { - createCFwdDecls("c_fwd.h"); //$NON-NLS-1$ - createCDefs("c_def.h"); //$NON-NLS-1$ - StringWriter writer = new StringWriter(); - writer.write("#include \"c_fwd.h\" \n"); //$NON-NLS-1$ - writer.write("#include \"c_def.h\" \n"); //$NON-NLS-1$ - writer.write("void f(int par1) { \n"); //$NON-NLS-1$ - writer.write(" int v1, x1, w1; \n"); //$NON-NLS-1$ - writer.write(" w1++; v1++; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - String contents = writer.toString(); - IFile cpp= importFile("test.c", contents ); //$NON-NLS-1$ - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - + public void testLocalNameConflictsPlainC() throws Exception { + createCFwdDecls("c_fwd.h"); + createCDefs("c_def.h"); + StringWriter writer = new StringWriter(); + writer.write("#include \"c_fwd.h\" \n"); + writer.write("#include \"c_def.h\" \n"); + writer.write("void f(int par1) { \n"); + writer.write(" int v1, x1, w1; \n"); + writer.write(" w1++; v1++; \n"); + writer.write("} \n"); + String contents = writer.toString(); + IFile cpp= importFile("test.c", contents); + + int offset1= contents.indexOf("v1"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("w1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("w1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: v1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("x1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("x1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: v1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); // renamings that are ok. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); } public void testParameterNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("void f(int par1, int v1) {\n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; v1++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2, int v2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3, int v3) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3; v3++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("void f(int par1, int v1) {\n"); + writer.write(" { \n"); + writer.write(" int w1; v1++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2, int v2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; v2++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3, int v3) { \n"); + writer.write(" { \n"); + writer.write(" int w3; v3++; \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("w1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("w1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: v1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w2 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset2, "par2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: par2 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "w3"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w3 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset3, "par3"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: par3 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset3, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset3, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset3, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); // renamings depending on scope - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + "Conflicting element type: Method"); + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "Conflicting element type: Method"); // lookup inside a static method also returns non-static members // we may want to have a check whether a binding is accessible or not. - -// status= checkConditions(cpp, offset3, "member"); //$NON-NLS-1$ + +// status= checkConditions(cpp, offset3, "member"); // assertRefactoringOk(status); -// status= checkConditions(cpp, offset3, "method"); //$NON-NLS-1$ +// status= checkConditions(cpp, offset3, "method"); // assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "Conflicting element type: Method"); // renamings that are ok. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_def_ov"); assertRefactoringOk(status); // renamings that are ok. - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset3, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "un_member"); assertRefactoringOk(status); } - - public void testParameterNameConflictsPlainC() throws Exception { - createCFwdDecls("c_fwd.h"); //$NON-NLS-1$ - createCDefs("c_def.h"); //$NON-NLS-1$ - StringWriter writer = new StringWriter(); - writer.write("#include \"c_fwd.h\" \n"); //$NON-NLS-1$ - writer.write("#include \"c_def.h\" \n"); //$NON-NLS-1$ - writer.write("void f(int par1, int v1) {\n"); //$NON-NLS-1$ - writer.write(" int w1; v1++; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - String contents = writer.toString(); - IFile c= importFile("test.c", contents ); //$NON-NLS-1$ - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - + public void testParameterNameConflictsPlainC() throws Exception { + createCFwdDecls("c_fwd.h"); + createCDefs("c_def.h"); + StringWriter writer = new StringWriter(); + writer.write("#include \"c_fwd.h\" \n"); + writer.write("#include \"c_def.h\" \n"); + writer.write("void f(int par1, int v1) {\n"); + writer.write(" int w1; v1++; \n"); + writer.write("} \n"); + String contents = writer.toString(); + IFile c= importFile("test.c", contents); + + int offset1= contents.indexOf("v1"); + // conflicting renamings - RefactoringStatus status= checkConditions(c, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(c, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(c, contents.indexOf("w1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(c, contents.indexOf("w1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(c, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Parameter"); + status= checkConditions(c, contents.indexOf("par1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: v1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(c, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(c, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(c, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(c, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); // renamings that are ok. - status= checkConditions(c, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "func_proto_ov"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "func_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "func_def_ov"); assertRefactoringOk(status); // renamings that are ok. - status= checkConditions(c, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "struct_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "struct_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "union_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "union_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "enum_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "enum_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "st_member"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "un_member"); assertRefactoringOk(status); } public void testVaribleNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("int v1, v2, v3; \n"); //$NON-NLS-1$ - writer.write("static int s1; \n"); //$NON-NLS-1$ - writer.write("static int s2; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; v1++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3; v3++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("int v1, v2, v3; \n"); + writer.write("static int s1; \n"); + writer.write("static int s2; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" { \n"); + writer.write(" int w1; v1++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; v2++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" { \n"); + writer.write(" int w3; v3++; \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - + IFile cpp= importFile("test.cpp", contents); + writer = new StringWriter(); - writer.write( "static int static_other_file; \n" ); //$NON-NLS-1$ - importFile( "other.cpp", writer.toString() ); //$NON-NLS-1$ + writer.write("static int static_other_file; \n"); + importFile("other.cpp", writer.toString()); - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("w1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("w1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w2 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset2, "par2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par2 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "w3"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w3 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset3, "par3"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par3 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset3, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset3, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset3, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); // renamings depending on scope - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + "Conflicting element type: Method"); + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "Conflicting element type: Method"); // lookup inside a static method also returns non-static members // we may want to have a check whether a binding is accessible or not. - -// status= checkConditions(cpp, offset3, "member"); //$NON-NLS-1$ + +// status= checkConditions(cpp, offset3, "member"); // assertRefactoringOk(status); -// status= checkConditions(cpp, offset3, "method"); //$NON-NLS-1$ +// status= checkConditions(cpp, offset3, "method"); // assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "Conflicting element type: Method"); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); // would be good to see an error here - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); // would be good to see an error here - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_proto_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_def_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); // renamings that are ok. - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset3, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "un_member"); assertRefactoringOk(status); - + // file static stuff - status= checkConditions(cpp, contents.indexOf("s1"), "s2"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("s1"), "s2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: s2 \n" + - "Conflicting element type: File static variable"); //$NON-NLS-1$ + "Conflicting element type: File static variable"); - status= checkConditions(cpp, contents.indexOf("s1"), "static_other_file"); //$NON-NLS-1$ //$NON-NLS-2$ - assertRefactoringOk(status); + status= checkConditions(cpp, contents.indexOf("s1"), "static_other_file"); + assertRefactoringOk(status); } public void testVaribleNameConflictsPlainC() throws Exception { - createCFwdDecls("c_fwd.h"); //$NON-NLS-1$ - createCDefs("c_def.h"); //$NON-NLS-1$ + createCFwdDecls("c_fwd.h"); + createCDefs("c_def.h"); StringWriter writer = new StringWriter(); - writer.write("#include \"c_fwd.h\" \n"); //$NON-NLS-1$ - writer.write("#include \"c_def.h\" \n"); //$NON-NLS-1$ - writer.write("int v1; \n"); //$NON-NLS-1$ - writer.write("static int s1; \n"); //$NON-NLS-1$ - writer.write("static int s2; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" int w1; v1++; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"c_fwd.h\" \n"); + writer.write("#include \"c_def.h\" \n"); + writer.write("int v1; \n"); + writer.write("static int s1; \n"); + writer.write("static int s2; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" int w1; v1++; \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile c= importFile("test.c", contents ); //$NON-NLS-1$ - + IFile c= importFile("test.c", contents); + writer = new StringWriter(); - writer.write( "static int static_other_file; \n" ); //$NON-NLS-1$ - importFile( "other.c", writer.toString() ); //$NON-NLS-1$ + writer.write("static int static_other_file; \n"); + importFile("other.c", writer.toString()); - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - + int offset1= contents.indexOf("v1"); + // conflicting renamings - RefactoringStatus status= checkConditions(c, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(c, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(c, contents.indexOf("w1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(c, contents.indexOf("w1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(c, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Global variable"); + status= checkConditions(c, contents.indexOf("par1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(c, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(c, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(c, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(c, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); // renamings conflicting with global stuff. - status= checkConditions(c, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(c, offset1, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); // renamings that are ok. - status= checkConditions(c, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "struct_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "struct_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "union_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "union_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "enum_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "enum_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "st_member"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "un_member"); assertRefactoringOk(status); - + // file static stuff - status= checkConditions(c, contents.indexOf("s1"), "s2"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(c, contents.indexOf("s1"), "s2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: s2 \n" + - "Conflicting element type: File static variable"); //$NON-NLS-1$ + "Conflicting element type: File static variable"); - status= checkConditions(c, contents.indexOf("s1"), "static_other_file"); //$NON-NLS-1$ //$NON-NLS-2$ - assertRefactoringOk(status); + status= checkConditions(c, contents.indexOf("s1"), "static_other_file"); + assertRefactoringOk(status); } public void testEnumeratorNameConflicts() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("enum E {v1, v2, v3}; \n"); //$NON-NLS-1$ - writer.write("static int s1; \n"); //$NON-NLS-1$ - writer.write("static int s2; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1=v1; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2=v2; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3=v3; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("enum E {v1, v2, v3}; \n"); + writer.write("static int s1; \n"); + writer.write("static int s2; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" { \n"); + writer.write(" int w1=v1; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2=v2; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" { \n"); + writer.write(" int w3=v3; \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - + IFile cpp= importFile("test.cpp", contents); + writer = new StringWriter(); - writer.write( "static int static_other_file; \n" ); //$NON-NLS-1$ - importFile( "other.cpp", writer.toString() ); //$NON-NLS-1$ + writer.write("static int static_other_file; \n"); + importFile("other.cpp", writer.toString()); - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("w1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("w1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Enumerator"); + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); + status= checkConditions(cpp, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w2 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset2, "par2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par2 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "w3"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w3 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset3, "par3"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par3 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset3, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset3, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset3, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); // renamings depending on scope - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + "Conflicting element type: Method"); + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + "Conflicting element type: Method"); + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "Conflicting element type: Method"); // renamings conflicting with global stuff. - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); // would be good to see an error here - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); // would be good to see an error here - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_proto_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(cpp, offset3, "func_def_ov"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def_ov \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); // renamings that are ok. - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset1, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "class_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: class_def \n" + - "Conflicting element type: Constructor"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ + "Conflicting element type: Constructor"); + status= checkConditions(cpp, offset3, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "st_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "un_member"); assertRefactoringOk(status); - + // file static stuff - status= checkConditions(cpp, contents.indexOf("s1"), "s2"); //$NON-NLS-1$ //$NON-NLS-2$ + status= checkConditions(cpp, contents.indexOf("s1"), "s2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: s2 \n" + - "Conflicting element type: File static variable"); //$NON-NLS-1$ + "Conflicting element type: File static variable"); - status= checkConditions(cpp, contents.indexOf("s1"), "static_other_file"); //$NON-NLS-1$ //$NON-NLS-2$ - assertRefactoringOk(status); + status= checkConditions(cpp, contents.indexOf("s1"), "static_other_file"); + assertRefactoringOk(status); } public void testEnumeratorNameConflictsPlainC() throws Exception { - createCFwdDecls("c_fwd.h"); //$NON-NLS-1$ - createCDefs("c_def.h"); //$NON-NLS-1$ + createCFwdDecls("c_fwd.h"); + createCDefs("c_def.h"); StringWriter writer = new StringWriter(); - writer.write("#include \"c_fwd.h\" \n"); //$NON-NLS-1$ - writer.write("#include \"c_def.h\" \n"); //$NON-NLS-1$ - writer.write("enum E {v1, v2, v3}; \n"); //$NON-NLS-1$ - writer.write("static int s1; \n"); //$NON-NLS-1$ - writer.write("static int s2; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" int w1=v1; \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"c_fwd.h\" \n"); + writer.write("#include \"c_def.h\" \n"); + writer.write("enum E {v1, v2, v3}; \n"); + writer.write("static int s1; \n"); + writer.write("static int s2; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" int w1=v1; \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile c= importFile("test.c", contents ); //$NON-NLS-1$ - + IFile c= importFile("test.c", contents); + writer = new StringWriter(); - writer.write( "static int static_other_file; \n" ); //$NON-NLS-1$ - importFile( "other.cpp", writer.toString() ); //$NON-NLS-1$ + writer.write("static int static_other_file; \n"); + importFile("other.cpp", writer.toString()); - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - + int offset1= contents.indexOf("v1"); + // conflicting renamings - RefactoringStatus status= checkConditions(c, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(c, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(c, contents.indexOf("w1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(c, contents.indexOf("w1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ - status= checkConditions(c, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Enumerator"); + status= checkConditions(c, contents.indexOf("par1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); + status= checkConditions(c, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(c, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(c, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(c, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); // renamings conflicting with global stuff. - status= checkConditions(c, offset1, "func_proto"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "func_proto"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_proto \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ - status= checkConditions(c, offset1, "func_def"); //$NON-NLS-1$ + "Conflicting element type: Global function"); + status= checkConditions(c, offset1, "func_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: func_def \n" + - "Conflicting element type: Global function"); //$NON-NLS-1$ + "Conflicting element type: Global function"); - status= checkConditions(c, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "struct_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "struct_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "union_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "union_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "enum_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "enum_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "st_member"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "st_member"); assertRefactoringOk(status); - status= checkConditions(c, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(c, offset1, "un_member"); assertRefactoringOk(status); } public void testMemberNameConflicts1() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("class Dummy { \n"); //$NON-NLS-1$ - writer.write(" int v1, v2, v3; \n"); //$NON-NLS-1$ - writer.write(" int member; \n"); //$NON-NLS-1$ - writer.write(" int method(int); \n"); //$NON-NLS-1$ - writer.write(" static int static_method(int); \n"); //$NON-NLS-1$ - writer.write(" static int static_member; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("void Dummy::method(int par1) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; v1++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void Dummy::static_method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; v2++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("class Dummy { \n"); + writer.write(" int v1, v2, v3; \n"); + writer.write(" int member; \n"); + writer.write(" int method(int); \n"); + writer.write(" static int static_method(int); \n"); + writer.write(" static int static_member; \n"); + writer.write("}; \n"); + writer.write("void Dummy::method(int par1) { \n"); + writer.write(" { \n"); + writer.write(" int w1; v1++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void Dummy::static_method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; v2++; \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w1 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("w1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, contents.indexOf("w1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, contents.indexOf("par1"), "v1"); //$NON-NLS-1$ //$NON-NLS-2$ + "Conflicting element type: Field"); + status= checkConditions(cpp, contents.indexOf("par1"), "v1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: v1 \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset1, "par1"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par1 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset1, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "w2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: w2 \n" + - "Conflicting element type: Local variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ + "Conflicting element type: Local variable"); + status= checkConditions(cpp, offset2, "par2"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: par2 \n" + - "Conflicting element type: Parameter"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ + "Conflicting element type: Parameter"); + status= checkConditions(cpp, offset2, "extern_var"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: extern_var \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "var_def"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: var_def \n" + - "Conflicting element type: Global variable"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ + "Conflicting element type: Global variable"); + status= checkConditions(cpp, offset2, "enum_item"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Shadowing \n" + "New element: enum_item \n" + - "Conflicting element type: Enumerator"); //$NON-NLS-1$ + "Conflicting element type: Enumerator"); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ + "Conflicting element type: Method"); + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ + "Conflicting element type: Method"); + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: static_member \n" + - "Conflicting element type: Field"); //$NON-NLS-1$ - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ + "Conflicting element type: Field"); + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringError(status, "A conflict was encountered during refactoring. \n" + "Type of problem: Redeclaration \n" + "New element: static_method \n" + - "Conflicting element type: Method"); //$NON-NLS-1$ + "Conflicting element type: Method"); } public void testMemberNameConflicts2() throws Exception { - createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ - createCppDefs("cpp_def.hh"); //$NON-NLS-1$ + createCppFwdDecls("cpp_fwd.hh"); + createCppDefs("cpp_def.hh"); StringWriter writer = new StringWriter(); - writer.write("#include \"cpp_fwd.hh\" \n"); //$NON-NLS-1$ - writer.write("#include \"cpp_def.hh\" \n"); //$NON-NLS-1$ - writer.write("class Dummy { \n"); //$NON-NLS-1$ - writer.write(" int v1, v2, v3; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("Dummy d; \n"); //$NON-NLS-1$ - writer.write("void f(int par1){ \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w1; d.v1++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void class_def::method(int par2) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w2; d.v2++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("static void class_def::static_method(int par3) { \n"); //$NON-NLS-1$ - writer.write(" { \n"); //$NON-NLS-1$ - writer.write(" int w3; d.v3++; \n"); //$NON-NLS-1$ - writer.write(" } \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#include \"cpp_fwd.hh\" \n"); + writer.write("#include \"cpp_def.hh\" \n"); + writer.write("class Dummy { \n"); + writer.write(" int v1, v2, v3; \n"); + writer.write("}; \n"); + writer.write("Dummy d; \n"); + writer.write("void f(int par1){ \n"); + writer.write(" { \n"); + writer.write(" int w1; d.v1++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("void class_def::method(int par2) { \n"); + writer.write(" { \n"); + writer.write(" int w2; d.v2++; \n"); + writer.write(" } \n"); + writer.write("} \n"); + writer.write("static void class_def::static_method(int par3) { \n"); + writer.write(" { \n"); + writer.write(" int w3; d.v3++; \n"); + writer.write(" } \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1"); //$NON-NLS-1$ - int offset2= contents.indexOf("v2"); //$NON-NLS-1$ - int offset3= contents.indexOf("v3"); //$NON-NLS-1$ - + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1"); + int offset2= contents.indexOf("v2"); + int offset3= contents.indexOf("v3"); + // conflicting renamings - RefactoringStatus status= checkConditions(cpp, offset1, "w1"); //$NON-NLS-1$ + RefactoringStatus status= checkConditions(cpp, offset1, "w1"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "par1"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "par1"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "extern_var"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "var_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "enum_item"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "extern_var"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "var_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_item"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "w2"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "par2"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "extern_var"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "var_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_item"); //$NON-NLS-1$ - assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "w2"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "par2"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "extern_var"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "var_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "enum_item"); + assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "w3"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "par3"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "extern_var"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "var_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_item"); //$NON-NLS-1$ - assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "w3"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "par3"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "extern_var"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "var_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "enum_item"); + assertRefactoringOk(status); // renamings depending on scope - status= checkConditions(cpp, offset1, "member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "static_method"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "method"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "static_method"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "static_method"); //$NON-NLS-1$ - assertRefactoringOk(status); - - status= checkConditions(cpp, offset1, "func_proto"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_proto_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "func_def_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_proto_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "func_def_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_proto_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "func_def_ov"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "class_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "struct_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "union_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "enum_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "typedef_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "namespace_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "st_member"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset1, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "static_method"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "class_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "struct_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset1, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_proto_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "func_def_ov"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto"); assertRefactoringOk(status); - status= checkConditions(cpp, offset2, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset3, "func_proto_ov"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "func_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "func_def_ov"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "class_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "struct_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "union_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "class_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "struct_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "union_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "enum_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "typedef_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "namespace_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "st_member"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset1, "un_member"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "struct_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "struct_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_fwd"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_fwd"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "class_def"); //$NON-NLS-1$ - assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "struct_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "class_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "union_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "struct_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "enum_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "union_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "typedef_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "enum_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "namespace_def"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "typedef_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "st_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "namespace_def"); assertRefactoringOk(status); - status= checkConditions(cpp, offset3, "un_member"); //$NON-NLS-1$ + status= checkConditions(cpp, offset2, "st_member"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset2, "un_member"); + assertRefactoringOk(status); + + status= checkConditions(cpp, offset3, "class_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "struct_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "union_fwd"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "class_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "struct_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "union_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "enum_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "typedef_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "namespace_def"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "st_member"); + assertRefactoringOk(status); + status= checkConditions(cpp, offset3, "un_member"); assertRefactoringOk(status); } - + public void testReferenceViaMacro() throws Exception { StringWriter writer = new StringWriter(); - writer.write("#define PASSON(x) (x) \n"); //$NON-NLS-1$ - writer.write("#define INC(x) PASSON(/*pc*/x)++ \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" int v1; \n"); //$NON-NLS-1$ - writer.write(" INC(/*comment*/ v1); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#define PASSON(x) (x) \n"); + writer.write("#define INC(x) PASSON(/*pc*/x)++ \n"); + writer.write("void f() { \n"); + writer.write(" int v1; \n"); + writer.write(" INC(/*comment*/ v1); \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - - int offset = contents.indexOf("v1") ; //$NON-NLS-1$ - int offset2= contents.indexOf("v1", offset+1) ; //$NON-NLS-1$ - Change changes = getRefactorChanges(cpp, offset2, "z"); //$NON-NLS-1$ - assertTotalChanges( 2, changes ); - assertChange( changes, cpp, offset, 2, "z" ); //$NON-NLS-1$ - assertChange( changes, cpp, offset2, 2, "z" ); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset = contents.indexOf("v1") ; + int offset2= contents.indexOf("v1", offset + 1) ; + Change changes = getRefactorChanges(cpp, offset2, "z"); + assertTotalChanges(2, changes); + assertChange(changes, cpp, offset, 2, "z"); + assertChange(changes, cpp, offset2, 2, "z"); } public void testReferenceViaMacro2() throws Exception { StringWriter writer = new StringWriter(); - writer.write("#define INC(x,y) x+=y \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" int v1,v2; \n"); //$NON-NLS-1$ - writer.write(" INC(v2,v1); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#define INC(x,y) x+=y \n"); + writer.write("void f() { \n"); + writer.write(" int v1,v2; \n"); + writer.write(" INC(v2,v1); \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - - int offset = contents.indexOf("v1") ; //$NON-NLS-1$ - int offset2= contents.indexOf("v1", offset+1) ; //$NON-NLS-1$ - Change changes = getRefactorChanges(cpp, offset2, "z"); //$NON-NLS-1$ - assertTotalChanges( 2, changes ); - assertChange( changes, cpp, offset, 2, "z" ); //$NON-NLS-1$ - assertChange( changes, cpp, offset2, 2, "z" ); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset = contents.indexOf("v1") ; + int offset2= contents.indexOf("v1", offset + 1) ; + Change changes = getRefactorChanges(cpp, offset2, "z"); + assertTotalChanges(2, changes); + assertChange(changes, cpp, offset, 2, "z"); + assertChange(changes, cpp, offset2, 2, "z"); } public void testReferenceViaMacro3() throws Exception { StringWriter writer = new StringWriter(); - writer.write("#define INC(x,y) x+=y \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" int v1,v2; \n"); //$NON-NLS-1$ - writer.write(" INC(v1,v1); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#define INC(x,y) x+=y \n"); + writer.write("void f() { \n"); + writer.write(" int v1,v2; \n"); + writer.write(" INC(v1,v1); \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - - int offset = contents.indexOf("v1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(cpp, offset, "z"); //$NON-NLS-1$ - assertTotalChanges( 3, changes ); - assertChange( changes, cpp, offset, 2, "z" ); //$NON-NLS-1$ - offset= contents.indexOf("v1", offset+1) ; //$NON-NLS-1$ - assertChange( changes, cpp, offset, 2, "z" ); //$NON-NLS-1$ - offset= contents.indexOf("v1", offset+1) ; //$NON-NLS-1$ - assertChange( changes, cpp, offset, 2, "z" ); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset = contents.indexOf("v1") ; + Change changes = getRefactorChanges(cpp, offset, "z"); + assertTotalChanges(3, changes); + assertChange(changes, cpp, offset, 2, "z"); + offset= contents.indexOf("v1", offset + 1) ; + assertChange(changes, cpp, offset, 2, "z"); + offset= contents.indexOf("v1", offset + 1) ; + assertChange(changes, cpp, offset, 2, "z"); } public void testReferenceViaMacro4() throws Exception { StringWriter writer = new StringWriter(); - writer.write("#define INC(x) v2++ \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" int v1; \n"); //$NON-NLS-1$ - writer.write(" INC(v1); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#define INC(x) v2++ \n"); + writer.write("void f() { \n"); + writer.write(" int v1; \n"); + writer.write(" INC(v1); \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - - int offset = contents.indexOf("v1") ; //$NON-NLS-1$ - Change changes = getRefactorChanges(cpp, offset, "z"); //$NON-NLS-1$ - assertTotalChanges( 1, 1, 0, changes ); - assertChange( changes, cpp, offset, 2, "z" ); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset = contents.indexOf("v1") ; + Change changes = getRefactorChanges(cpp, offset, "z"); + assertTotalChanges(1, 1, 0, changes); + assertChange(changes, cpp, offset, 2, "z"); } public void testReferenceViaMacro5() throws Exception { StringWriter writer = new StringWriter(); - writer.write("#define INC(x) v1++ \n"); //$NON-NLS-1$ - writer.write("void f() { \n"); //$NON-NLS-1$ - writer.write(" int v1,v2; \n"); //$NON-NLS-1$ - writer.write(" INC(v2); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ - writer.write("void f2() { \n"); //$NON-NLS-1$ - writer.write(" int v12; \n"); //$NON-NLS-1$ - writer.write(" INC(v12); \n"); //$NON-NLS-1$ - writer.write("} \n"); //$NON-NLS-1$ + writer.write("#define INC(x) v1++ \n"); + writer.write("void f() { \n"); + writer.write(" int v1,v2; \n"); + writer.write(" INC(v2); \n"); + writer.write("} \n"); + writer.write("void f2() { \n"); + writer.write(" int v12; \n"); + writer.write(" INC(v12); \n"); + writer.write("} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - - int offset1= contents.indexOf("v1") ; //$NON-NLS-1$ - int offset2= contents.indexOf("v1", offset1+1) ; //$NON-NLS-1$ - Change changes = getRefactorChanges(cpp, offset2, "z"); //$NON-NLS-1$ - assertTotalChanges( 2, changes ); - assertChange( changes, cpp, offset1, 2, "z" ); //$NON-NLS-1$ - assertChange( changes, cpp, offset2, 2, "z" ); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset1= contents.indexOf("v1") ; + int offset2= contents.indexOf("v1", offset1 + 1) ; + Change changes = getRefactorChanges(cpp, offset2, "z"); + assertTotalChanges(2, changes); + assertChange(changes, cpp, offset1, 2, "z"); + assertChange(changes, cpp, offset2, 2, "z"); } - + public void testBug72646() throws Exception { StringWriter writer = new StringWriter(); - writer.write("class C2: public C1 { \n"); //$NON-NLS-1$ - writer.write(" C2(int x, int y); \n"); //$NON-NLS-1$ - writer.write(" int y; \n"); //$NON-NLS-1$ - writer.write("}; \n"); //$NON-NLS-1$ - writer.write("C2::C2(int x, int y) \n"); //$NON-NLS-1$ - writer.write(" :C1(x), y(y) {} \n"); //$NON-NLS-1$ + writer.write("class C2: public C1 { \n"); + writer.write(" C2(int x, int y); \n"); + writer.write(" int y; \n"); + writer.write("}; \n"); + writer.write("C2::C2(int x, int y) \n"); + writer.write(" :C1(x), y(y) {} \n"); String contents = writer.toString(); - IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$ - - int offset = contents.indexOf("y") ; //$NON-NLS-1$ - offset= contents.indexOf("y", offset+1) ; //$NON-NLS-1$ - Change changes = getRefactorChanges(cpp, offset, "z"); //$NON-NLS-1$ - assertTotalChanges( 2, changes ); - assertChange( changes, cpp, offset, 1, "z" ); //$NON-NLS-1$ - offset= contents.indexOf("y", offset+1) ; //$NON-NLS-1$ - offset= contents.indexOf("y", offset+1) ; //$NON-NLS-1$ - assertChange( changes, cpp, offset, 1, "z" ); //$NON-NLS-1$ + IFile cpp= importFile("test.cpp", contents); + + int offset = contents.indexOf("y") ; + offset= contents.indexOf("y", offset + 1) ; + Change changes = getRefactorChanges(cpp, offset, "z"); + assertTotalChanges(2, changes); + assertChange(changes, cpp, offset, 1, "z"); + offset= contents.indexOf("y", offset + 1) ; + offset= contents.indexOf("y", offset + 1) ; + assertChange(changes, cpp, offset, 1, "z"); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/TestRenameParticipant.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/TestRenameParticipant.java index 5ad7cfecb86..8b6ffda8f41 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/TestRenameParticipant.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/TestRenameParticipant.java @@ -56,11 +56,12 @@ public class TestRenameParticipant extends RenameParticipant { @Override public String getName() { - return "TestRenameParticipant"; //$NON-NLS-1$ + return "TestRenameParticipant"; } @Override - public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException { + public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) + throws OperationCanceledException { sConditionCheck++; sArguments= getArguments(); return new RefactoringStatus(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java index 07a56aa5bc8..c0bec58f65e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java @@ -33,7 +33,7 @@ public class CRenameClassProcessor extends CRenameTypeProcessor { protected IBinding[] getBindingsToBeRenamed(RefactoringStatus status) { CRefactoringArgument argument= getArgument(); IBinding binding= argument.getBinding(); - ArrayList bindings= new ArrayList(); + ArrayList bindings= new ArrayList<>(); if (binding != null) { bindings.add(binding); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java index dee0b02c1ea..3ff2b50d578 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java @@ -33,6 +33,7 @@ import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper; */ public class CRenameLocalProcessor extends CRenameProcessorDelegate { private IScope fScope; + public CRenameLocalProcessor(CRenameProcessor input, String kind, IScope scope) { super(input, kind); fScope= scope; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java index 2548a03142f..e1f24fee771 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java @@ -100,7 +100,7 @@ public class CRenameMethodProcessor extends CRenameGlobalProcessor { CRefactoringArgument argument= getArgument(); IBinding binding= argument.getBinding(); - ArrayList bindings= new ArrayList(); + ArrayList bindings= new ArrayList<>(); if (binding != null) { bindings.add(binding); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java index 58b995452c2..66246e36426 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java @@ -1380,7 +1380,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { sourceName = NewSourceFileGenerator.generateSourceFileNameFromClass(className); testName = NewSourceFileGenerator.generateTestFileNameFromClass(className); } else { - // make sure the file names are unique + // Make sure the file names are unique. String currName = className; int count = 0; String separator = ""; //$NON-NLS-1$ @@ -1399,7 +1399,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage { headerName = header; sourceName = source; testName = test; - // we're done + // We're done. break; } }