1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Automatic formatting of code affected by refactoring.

This commit is contained in:
Sergey Prigogin 2011-11-07 11:00:43 -08:00
parent 65673a50e1
commit afb3fae823
90 changed files with 5152 additions and 5765 deletions

View file

@ -74,7 +74,8 @@ public class ASTWriterTest extends RewriteBaseTest {
for (String fileName : testResourceFiles.keySet()) {
TestSourceFile testFile = testResourceFiles.get(fileName);
String code = generateSource(testFile);
assertEquals(TestHelper.unifyNewLines(testFile.getExpectedSource()), TestHelper.unifyNewLines(code + System.getProperty("line.separator"))); //$NON-NLS-1$
assertEquals(TestHelper.unifyNewLines(testFile.getExpectedSource()),
TestHelper.unifyNewLines(code + System.getProperty("line.separator"))); //$NON-NLS-1$
}
}

View file

@ -88,11 +88,11 @@ public class SourceRewriteTester extends TestSuite {
}
private static ArrayList<RewriteBaseTest> createTests(BufferedReader inputReader) throws Exception {
String line;
ASTWriterTestSourceFile file = null;
MatcherState matcherState = MatcherState.skip;
ArrayList<RewriteBaseTest> testCases = new ArrayList<RewriteBaseTest>();
String line;
while ((line = inputReader.readLine()) != null) {
if (lineMatchesBeginOfTest(line)) {
matcherState = MatcherState.inTest;

View file

@ -13,12 +13,12 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
@ -29,26 +29,26 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTParameterDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
/**
* @author Emanuel Graf IFS
*
*/
public class AddDeclarationBug extends ChangeGeneratorTest {
AddDeclarationBug() {
super("AddDeclarationBug");
}
public AddDeclarationBug() {
super("Add Declaration Bug Test");
public static Test suite() {
return new AddDeclarationBug();
}
@Override
protected void setUp() throws Exception {
source = "class A\n{\npublic:\n A();\n virtual ~A();\n int foo();\n \nprivate:\n int help();\n};"; //$NON-NLS-1$
expectedSource = "class A\n{\npublic:\n A();\n virtual ~A();\n int foo();\n \nprivate:\n int help();\n int exp(int i);\n};"; //$NON-NLS-1$
expectedSource = "class A\n{\npublic:\n A();\n virtual ~A();\n int foo();\n \nprivate:\n int help();\n\tint exp(int i);\n};"; //$NON-NLS-1$
super.setUp();
}
@ -84,8 +84,4 @@ public class AddDeclarationBug extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new AddDeclarationBug();
}
}

View file

@ -13,22 +13,27 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class ArrayModifierTest extends ChangeGeneratorTest {
public ArrayModifierTest(){
super("Replace Array Modifier"); //$NON-NLS-1$
ArrayModifierTest() {
super("ArrayModifierTest");
}
public static Test suite() {
return new ArrayModifierTest();
}
@Override
@ -39,8 +44,7 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclarators = true;
@ -53,7 +57,8 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
IASTArrayModifier[] modifiers = arrayDeclarator.getArrayModifiers();
IASTArrayModifier newModifier = new CPPASTArrayModifier();
IASTExpression expr = new CPPASTLiteralExpression(0, "5"); //$NON-NLS-1$
IASTExpression expr =
new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, "5".toCharArray()); //$NON-NLS-1$
newModifier.setConstantExpression(expr);
ASTModification modification = new ASTModification(ModificationKind.INSERT_BEFORE, modifiers[0], newModifier, null);
modStore.storeModification(null, modification);
@ -62,8 +67,4 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new ArrayModifierTest();
}
}

View file

@ -13,11 +13,12 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTArrayModifier;
@ -25,12 +26,14 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class ArraySizeExpressionTest extends ChangeGeneratorTest {
public ArraySizeExpressionTest(){
super("Insert Array Size Expression"); //$NON-NLS-1$
ArraySizeExpressionTest() {
super("ArraySizeExpressionTest");
}
public static Test suite() {
return new ArraySizeExpressionTest();
}
@Override
@ -40,10 +43,8 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitExpressions = true;
@ -56,7 +57,8 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
IASTTypeId id= newExpression.getTypeId();
IASTArrayDeclarator dtor= (IASTArrayDeclarator) id.getAbstractDeclarator();
IASTArrayModifier[] mods= dtor.getArrayModifiers();
IASTArrayModifier add= new CPPASTArrayModifier(new CPPASTLiteralExpression(0, "6"));
IASTArrayModifier add= new CPPASTArrayModifier(
new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, "6".toCharArray()));
ASTModification modification = new ASTModification(ASTModification.ModificationKind.INSERT_BEFORE, mods[0], add, null);
modStore.storeModification(null, modification);
}
@ -64,9 +66,4 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new ArraySizeExpressionTest();
}
}

View file

@ -13,8 +13,8 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTConstructorChainInitializer;
@ -22,25 +22,28 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class CtorChainInitializerTest extends ChangeGeneratorTest {
public CtorChainInitializerTest(){
super("Insert Before Ctor Initializer"); //$NON-NLS-1$
CtorChainInitializerTest() {
super("CtorChainInitializerTest");
}
public static Test suite() {
return new CtorChainInitializerTest();
}
@Override
protected void setUp() throws Exception {
source = "TestClass::TestClass(int a, int b):beta(b) {\n}\n\n"; //$NON-NLS-1$
expectedSource = "TestClass::TestClass(int a, int b):alpha(a), beta(b){\n}\n\n"; //$NON-NLS-1$
expectedSource = "TestClass::TestClass(int a, int b) :\n\t\talpha(a), beta(b) {\n}\n\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclarators = true;
@ -63,9 +66,4 @@ public class CtorChainInitializerTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new CtorChainInitializerTest();
}
}

View file

@ -13,10 +13,10 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
@ -24,13 +24,17 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class ExceptionTest extends ChangeGeneratorTest {
public ExceptionTest(){
super("Insert Before Exception Declaration"); //$NON-NLS-1$
ExceptionTest() {
super("ExceptionTest");
}
public static Test suite() {
return new ExceptionTest();
}
@Override
@ -41,8 +45,7 @@ public class ExceptionTest extends ChangeGeneratorTest {
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclarators = true;
@ -69,9 +72,4 @@ public class ExceptionTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new ExceptionTest();
}
}

View file

@ -13,10 +13,10 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
@ -25,14 +25,14 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class ExpressionTest extends ChangeGeneratorTest {
public ExpressionTest(){
super("Insert Expression"); //$NON-NLS-1$
ExpressionTest() {
super("ExpressionTest");
}
public static Test suite() {
return new ExpressionTest();
}
@Override
@ -43,8 +43,7 @@ public class ExpressionTest extends ChangeGeneratorTest {
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitExpressions = true;
@ -63,9 +62,4 @@ public class ExpressionTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new ExpressionTest();
}
}

View file

@ -13,10 +13,10 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
@ -24,17 +24,17 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTParameterDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class FirstParameterTest extends ChangeGeneratorTest {
public FirstParameterTest(){
super("Insert Before First Parameter"); //$NON-NLS-1$
FirstParameterTest() {
super("FirstParameterTest");
}
public static Test suite() {
return new FirstParameterTest();
}
@Override
@ -44,10 +44,8 @@ public class FirstParameterTest extends ChangeGeneratorTest {
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclarators = true;
@ -77,9 +75,4 @@ public class FirstParameterTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new FirstParameterTest();
}
}

View file

@ -16,12 +16,11 @@ import junit.framework.TestSuite;
/**
* @author Thomas Corbat
*
*/
public class InsertBeforeTestSuite {
public static Test suite() throws Exception {
TestSuite suite = new TestSuite("Changegenerator InsertBefore Tests");
TestSuite suite = new TestSuite("ChangeGenerator InsertBefore Tests");
suite.addTest(FirstParameterTest.suite());
suite.addTest(PointerParameterTest.suite());

View file

@ -13,44 +13,38 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class MultilineWhitespaceHandlingTest extends ChangeGeneratorTest {
public MultilineWhitespaceHandlingTest(){
super("Multiline Whitespace Handling"); //$NON-NLS-1$
}
@Override
protected void setUp() throws Exception {
source = "void foo(){\r\n\r\n for(int i = 0; i < 10; i++){\r\n\r\n }\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "void foo(){\r\n\r\n for(int i = 0; i < 10; i++){\r\n int i;\r\n int j;\r\n\r\n }\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
MultilineWhitespaceHandlingTest() {
super("MultilineWhitespaceHandlingTest");
}
public static Test suite() {
return new MultilineWhitespaceHandlingTest();
}
@Override
protected void setUp() throws Exception {
source = "void foo() {\r\n\r\n\tfor(int i = 0; i < 10; i++) {\r\n\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "void foo() {\r\n\r\n\tfor(int i = 0; i < 10; i++) {\r\n\t\tint i;\r\n\t\tint j;\r\n\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitStatements = true;

View file

@ -13,21 +13,25 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.insertbefore;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTPointer;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class PointerParameterTest extends ChangeGeneratorTest {
public PointerParameterTest(){
super("Insert Pointer for Parameter"); //$NON-NLS-1$
PointerParameterTest() {
super("PointerParameterTest");
}
public static Test suite() {
return new PointerParameterTest();
}
@Override
@ -38,8 +42,7 @@ public class PointerParameterTest extends ChangeGeneratorTest {
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclarators = true;
@ -63,9 +66,4 @@ public class PointerParameterTest extends ChangeGeneratorTest {
}
};
}
public static Test suite() {
return new PointerParameterTest();
}
}

View file

@ -21,31 +21,25 @@ import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGenerator
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class SelfInsertionTest extends ChangeGeneratorTest {
public SelfInsertionTest(){
super("Self Insertion Test"); //$NON-NLS-1$
}
@Override
protected void setUp() throws Exception {
source = "void foo(){\r\n\r\n for(int i = 0; i < 10; i++){\r\n }\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "void foo(){\r\n\r\n for(int i = 0; i < 10; i++){\r\n for(int i = 0;i < 10;i++){\r\n }\r\n }\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
SelfInsertionTest() {
super("SelfInsertionTest");
}
public static Test suite() {
return new SelfInsertionTest();
}
@Override
protected void setUp() throws Exception {
source = "void foo() {\r\n\r\n\tfor (int i = 0; i < 10; i++) {\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "void foo() {\r\n\r\n\tfor (int i = 0; i < 10; i++) {\r\n\t\tfor (int i = 0; i < 10; i++) {\r\n\t\t}\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitStatements = true;

View file

@ -13,10 +13,10 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier;
@ -25,32 +25,25 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class MoveRenameTest extends ChangeGeneratorTest {
public MoveRenameTest(){
super("Swap Rename Declarations"); //$NON-NLS-1$
MoveRenameTest() {
super("MoveRenameTest");
}
@Override
protected void setUp() throws Exception {
source = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n int b;\r\n int a;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
expectedSource = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n int d;\r\n int b;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
super.setUp();
}
public static Test suite() {
return new MoveRenameTest();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected void setUp() throws Exception {
source = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n\tint b;\r\n\tint a;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
expectedSource = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n\tint d;\r\n\tint b;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclSpecifiers = true;
@ -70,8 +63,6 @@ public class MoveRenameTest extends ChangeGeneratorTest {
}
return super.visit(declSpec);
}
};
}
}

View file

@ -13,40 +13,34 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class MoveTest extends ChangeGeneratorTest {
public MoveTest(){
super("Swap Declarations"); //$NON-NLS-1$
}
@Override
protected void setUp() throws Exception {
source = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n int b;\r\n int a;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
expectedSource = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n int a;\r\n int b;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
super.setUp();
MoveTest() {
super("MoveTest");
}
public static Test suite() {
return new MoveTest();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected void setUp() throws Exception {
source = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n\tint b;\r\n\tint a;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
expectedSource = "#ifndef A_H_\r\n#define A_H_\r\n\r\nclass A {\r\n\r\nprivate:\r\n\tint a;\r\n\tint b;\r\n};\r\n\r\n#endif /*A_H_*/\r\n\r\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitDeclSpecifiers = true;
@ -64,8 +58,6 @@ public class MoveTest extends ChangeGeneratorTest {
}
return super.visit(declSpec);
}
};
}
}

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
@ -20,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionStatement;
@ -33,43 +33,37 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class ReplaceInsertStatementTest extends ChangeGeneratorTest {
public ReplaceInsertStatementTest() {
ReplaceInsertStatementTest() {
super("ReplaceInsertStatementTest");
}
@Override
protected void setUp() throws Exception {
source = "void main(){\r\n int i = 0;\r\n ++i;\r\n}"; //$NON-NLS-1$
expectedSource = "void main(){\r\n int i = 0;\r\n i = 42;\r\n i++;\r\n}"; //$NON-NLS-1$
super.setUp();
}
public static Test suite() {
return new ReplaceInsertStatementTest();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest#createModificator(org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore)
*/
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected void setUp() throws Exception {
source = "void main() {\r\n\tint i = 0;\r\n\t++i;\r\n}"; //$NON-NLS-1$
expectedSource = "void main() {\r\n\tint i = 0;\r\n\ti = 42;\r\n\ti++;\r\n}"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitStatements = true;
}
@Override
public int visit(IASTStatement statement) {
if (statement instanceof IASTCompoundStatement) {
IASTCompoundStatement compStmt = (IASTCompoundStatement) statement;
IASTStatement stmt = compStmt.getStatements()[1];
IASTIdExpression id = new CPPASTIdExpression(
new CPPASTName("i".toCharArray()));
IASTIdExpression id = new CPPASTIdExpression(new CPPASTName("i".toCharArray()));
IASTLiteralExpression value = new CPPASTLiteralExpression(
IASTLiteralExpression.lk_integer_constant, "42");
IASTLiteralExpression.lk_integer_constant, "42".toCharArray());
IASTExpressionStatement insertStmt = new CPPASTExpressionStatement(
new CPPASTBinaryExpression(
IASTBinaryExpression.op_assign, id, value));
@ -82,15 +76,12 @@ public class ReplaceInsertStatementTest extends ChangeGeneratorTest {
incExp);
ASTModification replaceMod = new ASTModification(
ASTModification.ModificationKind.REPLACE, stmt,
replaceStatement, null);
ASTModification.ModificationKind.REPLACE, stmt, replaceStatement, null);
modStore.storeModification(null, replaceMod);
ASTModification insertMod = new ASTModification(
ASTModification.ModificationKind.INSERT_BEFORE,
stmt, insertStmt, null);
ASTModification.ModificationKind.INSERT_BEFORE, stmt, insertStmt, null);
modStore.storeModification(null, insertMod);
}
return PROCESS_CONTINUE;

View file

@ -13,10 +13,10 @@ package org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.replace;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.parser.tests.rewrite.changegenerator.ChangeGeneratorTest;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionStatement;
@ -26,31 +26,25 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTUnaryExpression;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
public class StatementTest extends ChangeGeneratorTest {
public StatementTest(){
super("Replace Then-Statement"); //$NON-NLS-1$
}
@Override
protected void setUp() throws Exception {
source = "int f()\r\n{\r\n\tint i = 0;\r\n\tif(i < 1){\r\n\t\t++i;\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "int f()\r\n{\r\n\tint i = 0;\r\n\tif(i < 1){\r\n\t i++;\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
StatementTest() {
super("StatementTest");
}
public static Test suite() {
return new StatementTest();
}
@Override
protected void setUp() throws Exception {
source = "int f()\r\n{\r\n\tint i = 0;\r\n\tif (i < 1) {\r\n\t\t++i;\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
expectedSource = "int f()\r\n{\r\n\tint i = 0;\r\n\tif (i < 1) {\r\n\t\ti++;\r\n\t}\r\n}\r\n"; //$NON-NLS-1$
super.setUp();
}
@Override
protected ASTVisitor createModificator(
final ASTModificationStore modStore) {
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
return new ASTVisitor() {
{
shouldVisitStatements = true;

View file

@ -16,6 +16,7 @@ typedef int *intp;
extern int b;
//Test6
static int c;
//Test7
int foo()
{

View file

@ -76,42 +76,51 @@ extern "C" typedef void FUNC(); /*TEST 2*/
//!Commented NamespaceAlias 1
//%CPP
//TEST 1
namespace kurz = ziemlichlangernamespace; //TEST 2
namespace kurz = somenamespace; //TEST 2
//!Commented NamespaceAlias 2
//%CPP
/*TEST 1*/
namespace kurz = ziemlichlangernamespace; /*TEST 2*/
namespace kurz = somenamespace; /*TEST 2*/
//!Commented NamespaceDefinition 1
//%CPP
//TEST 1
namespace ziemlichlangernamespace
namespace namespace1
{
//TEST 2
} //TEST 3
//!Commented NamespaceDefinition 2
//%CPP
/*TEST 1*/
namespace ziemlichlangernamespace
namespace namespace2
{
/*TEST 2*/
} /*TEST 3*/
//!Commented NamespaceDefinition 3
//%CPP
namespace ziemlichlangernamespace
namespace namespace3
{
//TEST
}
//!Commented NamespaceDefinition 4
//%CPP
namespace ziemlichlangernamespace
namespace namespace4
{
//TEST
}
void doIt()
{
int i = 0;
@ -158,6 +167,7 @@ template<> class MyQueue<double> //TEST 2
{
//TEST 3
std::vector<double> data;
public:
void Add(const double&);
void Remove();
@ -173,6 +183,7 @@ template<> class MyQueue<double> /*TEST 2*/
{
/*TEST 3*/
std::vector<double> data;
public:
void Add(const double&);
void Remove();
@ -214,9 +225,11 @@ class A
//TEST 1
public: //TEST 2
int hallo();
/*TEST 3*/
protected: /*TEST 4*/
int b, c;
private:
int p;
};
@ -231,12 +244,12 @@ int i = 2; //TEST 2
/*TEST 1*/
int i = 2; /*TEST 2*/
//!Commented typename qualfier 1
//!Commented typename qualifier 1
//%CPP
//TEST 1
typename T::A* a6; //TEST 2
//!Commented typename qualfier 2
//!Commented typename qualifier 2
//%CPP
/*TEST 1*/
typename T::A* a6; /*TEST 2*/

View file

@ -29,6 +29,7 @@ void foo()
//!Commented CPPFunctionDeclaratorTest 1
//%CPP
char& operator [](unsigned int);
//TEST 1
TestClass::TestClass(int a) //TEST 2
{
@ -39,6 +40,7 @@ TestClass::TestClass(int a) //TEST 2
//!Commented CPPFunctionDeclaratorTest 2
//%CPP
char& operator [](unsigned int);
/*TEST 1*/
TestClass::TestClass(int a) /*TEST 2*/
{
@ -49,6 +51,7 @@ TestClass::TestClass(int a) /*TEST 2*/
//!Commented CPPFunctionDeclaratorTest 3
//%CPP
char& operator [](unsigned int);
//TEST 1
TestClass::TestClass(int a)
:alpha(a) //TEST 2
@ -60,6 +63,7 @@ TestClass::TestClass(int a)
//!Commented CPPFunctionDeclaratorTest 4
//%CPP
char& operator [](unsigned int);
/*TEST 1*/
TestClass::TestClass(int a)
:alpha(a) /*TEST 3*/

View file

@ -1,6 +1,7 @@
//!Commented TemplateFunction1
//%CPP
template<typename T> int tempFunct(T p)
template<typename T>
int tempFunct(T p)
{
++p;
//Kommentar
@ -12,7 +13,8 @@ template<typename T> int tempFunct(T p)
//!Commented TemplateFunction2
//%CPP
//Kommentar
template<typename T> int tempFunct(T p)
template<typename T>
int tempFunct(T p)
{
++p;
p + 4;
@ -22,7 +24,8 @@ template<typename T> int tempFunct(T p)
//!Commented TemplateFunction3
//%CPP
template<typename T> int tempFunct(T p)
template<typename T>
int tempFunct(T p)
{
++p;
p + 4;

View file

@ -10,6 +10,7 @@ volatile int b = 3;
typedef int* intp;
extern int b;
static int c;
int foo()
{
int i = 1;

View file

@ -32,12 +32,14 @@ extern "C" typedef void FUNC();
//!NamespaceAlias
//%CPP
namespace kurz = ziemlichlangernamespace;
namespace kurz = somenamespace;
//!NamespaceDefinition
//%CPP
namespace ziemlichlangernamespace
namespace somenamespace
{
}
//!TemplateDeclaration
@ -58,6 +60,7 @@ template<typename T> class MyQueue;
template<> class MyQueue<double>
{
std::vector<double> data;
public:
void Add(const double&);
void Remove();
@ -92,9 +95,11 @@ using namespace B;
class A
{
public:
int hallo();
int hello();
protected:
int b, c;
private:
int p;
};
@ -104,7 +109,7 @@ private:
//Comment
int i = 2;
//!typename qualfier
//!Typename qualifier
//%CPP
typename T::A* a6;

View file

@ -4,6 +4,7 @@ int sd;
int* ip;
int hs = 1;
char& c;
void foo()
{
struct B
@ -56,6 +57,7 @@ class TestClass
TestClass(int a);
virtual void pure() = 0;
};
TestClass::TestClass(int a)
:alpha(a)
{
@ -72,9 +74,11 @@ class C
{
int i;
double d;
public:
C(int, double);
};
C::C(int ii, double id)
try
:i(f(ii)), d(id)

View file

@ -33,6 +33,7 @@ int i = 1 | x;
bool b = 1 && x;
bool b = 1 || x;
int i = x;
void foo()
{
i *= x;

View file

@ -4,7 +4,8 @@ T *p1 = p->template alloc<100>();
//![temp.names] examples abschnitt 4/2, didn't work cause of Bug# 164482
//%CPP
template<class T> void f(T *p)
template<class T>
void f(T* p)
{
T::template adjust<100>();
}

View file

@ -148,6 +148,7 @@ class Klasse0
public:
Klasse0(); //Comment
std::string toString();
private:
int i;
};
@ -170,6 +171,7 @@ class Klasse0
public:
Klasse1();
std::string toString();
private:
int i;
};
@ -182,6 +184,7 @@ class Klasse0
public:
Klasse1();
std::string toString();
private:
int i;
}; = //Comment1
@ -2779,26 +2782,26 @@ int foo = bar; = //Zweiteilig
//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
//@Klasse1.h
//TEST 1
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST 2
} //TEST 3
//=
=>leading
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST 2
} = //TEST 1
=>trailing
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST 2
} = //TEST 3
=>freestanding
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST 2
} = //TEST 2
@ -2807,7 +2810,7 @@ namespace ziemlichlangernamespace
//!CommentRecognition215 - von ASTWriter NamesapceDefinition
//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
//@Klasse1.h
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST
}
@ -2822,7 +2825,7 @@ void doIt(){
=>trailing
=>freestanding
namespace ziemlichlangernamespace
namespace somenamespace
{
//TEST
} = //TEST
@ -2830,7 +2833,7 @@ namespace ziemlichlangernamespace
//!CommentRecognition216 - von ASTWriter NamesapceDefinition
//#org.eclipse.cdt.core.parser.tests.rewrite.comenthandler.CommentHandlingTest
//@Klasse1.h
namespace ziemlichlangernamespace
namespace somenamespace
{
int i = 0;
//TEST
@ -2846,7 +2849,7 @@ void doIt(){
=>trailing
=>freestanding
namespace ziemlichlangernamespace
namespace somenamespace
{
int i = 0;
//TEST

View file

@ -8,10 +8,19 @@
*
* Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.changegenerator.ChangeGeneratorWriterVisitor;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.ASTCommenter;
@ -19,9 +28,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/**
* ASTWriter main class. Generates source code from <code>IASTNode</code>.
* Uses a <code>hangeGeneratorWriterVisitor</code> to generate the code for the given nodes.
*
* @see ChangeGeneratorWriterVisitor
* Uses a {@link ChangeGeneratorWriterVisitor} to generate the code for the given nodes.
*
* @author Emanuel Graf
*/
@ -54,18 +61,13 @@ public class ASTWriter {
* @throws ProblemRuntimeException if the node or one of it's children is a <code>IASTProblemNode</code>.
*/
public String write(IASTNode rootNode) throws ProblemRuntimeException {
return write(rootNode, null, new NodeCommentMap());
}
public String write(IASTNode rootNode, NodeCommentMap commentMap) {
return write(rootNode, null, commentMap);
return write(rootNode, new NodeCommentMap());
}
/**
* Generates the source code representing this node including comments.
*
* @param rootNode Node to write.
* @param fileScope
* @param commentMap Node Comment Map <code>ASTCommenter</code>
* @return A <code>String</code> representing the source code for the node.
* @throws ProblemRuntimeException if the node or one of it's children is
@ -73,17 +75,95 @@ public class ASTWriter {
*
* @see ASTCommenter#getCommentedNodeMap(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
*/
public String write(IASTNode rootNode, String fileScope, NodeCommentMap commentMap)
public String write(IASTNode rootNode, NodeCommentMap commentMap)
throws ProblemRuntimeException {
ChangeGeneratorWriterVisitor transformationVisitor = new ChangeGeneratorWriterVisitor(
modificationStore, givenIndentation, fileScope, commentMap);
ChangeGeneratorWriterVisitor writer = new ChangeGeneratorWriterVisitor(
modificationStore, givenIndentation, null, commentMap);
if (rootNode != null) {
rootNode.accept(transformationVisitor);
rootNode.accept(writer);
}
return transformationVisitor.toString();
return writer.toString();
}
public void setModificationStore(ASTModificationStore modificationStore) {
this.modificationStore = modificationStore;
}
/**
* Returns <code>true</code> if the node should be separated by a blank line from the node
* before it.
*
* @param node The node.
* @return <code>true</code> if the node should be separated by a blank line from the node
* before it.
*/
public static boolean requiresLeadingBlankLine(IASTNode node) {
if (node instanceof ICPPASTTemplateDeclaration) {
node = ((ICPPASTTemplateDeclaration) node).getDeclaration();
}
return node instanceof IASTASMDeclaration ||
node instanceof IASTFunctionDefinition ||
node instanceof ICPPASTVisibilityLabel;
}
/**
* Returns <code>true</code> if the node should be separated by a blank line from the node
* after it.
*
* @param node The node.
* @return <code>true</code> if the node should be separated by a blank line from the node
* after it.
*/
public static boolean requiresTrailingBlankLine(IASTNode node) {
if (node instanceof ICPPASTNamespaceDefinition)
return true;
if (node instanceof IASTFunctionDefinition)
return true;
if (node instanceof IASTIfStatement) {
IASTIfStatement statement = ((IASTIfStatement) node);
IASTStatement lastClause = statement.getElseClause();
if (lastClause == null)
lastClause = statement.getThenClause();
if (!(lastClause instanceof IASTCompoundStatement) &&
!doNodesHaveSameOffset(lastClause, statement)) {
return true;
}
}
return false;
}
/**
* Returns <code>true</code> if there should be no blank line after this node even if a blank
* line is normally required before the subsequent node.
*
* @param node The node.
* @return <code>true</code> if there should be no blank line after this node.
*/
public static boolean suppressesTrailingBlankLine(IASTNode node) {
return node instanceof ICPPASTVisibilityLabel;
}
/**
* Returns <code>true</code> if the two given nodes should be separated by a blank line.
*
* @param node1 The first node.
* @param node2 The second node.
* @return <code>true</code> if the blank line between the nodes is needed.
*/
public static boolean requireBlankLineInBetween(IASTNode node1, IASTNode node2) {
if (requiresTrailingBlankLine(node1))
return true;
return !suppressesTrailingBlankLine(node1) && requiresLeadingBlankLine(node2);
}
/**
* Returns true if the two given nodes have the same offset. For nodes that are normally
* separated by other tokens this is an indication that they were produced by the same macro
* expansion.
*/
private static boolean doNodesHaveSameOffset(IASTNode node1, IASTNode node2) {
return node1.getFileLocation().getNodeOffset() == node2.getFileLocation().getNodeOffset();
}
}

View file

@ -9,6 +9,7 @@
* Contributors:
* Institute for Software - initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@ -38,15 +39,14 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/**
* Visits all nodes, prints leading comments and handles macro expansions. The
* source code generation is delegated to severals <code>NodeWriters</code>.
* source code generation is delegated to severals {@code NodeWriter}s.
*
* @see NodeWriter
* @see MacroExpansionHandler
*
* @author Emanuel Graf IFS
*/
public class ASTWriterVisitor extends ASTVisitor {
protected Scribe scribe = new Scribe();
protected final Scribe scribe = new Scribe();
protected NodeCommentMap commentMap;
protected ExpressionWriter expWriter;
protected DeclSpecWriter declSpecWriter;
@ -57,6 +57,9 @@ public class ASTWriterVisitor extends ASTVisitor {
protected NameWriter nameWriter;
protected TemplateParameterWriter tempParameterWriter;
protected MacroExpansionHandler macroHandler;
private boolean insertLeadingBlankLine;
private boolean suppressLeadingBlankLine;
private boolean spaceNeededBeforeName;
{
shouldVisitExpressions = true;
@ -83,6 +86,7 @@ public class ASTWriterVisitor extends ASTVisitor {
scribe.setGivenIndentation(givenIndentation);
init(commentMap);
this.commentMap = commentMap;
this.suppressLeadingBlankLine = true;
}
private void init(NodeCommentMap commentMap) {
@ -135,6 +139,10 @@ public class ASTWriterVisitor extends ASTVisitor {
@Override
public int visit(IASTName name) {
if (spaceNeededBeforeName && name.getSimpleID().length != 0) {
scribe.printSpace();
spaceNeededBeforeName = false;
}
writeLeadingComments(name);
if (!macroHandler.checkisMacroExpansionNode(name)) {
nameWriter.writeName(name);
@ -166,7 +174,9 @@ public class ASTWriterVisitor extends ASTVisitor {
@Override
public int visit(IASTStatement statement) {
insertBlankLineIfNeeded(statement);
writeLeadingComments(statement);
try {
if (macroHandler.isStatementWithMixedLocation(statement) &&
!(statement instanceof IASTCompoundStatement)) {
return statementWriter.writeMixedStatement(statement);
@ -175,13 +185,18 @@ public class ASTWriterVisitor extends ASTVisitor {
return ASTVisitor.PROCESS_SKIP;
}
return statementWriter.writeStatement(statement, true);
} finally {
setLeadingBlankLineFlags(statement);
}
}
@Override
public int visit(IASTDeclaration declaration) {
insertBlankLineIfNeeded(declaration);
writeLeadingComments(declaration);
if (!macroHandler.checkisMacroExpansionNode(declaration)) {
declarationWriter.writeDeclaration(declaration);
setLeadingBlankLineFlags(declaration);
}
return ASTVisitor.PROCESS_SKIP;
}
@ -219,9 +234,7 @@ public class ASTWriterVisitor extends ASTVisitor {
parameterDeclaration.getDeclSpecifier().accept(this);
IASTDeclarator declarator = getParameterDeclarator(parameterDeclaration);
if (getParameterName(declarator).toString().length() != 0) {
scribe.printSpaces(1);
}
spaceNeededBeforeName = true;
declarator.accept(this);
}
return ASTVisitor.PROCESS_SKIP;
@ -237,9 +250,11 @@ public class ASTWriterVisitor extends ASTVisitor {
@Override
public int visit(ICPPASTNamespaceDefinition namespace) {
insertBlankLineIfNeeded(namespace);
writeLeadingComments(namespace);
if (!macroHandler.checkisMacroExpansionNode(namespace)) {
declarationWriter.writeDeclaration(namespace);
setLeadingBlankLineFlags(namespace);
}
return ASTVisitor.PROCESS_SKIP;
}
@ -257,4 +272,38 @@ public class ASTWriterVisitor extends ASTVisitor {
scribe.cleanCache();
macroHandler.reset();
}
private void insertBlankLineIfNeeded(IASTNode node) {
if (!suppressLeadingBlankLine &&
(insertLeadingBlankLine || ASTWriter.requiresLeadingBlankLine(node))) {
scribe.newLine();
}
insertLeadingBlankLine = false;
suppressLeadingBlankLine = false;
}
private void setLeadingBlankLineFlags(IASTNode node) {
insertLeadingBlankLine = ASTWriter.requiresTrailingBlankLine(node);
suppressLeadingBlankLine = ASTWriter.suppressesTrailingBlankLine(node);
}
public boolean isSuppressLeadingBlankLine() {
return suppressLeadingBlankLine;
}
public void setSuppressLeadingBlankLine(boolean value) {
this.suppressLeadingBlankLine = value;
}
public boolean isSpaceNeededBeforeName() {
return spaceNeededBeforeName;
}
public void setSpaceNeededBeforeName(boolean value) {
this.spaceNeededBeforeName = value;
}
public void newLine() {
scribe.newLine();
}
}

View file

@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@ -62,7 +61,7 @@ public class DeclSpecWriter extends NodeWriter {
private static final String ENUM = "enum "; //$NON-NLS-1$
private static final String _BOOL = "_Bool"; //$NON-NLS-1$
public DeclSpecWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
public DeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
@ -129,7 +128,6 @@ public class DeclSpecWriter extends NodeWriter {
break;
}
System.err.println("Unknown specifier type: " + type); //$NON-NLS-1$
throw new IllegalArgumentException("Unknown specifier type: " + type); //$NON-NLS-1$
}
@ -179,8 +177,7 @@ public class DeclSpecWriter extends NodeWriter {
return CLASS_SPACE;
default:
System.err.println("Unknown ElaboratedType: " + kind); //$NON-NLS-1$
throw new IllegalArgumentException("Unknown ElaboratedType: " + kind); //$NON-NLS-1$
throw new IllegalArgumentException("Unknown elaborated type: " + kind); //$NON-NLS-1$
}
}
@ -260,6 +257,7 @@ public class DeclSpecWriter extends NodeWriter {
scribe.print('{');
scribe.newLine();
scribe.incrementIndentationLevel();
visitor.setSuppressLeadingBlankLine(true);
IASTDeclaration[] decls = getMembers(compDeclSpec);
if (decls.length > 0) {
@ -306,8 +304,7 @@ public class DeclSpecWriter extends NodeWriter {
case ICPPASTCompositeTypeSpecifier.k_class:
return CLASS;
default:
System.err.println("Unknow Specifiertype: " + key); //$NON-NLS-1$
throw new IllegalArgumentException("Unknow Specifiertype: " + key); //$NON-NLS-1$
throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
}
}
@ -318,8 +315,7 @@ public class DeclSpecWriter extends NodeWriter {
case IASTCompositeTypeSpecifier.k_union:
return UNION;
default:
System.err.println("Unknow Specifiertype: " + key); //$NON-NLS-1$
throw new IllegalArgumentException("Unknow Specifiertype: " + key); //$NON-NLS-1$
throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
}
}

View file

@ -9,10 +9,10 @@
* Contributors:
* Institute for Software - initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@ -57,7 +57,7 @@ public class DeclarationWriter extends NodeWriter{
private static final String USING = "using "; //$NON-NLS-1$
private boolean printSemicolon;
public DeclarationWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
public DeclarationWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
@ -72,6 +72,7 @@ public class DeclarationWriter extends NodeWriter{
writeASMDeclatation((IASTASMDeclaration) declaration);
} else if (declaration instanceof IASTFunctionDefinition) {
writeFunctionDefinition((IASTFunctionDefinition) declaration);
addNewLine = false;
} else if (declaration instanceof IASTProblemDeclaration) {
throw new ProblemRuntimeException((IASTProblemDeclaration) declaration);
} else if (declaration instanceof IASTSimpleDeclaration) {
@ -98,17 +99,17 @@ public class DeclarationWriter extends NodeWriter{
}
if (hasTrailingComments(declaration)) {
writeTrailingComments(declaration, addNewLine);
} else if (addNewLine) {
writeTrailingComments(declaration, false);
}
if (addNewLine) {
scribe.newLine();
}
if (hasFreestandingComments(declaration)) {
writeFreeStandingComments(declaration);
}
if (declaration instanceof ICPPASTUsingDirective) {
if (declaration instanceof IASTFunctionDefinition) {
scribe.newLine();
}
writeFreeStandingComments(declaration);
}
}
private void writeVisibilityLabel(ICPPASTVisibilityLabel visiblityLabel) {
@ -181,13 +182,14 @@ public class DeclarationWriter extends NodeWriter{
if (!hasTrailingComments(namespaceDefinition.getName())) {
scribe.newLine();
}
scribe.printLBrace();
scribe.newLine();
scribe.print('{');
scribe.newLine(2);
writeDeclarationsInNamespace(namespaceDefinition, namespaceDefinition.getDeclarations());
if (hasFreestandingComments(namespaceDefinition)) {
writeFreeStandingComments(namespaceDefinition);
}
scribe.printRBrace();
scribe.newLine();
scribe.print('}');
if (hasTrailingComments(namespaceDefinition)) {
writeTrailingComments(namespaceDefinition);
@ -266,10 +268,10 @@ public class DeclarationWriter extends NodeWriter{
if (declSpecifier instanceof IASTSimpleDeclSpecifier) {
IASTSimpleDeclSpecifier simDeclSpec = (IASTSimpleDeclSpecifier) declSpecifier;
if (simDeclSpec.getType() != IASTSimpleDeclSpecifier.t_unspecified) {
scribe.printSpace();
visitor.setSpaceNeededBeforeName(true);
}
} else {
scribe.printSpace();
visitor.setSpaceNeededBeforeName(true);
}
IASTDeclarator declarator = ASTQueries.findOutermostDeclarator(funcDef.getDeclarator());
declarator.accept(visitor);
@ -325,11 +327,17 @@ public class DeclarationWriter extends NodeWriter{
}
if (decls.length > 0) {
if (decls.length == 1) {
if (!noSpace)
visitor.setSpaceNeededBeforeName(true);
decls[0].accept(visitor);
} else {
if (!noSpace) {
scribe.printSpace();
}
writeNodeList(decls);
}
}
printSemicolon();
}

View file

@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@ -40,14 +39,12 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
* @author Emanuel Graf IFS
*/
public class DeclaratorWriter extends NodeWriter {
private static final String AMPERSAND_SPACE = "& "; //$NON-NLS-1$
private static final String AMPERSAND_AMPERSAND_SPACE = "&& "; //$NON-NLS-1$
private static final String STAR_SPACE = "* "; //$NON-NLS-1$
private static final String AMPERSAND_AMPERSAND = "&&"; //$NON-NLS-1$
private static final String PURE_VIRTUAL = " = 0"; //$NON-NLS-1$
private static final String MUTABLE = "mutable"; //$NON-NLS-1$
private static final String ARROW_OPERATOR = "->"; //$NON-NLS-1$
public DeclaratorWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
public DeclaratorWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}
@ -64,6 +61,7 @@ public class DeclaratorWriter extends NodeWriter {
writeDefaultDeclarator(declarator);
}
visitor.setSpaceNeededBeforeName(false);
if (hasTrailingComments(declarator)) {
writeTrailingComments(declarator, false);
}
@ -119,6 +117,10 @@ public class DeclaratorWriter extends NodeWriter {
private void writeNestedDeclarator(IASTDeclarator funcDec) {
IASTDeclarator nestedDeclarator = funcDec.getNestedDeclarator();
if (nestedDeclarator != null) {
if (visitor.isSpaceNeededBeforeName()) {
scribe.printSpace();
visitor.setSpaceNeededBeforeName(false);
}
scribe.print('(');
nestedDeclarator.accept(visitor);
scribe.print(')');
@ -160,10 +162,10 @@ public class DeclaratorWriter extends NodeWriter {
}
}
protected void writeParameterDeclarations(IASTStandardFunctionDeclarator funcDec, IASTParameterDeclaration[] paraDecls) {
writeNodeList(paraDecls);
protected void writeParameterDeclarations(IASTStandardFunctionDeclarator funcDec, IASTParameterDeclaration[] paramDecls) {
writeNodeList(paramDecls);
if (funcDec.takesVarArgs()) {
if (paraDecls.length > 0) {
if (paramDecls.length > 0) {
scribe.print(COMMA_SPACE);
}
scribe.print(VAR_ARGS);
@ -175,7 +177,7 @@ public class DeclaratorWriter extends NodeWriter {
ICPPASTPointerToMember pointerToMemberOp = (ICPPASTPointerToMember) operator;
if (pointerToMemberOp.getName() != null) {
pointerToMemberOp.getName().accept(visitor);
scribe.print(STAR_SPACE);
scribe.print('*');
}
} else {
scribe.print('*');
@ -198,9 +200,9 @@ public class DeclaratorWriter extends NodeWriter {
writePointer(pointOp);
} else if (operator instanceof ICPPASTReferenceOperator) {
if (((ICPPASTReferenceOperator) operator).isRValueReference()) {
scribe.print(AMPERSAND_AMPERSAND_SPACE);
scribe.print(AMPERSAND_AMPERSAND);
} else {
scribe.print(AMPERSAND_SPACE);
scribe.print('&');
}
}
}

View file

@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
@ -115,7 +114,7 @@ public class ExpressionWriter extends NodeWriter{
private static final String THIS = "this"; //$NON-NLS-1$
private final MacroExpansionHandler macroHandler;
public ExpressionWriter(Scribe scribe, ASTVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) {
public ExpressionWriter(Scribe scribe, ASTWriterVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
this.macroHandler = macroHandler;
}

View file

@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
@ -36,7 +35,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
*/
public class InitializerWriter extends NodeWriter{
public InitializerWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
public InitializerWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}

View file

@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -36,7 +35,7 @@ public class NameWriter extends NodeWriter {
* @param scribe
* @param visitor
*/
public NameWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
public NameWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import java.util.ArrayList;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTCopyLocation;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -28,7 +27,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
*/
public class NodeWriter {
protected Scribe scribe;
protected ASTVisitor visitor;
protected ASTWriterVisitor visitor;
protected NodeCommentMap commentMap;
protected static final String COMMA_SPACE = ", "; //$NON-NLS-1$
protected static final String EQUALS = " = "; //$NON-NLS-1$
@ -61,7 +60,7 @@ public class NodeWriter {
protected static final String COLON_COLON = "::"; //$NON-NLS-1$
protected static final String COLON_SPACE = ": "; //$NON-NLS-1$
public NodeWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
public NodeWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super();
this.scribe = scribe;
this.visitor = visitor;
@ -89,12 +88,17 @@ public class NodeWriter {
}
protected void writeTrailingComments(IASTNode node, boolean newLine) {
boolean first = true;
for (IASTComment comment : getTrailingComments(node)) {
scribe.printSpace();
scribe.print(comment.getComment());
if (newLine) {
if (!first) {
scribe.newLine();
}
scribe.printSpace();
scribe.print(comment.getComment());
first = false;
}
if (newLine) {
scribe.newLine();
}
}

View file

@ -20,17 +20,18 @@ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
*/
public class Scribe {
private int indentationLevel = 0;
private int indentationSize = 4; //HSR tcorbat: could be a tab character too - this is not a very elegant solution
// Any positive indentation size is good enough since the code is going to be formatted anyway.
private int indentationSize = 4;
private StringBuilder buffer = new StringBuilder();
private boolean isAtLineBeginning = true;
private String newLine = System.getProperty("line.separator"); //$NON-NLS-1$
private String givenIndentation = null;
private String givenIndentation;
private boolean noNewLine = false;
private boolean noSemicolon = false;
private boolean skipLineBreaks;
private boolean skipSemicolons;
public void newLine() {
if (!noNewLine) {
if (!skipLineBreaks) {
isAtLineBeginning = true;
buffer.append(getNewline());
}
@ -88,15 +89,15 @@ public class Scribe {
}
public void noSemicolon() {
noSemicolon = true;
skipSemicolons = true;
}
public void printSemicolon() {
if (!noSemicolon) {
if (!skipSemicolons) {
indentIfNewLine();
buffer.append(';');
} else {
noSemicolon = false;
skipSemicolons = false;
}
}
@ -126,7 +127,7 @@ public class Scribe {
}
/**
* Prints a { to the Buffer an increases the indentation level.
* Prints a { to the buffer an increases the indentation level.
*/
public void printLBrace() {
print('{');
@ -134,7 +135,7 @@ public class Scribe {
}
/**
* Prints a } to the Buffer an decrease the indentation level.
* Prints a } to the buffer an decrease the indentation level.
*/
public void printRBrace() {
--indentationLevel;
@ -152,11 +153,11 @@ public class Scribe {
}
protected void noNewLines() {
noNewLine = true;
skipLineBreaks = true;
}
protected void newLines() {
noNewLine = false;
skipLineBreaks = false;
}
public void newLine(int i) {

View file

@ -74,14 +74,15 @@ public class StatementWriter extends NodeWriter {
private boolean decrementIndentationLevelOneMore = false;
private final DeclarationWriter declWriter;
public StatementWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
public StatementWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
declWriter = new DeclarationWriter(scribe, visitor, commentMap);
}
/**
* Prints a statement.
*
* @param statement
* @param statement the statement
* @param newLine if true print a newline if statement usually have one.
* @return {@link ASTVisitor#PROCESS_SKIP}
*/
@ -173,12 +174,12 @@ public class StatementWriter extends NodeWriter {
scribe.printSemicolon();
}
private void writeForStatement(IASTForStatement forStatment) {
private void writeForStatement(IASTForStatement forStatement) {
scribe.noNewLines();
scribe.print(FOR);
writeStatement(forStatment.getInitializerStatement(),false);
if (forStatment instanceof ICPPASTForStatement) {
ICPPASTForStatement cppForStatment = (ICPPASTForStatement) forStatment;
writeStatement(forStatement.getInitializerStatement(),false);
if (forStatement instanceof ICPPASTForStatement) {
ICPPASTForStatement cppForStatment = (ICPPASTForStatement) forStatement;
IASTDeclaration cppConditionDeclaration = cppForStatment.getConditionDeclaration();
if (cppConditionDeclaration == null) {
visitNodeIfNotNull(cppForStatment.getConditionExpression());
@ -187,17 +188,17 @@ public class StatementWriter extends NodeWriter {
cppConditionDeclaration.accept(visitor);
}
} else {
if (forStatment.getConditionExpression() != null) {
forStatment.getConditionExpression().accept(visitor);
if (forStatement.getConditionExpression() != null) {
forStatement.getConditionExpression().accept(visitor);
scribe.printSemicolon();
}
}
visitNodeIfNotNull(forStatment.getIterationExpression());
visitNodeIfNotNull(forStatement.getIterationExpression());
scribe.print(')');
scribe.newLines();
nextCompoundNoNewLine();
writeBodyStatement(forStatment.getBody(), false);
writeBodyStatement(forStatement.getBody(), false);
}
private void writeForStatement(ICPPASTRangeBasedForStatement forStatment) {
@ -418,7 +419,6 @@ public class StatementWriter extends NodeWriter {
scribe.newLine();
statement.accept(visitor);
scribe.decrementIndentationLevel();
scribe.newLine();
}
}

View file

@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
@ -35,7 +34,7 @@ public class TemplateParameterWriter extends NodeWriter {
* @param scribe
* @param visitor
*/
public TemplateParameterWriter(Scribe scribe, ASTVisitor visitor, NodeCommentMap commentMap) {
public TemplateParameterWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
}

View file

@ -44,8 +44,7 @@ public class ASTModificationHelper {
T appendedTNode = cast(newNode, clazz);
if (appendedTNode != null) {
modifiedChildren.add(appendedTNode);
}
else if (newNode instanceof ContainerNode) {
} else if (newNode instanceof ContainerNode) {
ContainerNode nodeContainer = (ContainerNode) newNode;
for (IASTNode currentNode : nodeContainer.getNodes()) {
T tnode= cast(currentNode, clazz);

View file

@ -9,16 +9,23 @@
* Contributors:
* Institute for Software - initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ToolFactory;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTComment;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
@ -31,7 +38,10 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.formatter.CodeFormatter;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationMap;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTRewriteAnalyzer;
@ -41,16 +51,26 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
import org.eclipse.cdt.internal.core.dom.rewrite.util.FileContentHelper;
import org.eclipse.cdt.internal.core.dom.rewrite.util.FileHelper;
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.cdt.internal.formatter.CCodeFormatter;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.text.edits.DeleteEdit;
import org.eclipse.text.edits.InsertEdit;
import org.eclipse.text.edits.MalformedTreeException;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.text.edits.TextEditGroup;
public class ChangeGenerator extends ASTVisitor {
@ -93,8 +113,10 @@ public class ChangeGenerator extends ASTVisitor {
initParentModList();
rootNode.accept(pathProvider);
for (IFile currentFile : changes.keySet()) {
MultiTextEdit edit = changes.get(currentFile);
edit = formatChangedCode(edit, currentFile);
TextFileChange subchange= ASTRewriteAnalyzer.createCTextFileChange(currentFile);
subchange.setEdit(changes.get(currentFile));
subchange.setEdit(edit);
change.add(subchange);
}
}
@ -130,6 +152,63 @@ public class ChangeGenerator extends ASTVisitor {
return modifiedNodeParent;
}
/**
* Applies the C++ code formatter to the code affected by refactoring.
*
* @param edit The text edit produced by refactoring.
* @param file The file being modified.
* @return The text edit containing formatted refactoring changes, or the original text edit
* in case of errors.
*/
private MultiTextEdit formatChangedCode(MultiTextEdit edit, IFile file) {
String code;
try {
code = FileContentHelper.getContent(file, 0);
} catch (IOException e) {
CCorePlugin.log(e);
return edit;
} catch (CoreException e) {
CCorePlugin.log(e);
return edit;
}
IDocument document = new Document(code);
try {
TextEdit tempEdit = edit.copy();
tempEdit.apply(document, TextEdit.UPDATE_REGIONS);
TextEdit[] edits = tempEdit.getChildren();
IRegion[] regions = new IRegion[edits.length];
for (int i = 0; i < edits.length; i++) {
regions[i] = edits[i].getRegion();
}
ICProject project = CCorePlugin.getDefault().getCoreModel().create(file.getProject());
Map<String, String> options = project.getOptions(true);
CodeFormatter formatter = ToolFactory.createCodeFormatter(options);
code = document.get();
TextEdit[] formatEdits = formatter.format(CCodeFormatter.K_TRANSLATION_UNIT, code,
regions, TextUtilities.getDefaultLineDelimiter(document));
MultiTextEdit resultEdit = new MultiTextEdit();
edits = edit.getChildren();
for (int i = 0; i < edits.length; i++) {
IRegion region = regions[i];
int offset = region.getOffset();
TextEdit formatEdit = formatEdits[i];
formatEdit.moveTree(-offset);
document = new Document(code.substring(offset, offset + region.getLength()));
formatEdit.apply(document, TextEdit.NONE);
TextEdit textEdit = edits[i];
resultEdit.addChild(
new ReplaceEdit(textEdit.getOffset(), textEdit.getLength(), document.get()));
}
return resultEdit;
} catch (MalformedTreeException e) {
CCorePlugin.log(e);
return edit;
} catch (BadLocationException e) {
CCorePlugin.log(e);
return edit;
}
}
@Override
public int visit(IASTTranslationUnit translationUnit) {
if (hasChangedChild(translationUnit)) {
@ -145,11 +224,6 @@ public class ChangeGenerator extends ASTVisitor {
return super.leave(tu);
}
private int getOffsetForNodeFile(IASTNode rootNode) {
Integer offset = sourceOffsets.get(rootNode.getFileLocation().getFileName());
return offset == null ? 0 : offset.intValue();
}
@Override
public int visit(IASTDeclaration declaration) {
if (hasChangedChild(declaration)) {
@ -160,16 +234,10 @@ public class ChangeGenerator extends ASTVisitor {
}
private void synthTreatment(IASTNode synthNode) {
synthTreatment(synthNode, null);
}
private void synthTreatment(IASTNode synthNode, String fileScope) {
String indent = getIndent(synthNode);
ASTWriter synthWriter = new ASTWriter(indent);
synthWriter.setModificationStore(modificationStore);
String synthSource = synthWriter.write(synthNode, fileScope, commentMap);
ChangeGeneratorWriterVisitor writer =
new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
synthNode.accept(writer);
String synthSource = writer.toString();
createChange(synthNode, synthSource);
IASTFileLocation fileLocation = synthNode.getFileLocation();
@ -177,16 +245,115 @@ public class ChangeGenerator extends ASTVisitor {
sourceOffsets.put(fileLocation.getFileName(), Integer.valueOf(newOffset));
}
private void handleAppends(IASTNode node) {
ChangeGeneratorWriterVisitor writer =
new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
List<ASTModification> modifications = modificationParent.get(node);
ReplaceEdit anchor = getAppendAnchor(node);
Assert.isNotNull(anchor);
IASTNode precedingNode = getLastNodeBeforeAppendPoint(node);
if (precedingNode != null &&
ASTWriter.requireBlankLineInBetween(precedingNode, modifications.get(0).getNewNode())) {
writer.newLine();
}
for (ASTModification modification : modifications) {
IASTNode newNode = modification.getNewNode();
newNode.accept(writer);
}
String code = writer.toString();
IFile file = FileHelper.getFileFromNode(node);
MultiTextEdit parentEdit = getEdit(node, file);
ReplaceEdit edit = new ReplaceEdit(anchor.getOffset(), anchor.getLength(),
code + anchor.getText());
parentEdit.addChild(edit);
IASTFileLocation fileLocation = node.getFileLocation();
int newOffset = fileLocation.getNodeOffset() + fileLocation.getNodeLength();
sourceOffsets.put(fileLocation.getFileName(), Integer.valueOf(newOffset));
}
private IASTNode getLastNodeBeforeAppendPoint(IASTNode node) {
IASTNode[] children;
if (node instanceof IASTCompositeTypeSpecifier) {
children = ((IASTCompositeTypeSpecifier) node).getDeclarations(true);
} else {
children = node.getChildren();
}
return children.length > 0 ? children[children.length - 1] : null;
}
private boolean isAppendable(Iterable<ASTModification> modifications) {
for (ASTModification modification : modifications) {
if (!isAppendable(modification))
return false;
}
return true;
}
private boolean isAppendable(ASTModification modification) {
if (modification.getKind() != ModificationKind.APPEND_CHILD)
return false;
IASTNode node = modification.getNewNode();
return node instanceof IASTDeclaration || node instanceof IASTStatement;
}
/**
* Returns a replace edit whose offset is the position where child appended nodes should be
* inserted at. The text contains the content of the code region that will be disturbed by
* the insertion.
* @param node The node to append children to.
* @return a ReplaceEdit object, or <code>null</code> if the node does not support appending
* children to it.
*/
private ReplaceEdit getAppendAnchor(IASTNode node) {
if (!(node instanceof IASTCompositeTypeSpecifier ||
node instanceof IASTCompoundStatement ||
node instanceof ICPPASTNamespaceDefinition)) {
return null;
}
IFile file = FileHelper.getFileFromNode(node);
String code = originalCodeOfNode(node, file);
IASTFileLocation location = node.getFileLocation();
int pos = location.getNodeOffset() + location.getNodeLength();
int len = code.endsWith("}") ? 1 : 0; //$NON-NLS-1$
int startOfLine = skipPrecedingBlankLines(code, code.length() - len);
if (startOfLine < 0) {
// Include the closing brace in the region that will be reformatted.
return new ReplaceEdit(pos - len, len, code.substring(code.length() - len));
}
return new ReplaceEdit(location.getNodeOffset() + startOfLine, 0, ""); //$NON-NLS-1$
}
/**
* Skips blank lines preceding the given position.
* @param text the text to scan
* @param pos the position after that blank lines.
* @return the beginning of the first blank line, or -1 if the beginning of the line
* corresponding to the given position contains non-whitespace characters.
*/
private int skipPrecedingBlankLines(String text, int pos) {
int lineStart = -1;
while (--pos >= 0) {
char c = text.charAt(pos);
if (c == '\n') {
lineStart = pos + 1;
} else if (!Character.isWhitespace(c)) {
break;
}
}
return lineStart;
}
private void synthTreatment(IASTTranslationUnit synthTU) {
ASTWriter synthWriter = new ASTWriter();
synthWriter.setModificationStore(modificationStore);
for (ASTModification modification : modificationParent.get(synthTU)) {
IASTFileLocation targetLocation = modification.getTargetNode().getFileLocation();
IASTNode targetNode = modification.getTargetNode();
IASTFileLocation targetLocation = targetNode.getFileLocation();
String currentFile = targetLocation.getFileName();
IPath implPath = new Path(currentFile);
IFile relevantFile= ResourceLookup.selectFileForLocation(implPath, null);
if (relevantFile == null || !relevantFile.exists()) { // if not in workspace or local file system
if (relevantFile == null || !relevantFile.exists()) { // If not in workspace or local file system
throw new UnhandledASTModificationException(modification);
}
MultiTextEdit edit;
@ -196,7 +363,7 @@ public class ChangeGenerator extends ASTVisitor {
edit = new MultiTextEdit();
changes.put(relevantFile, edit);
}
String newNodeCode = synthWriter.write(modification.getNewNode(), null, commentMap);
String newNodeCode = synthWriter.write(modification.getNewNode(), commentMap);
switch (modification.getKind()) {
case REPLACE:
@ -204,18 +371,20 @@ public class ChangeGenerator extends ASTVisitor {
targetLocation.getNodeLength(), newNodeCode));
break;
case INSERT_BEFORE:
edit.addChild(new InsertEdit(getOffsetIncludingComments(modification.getTargetNode()),
newNodeCode));
if (ASTWriter.requireBlankLineInBetween(modification.getNewNode(), targetNode)) {
newNodeCode = newNodeCode + "\n"; //$NON-NLS-1$
}
edit.addChild(new InsertEdit(getOffsetIncludingComments(targetNode), newNodeCode));
break;
case APPEND_CHILD:
if (modification.getTargetNode() instanceof IASTTranslationUnit &&
((IASTTranslationUnit)modification.getTargetNode()).getDeclarations().length > 0) {
IASTTranslationUnit tu = (IASTTranslationUnit)modification.getTargetNode();
if (targetNode instanceof IASTTranslationUnit &&
((IASTTranslationUnit) targetNode).getDeclarations().length > 0) {
IASTTranslationUnit tu = (IASTTranslationUnit) targetNode;
IASTDeclaration lastDecl = tu.getDeclarations()[tu.getDeclarations().length - 1];
targetLocation = lastDecl.getFileLocation();
}
String lineDelimiter = FileHelper.determineLineDelimiter(
FileHelper.getFileFromNode(modification.getTargetNode()));
FileHelper.getFileFromNode(targetNode));
edit.addChild(new InsertEdit(targetLocation.getNodeOffset() + targetLocation.getNodeLength(),
lineDelimiter + lineDelimiter + newNodeCode));
break;
@ -225,31 +394,33 @@ public class ChangeGenerator extends ASTVisitor {
private void createChange(IASTNode synthNode, String synthSource) {
IFile relevantFile = FileHelper.getFileFromNode(synthNode);
String originalCode = originalCodeOfNode(synthNode);
String originalCode = originalCodeOfNode(synthNode, relevantFile);
CodeComparer codeComparer = new CodeComparer(originalCode, synthSource);
codeComparer.createChange(getEdit(synthNode, relevantFile), synthNode);
}
MultiTextEdit edit;
if (changes.containsKey(relevantFile)) {
edit = changes.get(relevantFile);
} else {
private MultiTextEdit getEdit(IASTNode modifiedNode, IFile file) {
MultiTextEdit edit = changes.get(file);
if (edit == null) {
edit = new MultiTextEdit();
changes.put(relevantFile, edit);
changes.put(file, edit);
}
TextEditGroup editGroup = new TextEditGroup(Messages.ChangeGenerator_group);
for (ASTModification currentModification : modificationParent.get(modifiedNode)) {
if (currentModification.getAssociatedEditGroup() != null) {
editGroup = currentModification.getAssociatedEditGroup();
edit.addChildren(editGroup.getTextEdits());
break;
}
}
return edit;
}
codeComparer.createChange(edit, synthNode);
}
public String originalCodeOfNode(IASTNode node) {
if (node.getFileLocation() != null) {
IFile sourceFile = FileHelper.getFileFromNode(node);
private String originalCodeOfNode(IASTNode node, IFile sourceFile) {
int nodeOffset = getOffsetIncludingComments(node);
int nodeLength = getNodeLengthIncludingComments(node);
return FileContentHelper.getContent(sourceFile, nodeOffset, nodeLength);
}
return null;
}
private int getNodeLengthIncludingComments(IASTNode node) {
int nodeOffset = node.getFileLocation().getNodeOffset();
@ -290,23 +461,15 @@ public class ChangeGenerator extends ASTVisitor {
return nodeOffset;
}
private String getIndent(IASTNode nextNode) {
IASTFileLocation fileLocation = nextNode.getFileLocation();
int length = fileLocation.getNodeOffset() - getOffsetForNodeFile(nextNode);
String originalSource = FileContentHelper.getContent(FileHelper.getFileFromNode(nextNode),
getOffsetForNodeFile(nextNode), length);
StringBuilder indent = new StringBuilder(originalSource);
indent.reverse();
String lastline = indent.substring(0, Math.max(indent.indexOf("\n"), 0)); //$NON-NLS-1$
if (lastline.trim().length() == 0) {
return lastline;
}
return ""; //$NON-NLS-1$
private boolean hasChangedChild(IASTNode node) {
return modificationParent.containsKey(node);
}
private boolean hasChangedChild(IASTNode parent) {
return modificationParent.containsKey(parent);
private boolean hasAppendsOnly(IASTNode node) {
List<ASTModification> modifications = modificationParent.get(node);
if (modifications == null)
return false;
return isAppendable(modifications);
}
@Override
@ -329,22 +492,38 @@ public class ChangeGenerator extends ASTVisitor {
@Override
public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
if (hasChangedChild(namespaceDefinition)) {
if (hasChangedChild(namespaceDefinition) && !hasAppendsOnly(namespaceDefinition)) {
synthTreatment(namespaceDefinition);
return ASTVisitor.PROCESS_SKIP;
}
return super.visit(namespaceDefinition);
}
@Override
public int leave(ICPPASTNamespaceDefinition namespaceDefinition) {
if (hasAppendsOnly(namespaceDefinition)) {
handleAppends(namespaceDefinition);
}
return super.leave(namespaceDefinition);
}
@Override
public int visit(IASTDeclSpecifier declSpec) {
if (hasChangedChild(declSpec)) {
if (hasChangedChild(declSpec) && !hasAppendsOnly(declSpec)) {
synthTreatment(declSpec);
return ASTVisitor.PROCESS_SKIP;
}
return super.visit(declSpec);
}
@Override
public int leave(IASTDeclSpecifier declSpec) {
if (hasAppendsOnly(declSpec)) {
handleAppends(declSpec);
}
return super.leave(declSpec);
}
@Override
public int visit(IASTExpression expression) {
if (hasChangedChild(expression)) {
@ -383,13 +562,21 @@ public class ChangeGenerator extends ASTVisitor {
@Override
public int visit(IASTStatement statement) {
if (hasChangedChild(statement)) {
if (hasChangedChild(statement) && !hasAppendsOnly(statement)) {
synthTreatment(statement);
return ASTVisitor.PROCESS_SKIP;
}
return super.visit(statement);
}
@Override
public int leave(IASTStatement statement) {
if (hasAppendsOnly(statement)) {
handleAppends(statement);
}
return super.leave(statement);
}
class CodeComparer {
private final StringBuilder originalCode;
private final StringBuilder synthCode;
@ -536,14 +723,6 @@ public class ChangeGenerator extends ASTVisitor {
protected void createChange(MultiTextEdit edit, IASTNode changedNode) {
int changeOffset = getOffsetIncludingComments(changedNode);
TextEditGroup editGroup = new TextEditGroup(Messages.ChangeGenerator_group);
for (ASTModification currentModification : modificationParent.get(changedNode)) {
if (currentModification.getAssociatedEditGroup() != null) {
editGroup = currentModification.getAssociatedEditGroup();
edit.addChildren(editGroup.getTextEdits());
break;
}
}
createChange(edit, changeOffset);
}

View file

@ -11,9 +11,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.DeclSpecWriter;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.Scribe;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
@ -21,8 +21,8 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
public class ModifiedASTDeclSpecWriter extends DeclSpecWriter {
private final ASTModificationHelper modificationHelper;
public ModifiedASTDeclSpecWriter(Scribe scribe, ASTVisitor visitor, ModificationScopeStack stack,
NodeCommentMap commentMap) {
public ModifiedASTDeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor,
ModificationScopeStack stack, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
this.modificationHelper = new ASTModificationHelper(stack);
}

View file

@ -12,11 +12,11 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.DeclarationWriter;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.Scribe;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
@ -24,21 +24,26 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
public class ModifiedASTDeclarationWriter extends DeclarationWriter {
private final ASTModificationHelper modificationHelper;
public ModifiedASTDeclarationWriter(Scribe scribe, ASTVisitor visitor, ModificationScopeStack stack, NodeCommentMap commentMap) {
public ModifiedASTDeclarationWriter(Scribe scribe, ASTWriterVisitor visitor,
ModificationScopeStack stack, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
this.modificationHelper = new ASTModificationHelper(stack);
}
@Override
protected void writeDeclarationsInNamespace(ICPPASTNamespaceDefinition namespaceDefinition, IASTDeclaration[] declarations) {
IASTDeclaration[] modifiedDeclarations = modificationHelper.createModifiedChildArray(namespaceDefinition, declarations, IASTDeclaration.class, commentMap);
protected void writeDeclarationsInNamespace(ICPPASTNamespaceDefinition namespaceDefinition,
IASTDeclaration[] declarations) {
IASTDeclaration[] modifiedDeclarations = modificationHelper.createModifiedChildArray(
namespaceDefinition, declarations, IASTDeclaration.class, commentMap);
super.writeDeclarationsInNamespace(namespaceDefinition, modifiedDeclarations);
}
@Override
protected void writeCtorChainInitializer(ICPPASTFunctionDefinition funcDec,
ICPPASTConstructorChainInitializer[] ctorInitChain) {
ICPPASTConstructorChainInitializer[] modifiedChainInitializer = modificationHelper.createModifiedChildArray(funcDec, ctorInitChain, ICPPASTConstructorChainInitializer.class, commentMap);
super.writeCtorChainInitializer(funcDec, modifiedChainInitializer);
ICPPASTConstructorChainInitializer[] modifiedInitializer =
modificationHelper.createModifiedChildArray(funcDec, ctorInitChain,
ICPPASTConstructorChainInitializer.class, commentMap);
super.writeCtorChainInitializer(funcDec, modifiedInitializer);
}
}

View file

@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
@ -25,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.DeclaratorWriter;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.Scribe;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
@ -32,7 +32,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
public class ModifiedASTDeclaratorWriter extends DeclaratorWriter {
private final ASTModificationHelper modificationHelper;
public ModifiedASTDeclaratorWriter(Scribe scribe, ASTVisitor visitor, ModificationScopeStack stack, NodeCommentMap commentMap) {
public ModifiedASTDeclaratorWriter(Scribe scribe, ASTWriterVisitor visitor, ModificationScopeStack stack, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
this.modificationHelper = new ASTModificationHelper(stack);
}
@ -40,29 +40,31 @@ public class ModifiedASTDeclaratorWriter extends DeclaratorWriter {
@Override
protected void writeParameterDeclarations(IASTStandardFunctionDeclarator funcDec,
IASTParameterDeclaration[] paraDecls) {
IASTParameterDeclaration[] modifiedParameters = modificationHelper
.createModifiedChildArray(funcDec, paraDecls, IASTParameterDeclaration.class,
commentMap);
IASTParameterDeclaration[] modifiedParameters = modificationHelper.createModifiedChildArray(
funcDec, paraDecls, IASTParameterDeclaration.class, commentMap);
super.writeParameterDeclarations(funcDec, modifiedParameters);
}
@Override
protected void writePointerOperators(IASTDeclarator declarator,IASTPointerOperator[] unmodifiedPointerOperations) {
protected void writePointerOperators(IASTDeclarator declarator,
IASTPointerOperator[] unmodifiedPointerOperations) {
IASTPointerOperator[] modifiedPointer = modificationHelper.createModifiedChildArray(
declarator, unmodifiedPointerOperations, IASTPointerOperator.class, commentMap);
super.writePointerOperators(declarator, modifiedPointer);
}
@Override
protected void writeArrayModifiers(IASTArrayDeclarator arrDecl,
IASTArrayModifier[] arrMods) {
IASTArrayModifier[] modifiedModifiers = modificationHelper.createModifiedChildArray(arrDecl, arrMods, IASTArrayModifier.class, commentMap);
protected void writeArrayModifiers(IASTArrayDeclarator arrDecl, IASTArrayModifier[] arrMods) {
IASTArrayModifier[] modifiedModifiers = modificationHelper.createModifiedChildArray(arrDecl,
arrMods, IASTArrayModifier.class, commentMap);
super.writeArrayModifiers(arrDecl, modifiedModifiers);
}
@Override
protected void writeExceptionSpecification(ICPPASTFunctionDeclarator funcDec, IASTTypeId[] exceptions ) {
IASTTypeId[] modifiedExceptions = modificationHelper.createModifiedChildArray(funcDec, exceptions, IASTTypeId.class, commentMap);
protected void writeExceptionSpecification(ICPPASTFunctionDeclarator funcDec,
IASTTypeId[] exceptions) {
IASTTypeId[] modifiedExceptions = modificationHelper.createModifiedChildArray(funcDec,
exceptions, IASTTypeId.class, commentMap);
// it makes a difference whether the exception array is identical to
// ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION
if (modifiedExceptions.length == 0 &&
@ -74,18 +76,18 @@ public class ModifiedASTDeclaratorWriter extends DeclaratorWriter {
}
@Override
protected void writeKnRParameterDeclarations(
ICASTKnRFunctionDeclarator knrFunct,
protected void writeKnRParameterDeclarations(ICASTKnRFunctionDeclarator knrFunct,
IASTDeclaration[] knrDeclarations) {
IASTDeclaration[] modifiedDeclarations = modificationHelper.createModifiedChildArray(knrFunct, knrDeclarations, IASTDeclaration.class, commentMap);
IASTDeclaration[] modifiedDeclarations = modificationHelper.createModifiedChildArray(
knrFunct, knrDeclarations, IASTDeclaration.class, commentMap);
super.writeKnRParameterDeclarations(knrFunct, modifiedDeclarations);
}
@Override
protected void writeKnRParameterNames(
ICASTKnRFunctionDeclarator knrFunct, IASTName[] parameterNames) {
IASTName[] modifiedNames = modificationHelper.createModifiedChildArray(knrFunct, parameterNames, IASTName.class, commentMap);
protected void writeKnRParameterNames(ICASTKnRFunctionDeclarator knrFunct,
IASTName[] parameterNames) {
IASTName[] modifiedNames = modificationHelper.createModifiedChildArray(knrFunct,
parameterNames, IASTName.class, commentMap);
super.writeKnRParameterNames(knrFunct, modifiedNames);
}

View file

@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
@ -20,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ExpressionWriter;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.MacroExpansionHandler;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.Scribe;
@ -28,7 +28,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
public class ModifiedASTExpressionWriter extends ExpressionWriter {
private final ASTModificationHelper modificationHelper;
public ModifiedASTExpressionWriter(Scribe scribe, ASTVisitor visitor, MacroExpansionHandler macroHandler,
public ModifiedASTExpressionWriter(Scribe scribe, ASTWriterVisitor visitor, MacroExpansionHandler macroHandler,
ModificationScopeStack stack, NodeCommentMap commentMap) {
super(scribe, visitor, macroHandler, commentMap);
this.modificationHelper = new ASTModificationHelper(stack);

View file

@ -11,10 +11,10 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriterVisitor;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.Scribe;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.StatementWriter;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
@ -22,7 +22,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
public class ModifiedASTStatementWriter extends StatementWriter {
private final ASTModificationHelper modificationHelper;
public ModifiedASTStatementWriter(Scribe scribe, ASTVisitor visitor, ModificationScopeStack stack, NodeCommentMap commentMap) {
public ModifiedASTStatementWriter(Scribe scribe, ASTWriterVisitor visitor, ModificationScopeStack stack, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap);
this.modificationHelper = new ASTModificationHelper(stack);
}

View file

@ -13,8 +13,6 @@ void foo();
//@A.cpp
#include "A.h"
void foo()
{
void foo() {
}

View file

@ -4,8 +4,7 @@
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -20,8 +19,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -36,21 +34,17 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
return /*$*/42/*$$*/; //Hallo
int A::foo() {
return /*$*/42/*$$*/; //Hello
}
void A::bar()
{
void A::bar() {
int a = 42;
int b = 42;
}
@ -58,21 +52,17 @@ void A::bar()
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
return theAnswer; //Hallo
int A::foo() {
return theAnswer; //Hello
}
void A::bar()
{
void A::bar() {
int a = theAnswer;
int b = theAnswer;
}
@ -83,8 +73,7 @@ void A::bar()
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -99,8 +88,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -115,22 +103,18 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
//Hallo
return /*$*/42/*$$*/;
}
void A::bar()
{
void A::bar() {
int a = 42;
int b = 42;
}
@ -138,22 +122,18 @@ void A::bar()
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
//Hallo
return theAnswer;
}
void A::bar()
{
void A::bar() {
int a = theAnswer;
int b = theAnswer;
}
@ -164,8 +144,7 @@ void A::bar()
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -180,8 +159,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -196,21 +174,17 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
float A::foo()
{
float A::foo() {
return /*$*/42.0f/*$$*/;
}
void A::bar()
{
void A::bar() {
float a = 42.0f;
float b = 42.0f;
}
@ -218,21 +192,17 @@ void A::bar()
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
float A::foo()
{
float A::foo() {
return theAnswer;
}
void A::bar()
{
void A::bar() {
float a = theAnswer;
float b = theAnswer;
}
@ -243,8 +213,7 @@ void A::bar()
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -259,8 +228,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -275,21 +243,17 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
double A::foo()
{
double A::foo() {
return /*$*/42.0/*$$*/;
}
void A::bar()
{
void A::bar() {
double a = 42.0;
double b = 42.0;
}
@ -297,21 +261,17 @@ void A::bar()
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
double A::foo()
{
double A::foo() {
return theAnswer;
}
void A::bar()
{
void A::bar() {
double a = theAnswer;
double b = theAnswer;
}
@ -322,8 +282,7 @@ void A::bar()
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -337,8 +296,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -351,51 +309,43 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return 42;
}
int bar()
{
int bar() {
return /*$*/42/*$$*/;
}
//=
#include "A.h"
namespace
{
namespace {
const int theAnswer = 42;
}
A::A()
{
}
A::~A()
{
A::A() {
}
int A::foo()
{
A::~A() {
}
int A::foo() {
return theAnswer;
}
int bar()
{
int bar() {
return theAnswer;
}
//!replaceNumberProtected
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
//@.config
@ -404,8 +354,7 @@ visibility=protected
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -418,12 +367,12 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
int foo();
protected:
static const int theAnswer = 42;
};
@ -433,32 +382,26 @@ protected:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return /*$*/42/*$$*/;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return theAnswer;
}
@ -470,8 +413,7 @@ visibility=private
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -484,12 +426,12 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
int foo();
private:
static const int theAnswer = 42;
};
@ -499,32 +441,26 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return /*$*/42/*$$*/;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return theAnswer;
}
@ -556,26 +492,22 @@ visibility=private
filename=A.h
//@A.h
class X {
void method()
{
void method() {
char* a = /*$*/"sometext"/*$$*/;
}
void method2()
{
void method2() {
const char* b = "sometext";
}
};
//=
class X {
void method()
{
void method() {
char* a = theAnswer;
}
void method2()
{
void method2() {
const char* b = theAnswer;
}
@ -589,13 +521,11 @@ visibility=private
filename=A.h
//@A.h
class X {
void method()
{
void method() {
wchar_t* a = /*$*/L"sometext"/*$$*/;
}
void method2()
{
void method2() {
const wchar_t* b = L"sometext";
const char* c = "sometext";
}
@ -603,13 +533,11 @@ class X {
//=
class X {
void method()
{
void method() {
wchar_t* a = theAnswer;
}
void method2()
{
void method2() {
const wchar_t* b = theAnswer;
const char* c = "sometext";
}

View file

@ -4,8 +4,7 @@
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -19,8 +18,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -34,21 +32,17 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
return 42; //Hallo
int A::foo() {
return 42; // Hello
}
void A::bar()
{
void A::bar() {
int a = 42;
int b = 42;
}
@ -56,21 +50,17 @@ void A::bar()
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
return theAnswer; //Hallo
int A::foo() {
return theAnswer; // Hello
}
void A::bar()
{
void A::bar() {
int a = theAnswer;
int b = theAnswer;
}
@ -91,8 +81,7 @@ project="RegressionTestProject" selection="64,2" visibility="public"/>
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -105,12 +94,12 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
int foo();
protected:
static const int theAnswer = 42;
};
@ -120,32 +109,26 @@ protected:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return theAnswer;
}
@ -164,8 +147,7 @@ project="RegressionTestProject" selection="64,2" visibility="protected"/>
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -178,12 +160,12 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
int foo();
private:
static const int theAnswer = 42;
};
@ -193,32 +175,26 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return theAnswer;
}

View file

@ -6,15 +6,13 @@ filename=test.cpp
methodname=check
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
bool check();
};
@ -23,8 +21,7 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
if (/*$*/5 == 3 + 2/*$$*/) {
//...
}
@ -33,13 +30,11 @@ void Test::test()
//=
#include "test.h"
bool Test::check()
{
bool Test::check() {
return 5 == 3 + 2;
}
void Test::test()
{
void Test::test() {
if (check()) {
//...
}
@ -53,15 +48,13 @@ filename=test.cpp
methodname=check
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
bool check(int num);
};
@ -70,8 +63,7 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
int num = 1;
if (/*$*/5 != 3 + num/*$$*/) {
//...
@ -81,13 +73,11 @@ void Test::test()
//=
#include "test.h"
bool Test::check(int num)
{
bool Test::check(int num) {
return 5 != 3 + num;
}
void Test::test()
{
void Test::test() {
int num = 1;
if (check(num)) {
//...
@ -102,15 +92,13 @@ filename=test.cpp
methodname=add
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
int add(int five, int six);
};
@ -119,8 +107,7 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
int five = 5;
int six = 6;
int result = /*$*/five + six/*$$*/;
@ -129,13 +116,11 @@ void Test::test()
//=
#include "test.h"
int Test::add(int five, int six)
{
int Test::add(int five, int six) {
return five + six;
}
void Test::test()
{
void Test::test() {
int five = 5;
int six = 6;
int result = add(five, six);
@ -151,8 +136,7 @@ methodname=cat
//@test.h
struct helper {};
class Test
{
class Test {
void test();
};
@ -160,8 +144,7 @@ class Test
//=
struct helper {};
class Test
{
class Test {
void test();
helper cat(helper s1, helper s2);
};
@ -170,8 +153,7 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
helper s1 = "a";
helper s2 = "b";
helper result = /*$*/s1 + s2/*$$*/;
@ -180,13 +162,11 @@ void Test::test()
//=
#include "test.h"
helper Test::cat(helper s1, helper s2)
{
helper Test::cat(helper s1, helper s2) {
return s1 + s2;
}
void Test::test()
{
void Test::test() {
helper s1 = "a";
helper s2 = "b";
helper result = cat(s1, s2);
@ -203,8 +183,7 @@ methodname=cat
struct helper {};
typedef helper new_helper;
class Test
{
class Test {
void test();
};
@ -213,8 +192,7 @@ class Test
struct helper {};
typedef helper new_helper;
class Test
{
class Test {
void test();
new_helper cat(new_helper s1, new_helper s2);
};
@ -223,8 +201,7 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
new_helper s1 = "a";
new_helper s2 = "b";
new_helper result = /*$*/s1 + s2/*$$*/;
@ -233,13 +210,11 @@ void Test::test()
//=
#include "test.h"
new_helper Test::cat(new_helper s1, new_helper s2)
{
new_helper Test::cat(new_helper s1, new_helper s2) {
return s1 + s2;
}
void Test::test()
{
void Test::test() {
new_helper s1 = "a";
new_helper s2 = "b";
new_helper result = cat(s1, s2);
@ -256,8 +231,7 @@ methodname=new_helper
struct helper {};
int main(int argc, char** argv)
{
int main(int argc, char** argv) {
helper* h = /*$*/new helper/*$$*/;
return 0;
}
@ -265,13 +239,11 @@ int main(int argc, char** argv)
struct helper {};
helper *new_helper()
{
helper* new_helper() {
return new helper;
}
int main(int argc, char** argv)
{
int main(int argc, char** argv) {
helper* h = new_helper();
return 0;
}
@ -285,31 +257,26 @@ methodname=join_with_world
//@test.cpp
class string {};
string join(string s1, char* s2)
{
string join(string s1, char* s2) {
return s1 + " " + s2;
}
int main()
{
int main() {
string hello = "Hello";
cout << /*$*/join(hello, "World")/*$$*/ << endl;
}
//=
class string {};
string join(string s1, char* s2)
{
string join(string s1, char* s2) {
return s1 + " " + s2;
}
string join_with_world(string hello)
{
string join_with_world(string hello) {
return join(hello, "World");
}
int main()
{
int main() {
string hello = "Hello";
cout << join_with_world(hello) << endl;
}
@ -321,38 +288,34 @@ filename=test.cpp
methodname=value_from
//@test.cpp
struct other
{
struct other {
bool value() {}
};
class Klass
{
void set(bool b){}
void test()
{
class Klass {
void set(bool b) {
}
void test() {
other o;
this->set(/*$*/o.value()/*$$*/);
}
};
//=
struct other
{
struct other {
bool value() {}
};
class Klass
{
void set(bool b){}
class Klass {
void set(bool b) {
}
bool value_from(other o)
{
bool value_from(other o) {
return o.value();
}
void test()
{
void test() {
other o;
this->set(value_from(o));
}
@ -380,8 +343,7 @@ class Cursor{};
Cursor* contains(const Cursor& pos);
Cursor *has(Cursor c)
{
Cursor* has(Cursor c) {
return contains(c);
}
@ -400,8 +362,7 @@ methodname=has
//@test.cpp
class Cursor{};
Cursor* contains(const Cursor& pos)
{
Cursor* contains(const Cursor& pos) {
;
}
@ -413,13 +374,11 @@ int main() {
//=
class Cursor{};
Cursor* contains(const Cursor& pos)
{
Cursor* contains(const Cursor& pos) {
;
}
Cursor *has(Cursor c)
{
Cursor* has(Cursor c) {
return contains(c);
}
@ -436,15 +395,13 @@ filename=test.cpp
methodname=greeting
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
const char greeting();
};
@ -453,21 +410,18 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
char* hi = /*$*/"hello"/*$$*/;
}
//=
#include "test.h"
const char Test::greeting()
{
const char Test::greeting() {
return "hello";
}
void Test::test()
{
void Test::test() {
char* hi = greeting();
}
@ -479,15 +433,13 @@ filename=test.cpp
methodname=size
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
int size();
};
@ -496,21 +448,18 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
int i = /*$*/42/*$$*/;
}
//=
#include "test.h"
int Test::size()
{
int Test::size() {
return 42;
}
void Test::test()
{
void Test::test() {
int i = size();
}
@ -522,15 +471,13 @@ filename=test.cpp
methodname=certainty
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
float certainty();
};
@ -539,21 +486,18 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
float f = /*$*/0.42f/*$$*/;
}
//=
#include "test.h"
float Test::certainty()
{
float Test::certainty() {
return 0.42f;
}
void Test::test()
{
void Test::test() {
float f = certainty();
}
@ -565,15 +509,13 @@ filename=test.cpp
methodname=newline
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
char newline();
};
@ -582,21 +524,18 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
char nl = /*$*/'\n'/*$$*/;
}
//=
#include "test.h"
char Test::newline()
{
char Test::newline() {
return '\n';
}
void Test::test()
{
void Test::test() {
char nl = newline();
}
@ -608,15 +547,13 @@ filename=test.cpp
methodname=valid
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
bool valid();
};
@ -625,21 +562,18 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
bool b = /*$*/true/*$$*/;
}
//=
#include "test.h"
bool Test::valid()
{
bool Test::valid() {
return true;
}
void Test::test()
{
void Test::test() {
bool b = valid();
}
@ -651,15 +585,13 @@ filename=test.cpp
methodname=invalid
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
bool invalid();
};
@ -668,21 +600,18 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
bool b = /*$*/false/*$$*/;
}
//=
#include "test.h"
bool Test::invalid()
{
bool Test::invalid() {
return false;
}
void Test::test()
{
void Test::test() {
bool b = invalid();
}
@ -694,15 +623,13 @@ filename=test.cpp
methodname=size
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
int size();
};
@ -711,21 +638,18 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
int i = /*$*/42/*$$*/;
}
//=
#include "test.h"
int Test::size()
{
int Test::size() {
return 42;
}
void Test::test()
{
void Test::test() {
int i = size();
}
@ -737,15 +661,13 @@ filename=test.cpp
methodname=newline
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
char newline();
};
@ -754,21 +676,18 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
char nl = /*$*/'\n'/*$$*/;
}
//=
#include "test.h"
char Test::newline()
{
char Test::newline() {
return '\n';
}
void Test::test()
{
void Test::test() {
char nl = newline();
}
@ -780,15 +699,13 @@ filename=test.cpp
methodname=valid
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
bool valid();
};
@ -797,21 +714,18 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
bool b = /*$*/true/*$$*/;
}
//=
#include "test.h"
bool Test::valid()
{
bool Test::valid() {
return true;
}
void Test::test()
{
void Test::test() {
bool b = valid();
}
@ -823,15 +737,13 @@ filename=test.cpp
methodname=invalid
//@test.h
class Test
{
class Test {
void test();
};
//=
class Test
{
class Test {
void test();
bool invalid();
};
@ -840,21 +752,18 @@ class Test
//@test.cpp
#include "test.h"
void Test::test()
{
void Test::test() {
bool b = /*$*/false/*$$*/;
}
//=
#include "test.h"
bool Test::invalid()
{
bool Test::invalid() {
return false;
}
void Test::test()
{
void Test::test() {
bool b = invalid();
}
@ -875,8 +784,7 @@ int test(foo s) {
//=
typedef int& foo;
int bar(foo s)
{
int bar(foo s) {
return s + 1;
}
@ -902,8 +810,7 @@ void foo(){
//=
double bar(int x)
{
double bar(int x) {
return x + 2.5;
}
@ -934,8 +841,7 @@ int main(){
#define five 5
#define ADD(a, b) a + b
int bar(int & i)
{
int bar(int& i) {
return ADD(i, five);
}
@ -968,8 +874,7 @@ int main(){
#define five 5
#define ADD(a, b) a + b
int bar(int & i)
{
int bar(int& i) {
return ADD(i, five);
}

View file

@ -3,9 +3,9 @@
//@A.cpp
void test() {
}
template <typename T>
int tempFunct() {
T i;
i = 0;
/*$*/i++;
@ -17,15 +17,15 @@ int tempFunct(){
//=
void test() {
}
template<typename T> void exp(T i)
{
template<typename T>
void exp(T i) {
i++;
i += 3;
}
template <typename T>
int tempFunct() {
T i;
i = 0;
exp(i);
@ -38,9 +38,9 @@ int tempFunct(){
//@A.cpp
void test() {
}
template <typename T>
int tempFunct(T p) {
/*$*/++p;
p + 4;/*$$*/
return 0;
@ -49,8 +49,9 @@ int tempFunct(T p){
//=
void test() {
}
template<typename T> void exp(T p)
{
template<typename T>
void exp(T p) {
++p;
p + 4;
}
@ -66,9 +67,9 @@ int tempFunct(T p){
//@A.cpp
void test() {
}
template <typename T>
int tempFunct() {
/*$*/T p;
p = 0;
p + 4;/*$$*/
@ -79,8 +80,9 @@ int tempFunct(){
//=
void test() {
}
template<typename T> T exp()
{
template<typename T>
T exp() {
T p;
p = 0;
p + 4;
@ -89,7 +91,6 @@ template<typename T> T exp()
template <typename T>
int tempFunct() {
T p = exp();
p + 2;
return 0;

View file

@ -4,8 +4,7 @@
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -18,8 +17,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -31,32 +29,26 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return /*$*/42/*$$*/;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
int i = 42;
return i;
}
@ -67,8 +59,7 @@ int A::foo()
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -81,8 +72,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -94,32 +84,26 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return /*$*/'c'/*$$*/;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
char temp = 'c';
return temp;
}
@ -130,8 +114,7 @@ int A::foo()
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -144,8 +127,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -157,32 +139,26 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
float A::foo()
{
float A::foo() {
return /*$*/42.0f/*$$*/;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
float A::foo()
{
float A::foo() {
float f = 42.0f;
return f;
}
@ -193,8 +169,7 @@ float A::foo()
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -207,8 +182,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -220,32 +194,26 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
float A::foo()
{
float A::foo() {
return /*$*/42.0/*$$*/;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
float A::foo()
{
float A::foo() {
double f = 42.0;
return f;
}
@ -256,8 +224,7 @@ float A::foo()
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -270,8 +237,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -283,32 +249,26 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
return /*$*/(42)/*$$*/;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
int i = 42;
return i;
}
@ -319,8 +279,7 @@ int A::foo()
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -333,8 +292,7 @@ public:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -346,16 +304,13 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
int x = 3;
return /*$*/(x + 2)/*$$*/ * 15;
}
@ -363,16 +318,13 @@ int A::foo()
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
int x = 3;
int i = x + 2;
return i * 15;
@ -382,13 +334,15 @@ int A::foo()
//#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest
//@A.cpp
void foo() {
for(int n = /*$*/5 + 2/*$$*/; n < 10; ++n);
for (int n = /*$*/5 + 2/*$$*/; n < 10; ++n)
;
}
//=
void foo() {
int i = 5 + 2;
for(int n = i; n < 10; ++n);
for (int n = i; n < 10; ++n)
;
}
//!ExtractLocalVariableRefactoringTest expression
@ -427,12 +381,14 @@ void foo(){
//#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest
//@A.cpp
const volatile int* k;
void foo() {
/*$*/k;/*$$*/
}
//=
const volatile int* k;
void foo() {
const volatile int* k0 = k;
k0;
@ -491,9 +447,7 @@ class Foo {
Foo<int> getFoo();
int main() {
/*$*/getFoo()/*$$*/;
return 0;
}
@ -508,7 +462,6 @@ Foo<int> getFoo();
int main() {
Foo<int> foo = getFoo();
foo;
return 0;
}
@ -516,25 +469,27 @@ int main() {
//#org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest
//@A.cpp
namespace bar {
template<class T>
class Foo {
};
}
bar::Foo<int> getFoo();
int main() {
/*$*/getFoo()/*$$*/;
return 0;
}
//=
namespace bar {
template<class T>
class Foo {
};
}
bar::Foo<int> getFoo();
@ -542,7 +497,6 @@ bar::Foo<int> getFoo();
int main() {
bar::Foo<int> foo = getFoo();
foo;
return 0;
}

View file

@ -2,13 +2,15 @@
//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest
//@main.cpp
void foo() {
for(int n = 5 + 2; n < 10; ++n);
for (int n = 5 + 2; n < 10; ++n)
;
}
//=
void foo() {
int i = 5 + 2;
for(int n = i; n < 10; ++n);
for (int n = i; n < 10; ++n)
;
}
//@refScript.xml
@ -17,5 +19,5 @@ void foo(){
<refactoring comment="Extract 5 + 2" description="Extract Local Variable Refactoring"
fileName="file:$$projectPath$$/main.cpp" flags="4"
id="org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable.ExtractLocalVariableRefactoring"
name="i" project="RegressionTestProject" selection="25,5"/>
name="i" project="RegressionTestProject" selection="27,5"/>
</session>

View file

@ -6,8 +6,7 @@ replaceduplicates=true
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -23,8 +22,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -40,54 +38,49 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int i = 2;
++i;
help();
}int A::foo()
{
}
int A::foo() {
int i = 2;
/*$*/++i;
help();/*$$*/
return i;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int i = 2;
exp(i);
}void A::exp(int & i)
{
}
void A::exp(int& i) {
++i;
help();
}
int A::foo()
{
int A::foo() {
int i = 2;
exp(i);
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -99,8 +92,7 @@ replaceduplicates=true
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -116,8 +108,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -133,54 +124,49 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int oo = 99;
++oo;
help();
}int A::foo()
{
}
int A::foo() {
int i = 2;
/*$*/++i;
help();/*$$*/
return i;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int oo = 99;
exp(oo);
}void A::exp(int & i)
{
}
void A::exp(int& i) {
++i;
help();
}
int A::foo()
{
int A::foo() {
int i = 2;
exp(i);
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -193,8 +179,7 @@ returnvalue=true
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -211,8 +196,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -229,18 +213,17 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int j = 0;
i++;
j++;
help();
}void A::foo()
{
}
void A::foo() {
int j = 0;
int a = 1;
/*$*/j++;
@ -250,32 +233,29 @@ A::~A()
j++;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int j = 0;
i = exp(i, j);
}int A::exp(int j, int & a)
{
}
int A::exp(int j, int& a) {
j++;
a++;
help();
return j;
}
void A::foo()
{
void A::foo() {
int j = 0;
int a = 1;
j = exp(j, a);
@ -283,8 +263,7 @@ void A::foo()
j++;
}
int A::help()
{
int A::help() {
return 42;
}
@ -297,8 +276,7 @@ returnvalue=true
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -316,8 +294,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -335,19 +312,18 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int j = 0;
int a = 1;
a++;
j++;
help();
}void A::foo()
{
}
void A::foo() {
int j = 0;
/*$*/field++;
@ -357,43 +333,39 @@ A::~A()
j++;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int j = 0;
int a = 1;
a++;
j++;
help();
}int A::exp(int j)
{
}
int A::exp(int j) {
field++;
j++;
help();
return j;
}
void A::foo()
{
void A::foo() {
int j = 0;
j = exp(j);
field++;
j++;
}
int A::help()
{
int A::help() {
return 42;
}
@ -406,8 +378,7 @@ returnvalue=true
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -423,8 +394,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -440,20 +410,19 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int oo = 99;
float blabla = 0;
++oo;
blabla += 1;
help();
blabla += 1;
}int A::foo()
{
}
int A::foo() {
int i = 2;
float j = 8989;
/*$*/++i;
@ -463,34 +432,31 @@ A::~A()
return i;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int oo = 99;
float blabla = 0;
oo = exp(oo, blabla);
blabla += 1;
}int A::exp(int i, float & j)
{
}
int A::exp(int i, float& j) {
++i;
j += 1;
help();
return i;
}
int A::foo()
{
int A::foo() {
int i = 2;
float j = 8989;
i = exp(i, j);
@ -498,8 +464,7 @@ int A::foo()
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -511,8 +476,7 @@ replaceduplicates=true
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -528,8 +492,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -545,19 +508,18 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int oo = 99;
float blabla = 0;
++oo;
blabla += 1;
help();
}int A::foo()
{
}
int A::foo() {
int i = 2;
float j = 8989;
/*$*/++i;
@ -566,40 +528,36 @@ A::~A()
return i;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int oo = 99;
float blabla = 0;
exp(oo, blabla);
}void A::exp(int & i, float j)
{
}
void A::exp(int& i, float j) {
++i;
j += 1;
help();
}
int A::foo()
{
int A::foo() {
int i = 2;
float j = 8989;
exp(i, j);
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -611,8 +569,7 @@ replaceduplicates=true
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -628,8 +585,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -645,55 +601,50 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int i = 2;
++i;// No Duplicate
help();
++i;// this is the reason
}void A::foo()
{
}
void A::foo() {
int i = 2;
/*$*/++i;
help();/*$$*/
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int i = 2;
++i;// No Duplicate
help();
++i;// this is the reason
}void A::exp(int i)
{
}
void A::exp(int i) {
++i;
help();
}
void A::foo()
{
void A::foo() {
int i = 2;
exp(i);
}
int A::help()
{
int A::help() {
return 42;
}
@ -708,8 +659,7 @@ returnvalue=true
#include "B.h"
class A
{
class A {
public:
A();
virtual ~A();
@ -727,8 +677,7 @@ private:
#include "B.h"
class A
{
class A {
public:
A();
virtual ~A();
@ -744,12 +693,10 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int i = 2;
float x = i;
B* b = new B();
@ -761,8 +708,9 @@ A::~A()
b->hello(y);
++x;
i++;
}int A::foo()
{
}
int A::foo() {
int i = 2;
float x = i;
B* b = new B();
@ -776,20 +724,17 @@ A::~A()
return i;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int i = 2;
float x = i;
B* b = new B();
@ -798,8 +743,9 @@ A::~A()
b->hello(y);
++x;
i++;
}int A::exp(int i, B *& b, int & y, float & x)
{
}
int A::exp(int i, B*& b, int& y, float& x) {
++i;
b->hello(y);
i = i + x;
@ -807,8 +753,7 @@ A::~A()
return i;
}
int A::foo()
{
int A::foo() {
int i = 2;
float x = i;
B* b = new B();
@ -819,8 +764,7 @@ int A::foo()
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -849,8 +793,7 @@ returnvalue=true
#include "B.h"
class A
{
class A {
public:
A();
virtual ~A();
@ -868,8 +811,7 @@ private:
#include "B.h"
class A
{
class A {
public:
A();
virtual ~A();
@ -885,12 +827,10 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int i = 2;
float x = i;
B* b = new B();
@ -902,8 +842,9 @@ A::~A()
b->hello(y);
++x;
i++;
}int A::foo()
{
}
int A::foo() {
int i = 2;
float x = i;
B* b = new B();
@ -916,20 +857,17 @@ A::~A()
return i;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int i = 2;
float x = i;
B* b = new B();
@ -941,8 +879,9 @@ A::~A()
b->hello(y);
++x;
i++;
}int A::exp(int i, B *& b, int & y, float x)
{
}
int A::exp(int i, B*& b, int& y, float x) {
++i;
b->hello(y);
i = i + x;
@ -950,8 +889,7 @@ A::~A()
return i;
}
int A::foo()
{
int A::foo() {
int i = 2;
float x = i;
B* b = new B();
@ -961,8 +899,7 @@ int A::foo()
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -988,8 +925,7 @@ replaceduplicates=true
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -1005,8 +941,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -1022,54 +957,49 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int i = 2;
++i;
help();
}int A::foo()
{
}
int A::foo() {
int i = 2;
/*$*/++i;
help();/*$$*/
return i;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int i = 2;
exp(i);
}void A::exp(int & i)
{
}
void A::exp(int& i) {
++i;
help();
}
int A::foo()
{
int A::foo() {
int i = 2;
exp(i);
return i;
}
int A::help()
{
int A::help() {
return 42;
}

View file

@ -4,8 +4,7 @@
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -21,8 +20,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -38,52 +36,45 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
int i = 2;
++i;
help();
return i;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::exp()
{
int A::exp() {
int i = 2;
++i;
help();
return i;
}
int A::foo()
{
int A::foo() {
int i = exp();
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -93,7 +84,7 @@ int A::help()
<refactoring comment="Create method exp" description="Extract Method Refactoring"
fileName="file:$$projectPath$$/A.cpp"
flags="4" id="org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring"
name="exp" project="RegressionTestProject" selection="56,25" visibility="private"/>
name="exp" project="RegressionTestProject" selection="57,25" visibility="private"/>
</session>
@ -103,8 +94,7 @@ int A::help()
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -120,8 +110,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -137,15 +126,13 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
int i = 2;
//comment
++i;
@ -153,38 +140,33 @@ int A::foo()
return i;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
void A::exp(int & i)
{
void A::exp(int& i) {
//comment
++i;
help();
}
int A::foo()
{
int A::foo() {
int i = 2;
//comment
exp(i);
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -194,14 +176,13 @@ int A::help()
<refactoring comment="Create method exp" description="Extract Method Refactoring"
fileName="file:$$projectPath$$/A.cpp"
flags="4" id="org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring"
name="exp" project="RegressionTestProject" selection="79,13" visibility="private"/>
name="exp" project="RegressionTestProject" selection="69,24" visibility="private"/>
</session>
//!Extract Function History first extracted statement with leading comment
//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest
//@main.cpp
int main() {
int i;
// Comment
i = 7;
@ -209,14 +190,12 @@ int main(){
}
//=
void exp(int & i)
{
void exp(int& i) {
// Comment
i = 7;
}
int main() {
int i;
// Comment
exp(i);
@ -229,27 +208,24 @@ int main(){
<refactoring comment="Create method exp" description="Extract Method Refactoring"
fileName="file:$$projectPath$$/main.cpp"
flags="4" id="org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring"
name="exp" project="RegressionTestProject" selection="35,5" visibility="private"/>
name="exp" project="RegressionTestProject" selection="34,6" visibility="private"/>
</session>
//!Extract Function History extracted statement with trailling comment
//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest
//@main.cpp
int main() {
int i;
i = 7; // Comment
return i;
}
//=
void exp(int & i)
{
void exp(int& i) {
i = 7; // Comment
}
int main() {
int i;
exp(i); // Comment
return i;
@ -261,7 +237,7 @@ int main(){
<refactoring comment="Create method exp" description="Extract Method Refactoring"
fileName="file:$$projectPath$$/main.cpp"
flags="4" id="org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring"
name="exp" project="RegressionTestProject" selection="23,5" visibility="private"/>
name="exp" project="RegressionTestProject" selection="22,6" visibility="private"/>
</session>
//!ExtractFunctionRefactoringTest duplicates with different Names History Test
@ -270,8 +246,7 @@ int main(){
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -287,8 +262,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -304,54 +278,49 @@ private:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int oo = 99;
++oo;
help();
}int A::foo()
{
}
int A::foo() {
int i = 2;
++i;
help();
return i;
}
int A::help()
{
int A::help() {
return 42;
}
//=
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
int oo = 99;
exp(oo);
}void A::exp(int & i)
{
}
void A::exp(int& i) {
++i;
help();
}
int A::foo()
{
int A::foo() {
int i = 2;
exp(i);
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -360,5 +329,5 @@ int A::help()
<session version="1.0">
<refactoring comment="Create method exp" description="Extract Method Refactoring"
fileName="file:$$projectPath$$/A.cpp" flags="4" id="org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring"
name="exp" project="RegressionTestProject" replaceDuplicates="true" selection="97,13" visibility="private"/>
name="exp" project="RegressionTestProject" replaceDuplicates="true" selection="99,13" visibility="private"/>
</session>

View file

@ -4,8 +4,7 @@
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -21,8 +20,7 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
@ -40,15 +38,13 @@ private:
#define ADD(a,ab) a + ab + 2 + a
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
int ii = 2;
/*$*/++ii;
ii = ADD(ii, 42);
@ -56,8 +52,7 @@ int A::foo()
return ii;
}
int A::help()
{
int A::help() {
return 42;
}
@ -66,29 +61,25 @@ int A::help()
#define ADD(a,ab) a + ab + 2 + a
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
void A::exp(int & ii)
{
void A::exp(int& ii) {
++ii;
ii = ADD(ii, 42);
help();
}
int A::foo()
{
int A::foo() {
int ii = 2;
exp(ii);
return ii;
}
int A::help()
{
int A::help() {
return 42;
}
@ -101,12 +92,12 @@ returnparameterindex=1
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
int foo();
private:
int help();
};
@ -117,12 +108,12 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
int foo();
private:
int help();
int exp(int& i, int b);
@ -135,15 +126,13 @@ private:
#define ADD(b) b = b + 2
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
int i = 2;
int b = 42;
/*$*/++i;
@ -153,8 +142,7 @@ int A::foo()
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -163,23 +151,20 @@ int A::help()
#define ADD(b) b = b + 2
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::exp(int & i, int b)
{
int A::exp(int& i, int b) {
++i;
help();
ADD(b);
return b;
}
int A::foo()
{
int A::foo() {
int i = 2;
int b = 42;
b = exp(i, b);
@ -187,8 +172,7 @@ int A::foo()
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -202,12 +186,12 @@ replaceduplicates=true
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
int foo();
private:
int help();
};
@ -218,12 +202,12 @@ private:
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
virtual ~A();
int foo();
private:
int help();
int exp(int bb);
@ -236,15 +220,13 @@ private:
#define ADD(b) b = b + 2
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::foo()
{
int A::foo() {
int i = 2;
int bb = 42;
++i;
@ -254,8 +236,7 @@ int A::foo()
return i;
}
int A::help()
{
int A::help() {
return 42;
}
@ -264,22 +245,19 @@ int A::help()
#define ADD(b) b = b + 2
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
int A::exp(int bb)
{
int A::exp(int bb) {
ADD(bb);
ADD(bb);
return bb;
}
int A::foo()
{
int A::foo() {
int i = 2;
int bb = 42;
++i;
@ -288,8 +266,7 @@ int A::foo()
return i;
}
int A::help()
{
int A::help() {
return 42;
}

View file

@ -13,6 +13,7 @@ public:
A();
/*$*/void method2();/*$$*/
std::string toString();
private:
int i;
};
@ -29,6 +30,7 @@ class A{
public:
A();
std::string toString();
private:
int i;
void method2();
@ -49,9 +51,10 @@ filename=A.h
class A {
public:
A();
//Kommentar
//Comment
/*$*/void method2();/*$$*/
std::string toString();
private:
int i;
};
@ -68,9 +71,10 @@ class A{
public:
A();
std::string toString();
private:
int i;
//Kommentar
//Comment
void method2();
};
@ -89,7 +93,7 @@ filename=A.h
class A {
public:
A();
/*Kommentar*/
/*Comment*/
/*$*/void method2();/*$$*/
std::string toString();
@ -109,9 +113,10 @@ class A{
public:
A();
std::string toString();
private:
int i;
/*Kommentar*/
/*Comment*/
void method2();
};
@ -130,8 +135,9 @@ filename=A.h
class A {
public:
A();
/*$*/void method2();/*$$*///Kommentar
/*$*/void method2();/*$$*///Comment
std::string toString();
private:
int i;
};
@ -148,9 +154,10 @@ class A{
public:
A();
std::string toString();
private:
int i;
void method2(); //Kommentar
void method2(); //Comment
};
#endif /*A_H_*/
@ -168,8 +175,9 @@ filename=A.h
class A {
public:
A();
/*$*/void method2();/*$$*//*Kommentar*/
/*$*/void method2();/*$$*//*Comment*/
std::string toString();
private:
int i;
};
@ -186,9 +194,10 @@ class A{
public:
A();
std::string toString();
private:
int i;
void method2(); /*Kommentar*/
void method2(); /*Comment*/
};
#endif /*A_H_*/
@ -207,9 +216,10 @@ class A{
public:
A();
//Kommentar
//Comment
/*$*/void method2();/*$$*/
std::string toString();
private:
int i;
};
@ -226,9 +236,10 @@ class A{
public:
A();
std::string toString();
private:
int i;
//Kommentar
//Comment
void method2();
};
@ -248,9 +259,10 @@ class A{
public:
A();
/*Kommentar*/
/*Comment*/
/*$*/void method2();/*$$*/
std::string toString();
private:
int i;
};
@ -267,9 +279,10 @@ class A{
public:
A();
std::string toString();
private:
int i;
/*Kommentar*/
/*Comment*/
void method2();
};
@ -288,8 +301,9 @@ filename=A.h
class A {
public:
A();
/*$*/void method2();/*$$*///Kommentar
/*$*/void method2();/*$$*///Comment
std::string toString();
private:
int i;
};
@ -306,9 +320,10 @@ class A{
public:
A();
std::string toString();
private:
int i;
void method2(); //Kommentar
void method2(); //Comment
};
#endif /*A_H_*/
@ -326,9 +341,10 @@ filename=A.h
class A {
public:
A();
/*$*/void method2();/*$$*//*Kommentar*/
/*$*/void method2();/*$$*//*Comment*/
std::string toString();
private:
int i;
};
@ -344,9 +360,10 @@ class A{
public:
A();
std::string toString();
private:
int i;
void method2(); /*Kommentar*/
void method2(); /*Comment*/
};
#endif /*A_H_*/
@ -364,10 +381,11 @@ class A{
public:
A();
/*
* Kommentar
* Comment
*/
/*$*/void method2();/*$$*/
std::string toString();
private:
int i;
};
@ -383,10 +401,11 @@ class A{
public:
A();
std::string toString();
private:
int i;
/*
* Kommentar
* Comment
*/
void method2();
};
@ -406,9 +425,10 @@ class A{
public:
A();
/*$*/void method2();/*$$*/ /*
* Kommentar
* Comment
*/
std::string toString();
private:
int i;
};
@ -425,10 +445,11 @@ class A{
public:
A();
std::string toString();
private:
int i;
void method2(); /*
* Kommentar
* Comment
*/
};
@ -451,9 +472,10 @@ public:
* Davor
*/
/*$*/void method2();/*$$*/ /*
* Kommentar
* Comment
*/
std::string toString();
private:
int i;
};
@ -470,13 +492,14 @@ class A{
public:
A();
std::string toString();
private:
int i;
/*
* Davor
*/
void method2(); /*
* Kommentar
* Comment
*/
};
@ -498,6 +521,7 @@ public:
/*123*/
/*$*/void method2();/*$$*///TEST
std::string toString();
private:
int i;
};
@ -514,6 +538,7 @@ class A{
public:
A();
std::string toString();
private:
int i;
/*123*/
@ -538,6 +563,7 @@ public:
/*123*/
/*$*/void method2();/*$$*//*TEST*/
std::string toString();
private:
int i;
};
@ -553,6 +579,7 @@ class A{
public:
A();
std::string toString();
private:
int i;
/*123*/
@ -618,6 +645,7 @@ public:
class A {
public:
void method2();
private:
void method1();
};
@ -650,6 +678,7 @@ public:
class A {
public:
void method2();
private:
void method1();
};
@ -668,7 +697,7 @@ filename=A.h
class A {
public:
//Kommentar
//Comment
/*$*/void method1();/*$$*/
void method2();
};
@ -684,8 +713,9 @@ public:
class A {
public:
void method2();
private:
//Kommentar
//Comment
void method1();
};
@ -703,7 +733,7 @@ filename=A.h
class A {
public:
//Kommentar
//Comment
/*$*/void method1();/*$$*/void method2();
};
@ -718,8 +748,9 @@ public:
class A {
public:
void method2();
private:
//Kommentar
//Comment
void method1();
};
@ -738,6 +769,7 @@ public:
A();
void method2();
std::string toString();
private:
int i;
};
@ -754,6 +786,7 @@ class A{
public:
A();
std::string toString();
private:
int i;
void method2();
@ -782,6 +815,7 @@ public:
//TEST 1
void method2(); //TEST 2
std::string toString();
private:
int i;
};
@ -798,6 +832,7 @@ class A{
public:
A();
std::string toString();
private:
int i;
//TEST 1
@ -826,11 +861,9 @@ public:
HideMethod();
virtual ~HideMethod();
void /*$*/methode2/*$$*/();
void methode3()
{
void methode3() {
methode2();
}
};
#endif /* HIDEMETHOD_H_ */
@ -843,14 +876,12 @@ class HideMethod {
public:
HideMethod();
virtual ~HideMethod();
void methode3()
{
void methode3() {
methode2();
}
private:
void methode2();
};
#endif /* HIDEMETHOD_H_ */
@ -882,6 +913,7 @@ public:
HideMethod();
virtual ~HideMethod();
void methode3();
private:
void methode2();
};
@ -964,6 +996,7 @@ public:
HideMethod();
virtual ~HideMethod();
void methode3();
private:
void methode2();
};
@ -1006,6 +1039,7 @@ public:
HideMethod();
virtual ~HideMethod();
void methode3();
private:
void methode2();
};
@ -1090,6 +1124,7 @@ public:
HideMethod();
virtual ~HideMethod();
void methode3();
private:
void methode2();
};
@ -1230,40 +1265,33 @@ private:
//@.config
filename=A.cpp
//@A.cpp
struct other
{
struct other {
bool value() { return true; }
};
class Klass
{
class Class {
public:
void /*$*/set/*$$*/(bool b) {}
void test()
{
void test() {
other o;
this->set(o.value());
}
};
//=
struct other
{
struct other {
bool value() { return true; }
};
class Klass
{
class Class {
public:
void test()
{
void test() {
other o;
this->set(o.value());
}
private:
void set(bool b)
{
void set(bool b) {
}
};
@ -1272,40 +1300,35 @@ private:
//@.config
filename=A.cpp
//@A.cpp
struct other
{
struct other {
bool value() { return true; }
};
class Klass
{
class Class {
public:
void set(bool b){}
void test()
{
void set(bool b) {
}
void test() {
other o;
this->/*$*/set/*$$*/(o.value());
}
};
//=
struct other
{
struct other {
bool value() { return true; }
};
class Klass
{
class Class {
public:
void test()
{
void test() {
other o;
this->set(o.value());
}
private:
void set(bool b)
{
void set(bool b) {
}
};
@ -1315,35 +1338,29 @@ private:
filename=A.cpp
warnings=1
//@A.cpp
struct other
{
struct other {
bool /*$*/value/*$$*/() { return true; }
};
class Klass
{
class Class {
public:
void set(bool b) {}
void test()
{
void test() {
other o;
this->set(o.value());
}
};
//=
struct other
{
struct other {
private:
bool value() { return true; }
};
class Klass
{
class Class {
public:
void set(bool b) {}
void test()
{
void test() {
other o;
this->set(o.value());
}
@ -1354,36 +1371,34 @@ public:
//@.config
filename=A.cpp
//@A.cpp
struct other
{
struct other {
bool value() { return true; }
};
class Klass
{
class Class {
public:
void set(bool b){}
void /*$*/test/*$$*/()
{
void set(bool b) {
}
void /*$*/test/*$$*/() {
other o;
this->set(o.value());
}
};
//=
struct other
{
struct other {
bool value() { return true; }
};
class Klass
{
class Class {
public:
void set(bool b){}
void set(bool b) {
}
private:
void test()
{
void test() {
other o;
this->set(o.value());
}
@ -1413,8 +1428,7 @@ int main(){
//@.config
filename=A.h
//@A.h
class Klass
{
class Class {
public:
void /*$*/to_move()/*$$*/;
@ -1423,8 +1437,7 @@ private:
};
//=
class Klass
{
class Class {
public:
private:
void just_private();
@ -1436,23 +1449,23 @@ private:
//@.config
filename=A.h
//@A.h
class Klass
{
class Class {
public:
void /*$*/to_move()/*$$*/;
private:
void just_private();
private:
};
//=
class Klass
{
class Class {
public:
private:
void just_private();
void to_move();
private:
};

View file

@ -11,6 +11,7 @@ public:
A();
void method2();
std::string toString();
private:
int i;
};
@ -27,6 +28,7 @@ class A{
public:
A();
std::string toString();
private:
int i;
void method2();
@ -40,5 +42,5 @@ private:
<refactoring comment="Hide Method method2" description="Hide Method Refactoring"
fileName="file:$$projectPath$$/A.h" flags="2"
id="org.eclipse.cdt.internal.ui.refactoring.hidemethod.HideMethodRefactoring"
project="RegressionTestProject" selection="83,7"/>
project="RegressionTestProject" selection="78,7"/>
</session>

View file

@ -15,12 +15,10 @@ public:
bool a(int = 100) const;
};
inline bool X::a(int int1) const
{
inline bool X::a(int int1) const {
}
//!Param const and reference and pointer two params
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -38,37 +36,34 @@ public:
bool xy(int, int i) const;
};
inline bool X::xy(int int1, int i) const
{
inline bool X::xy(int int1, int i) const {
}
//!Test if TemplateMethod stays in header
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
infos=1
//@A.h
template<class T> class A
{
template<class T>
class A {
public:
/*$*/void test();/*$$*/
};
//=
template<class T> class A
{
template<class T>
class A {
public:
void test();
};
template<class T> inline void A<T>::test()
{
template<class T>
inline void A<T>::test() {
}
//@A.cpp
#include "A.h"
@ -81,45 +76,42 @@ template<class T> inline void A<T>::test()
filename=A.h
infos=1
//@A.h
template<class T> class A
{
template<class T>
class A {
public:
A();
/*$*/void test();/*$$*/
};
template<class T> A<T>::A()
{
template<class T>
A<T>::A() {
}
//=
template<class T> class A
{
template<class T>
class A {
public:
A();
void test();
};
template<class T> A<T>::A()
{
template<class T>
A<T>::A() {
}
template<class T> inline void A<T>::test()
{
template<class T>
inline void A<T>::test() {
}
//!member class
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
//@A.h
class Demo
{
class SubClass
{
class Demo {
class SubClass {
/*$*/void test();/*$$*/
};
};
@ -131,51 +123,41 @@ class Demo
//=
#include "A.h"
void Demo::SubClass::test()
{
void Demo::SubClass::test() {
}
//!method declared in otherwise empty class without cpp file
//!Method declared in otherwise empty class without cpp file
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
infos=1
//@A.h
class A
{
class A {
public:
/*$*/void test();/*$$*/
};
//=
class A
{
class A {
public:
void test();
};
inline void A::test()
{
inline void A::test() {
}
//!method declared in otherwise empty class
//!Method declared in otherwise empty class
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
//@A.h
class A
{
class A {
public:
/*$*/void test();/*$$*/
};
//=
class A
{
class A {
public:
void test();
};
@ -184,49 +166,45 @@ public:
//=
void A::test()
{
void A::test() {
}
//!implement in existing namespace
//!Implement in existing namespace
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
//@A.h
namespace NameSpace
{
class ClassInNamespace
{
namespace Namespace {
class ClassInNamespace {
public:
int test();
/*$*/void test2();/*$$*/
};
}
//@A.cpp
#include "A.h"
namespace NameSpace
{
int ClassInNamespace::test()
{
namespace Namespace {
int ClassInNamespace::test() {
return 5;
}
}
//=
#include "A.h"
namespace NameSpace
{
int ClassInNamespace::test()
{
namespace Namespace {
int ClassInNamespace::test() {
return 5;
}
void ClassInNamespace::test2()
{}
void ClassInNamespace::test2() {
}
}
//!virtual method in the middle of con/destructor, without parameters and void return value
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
@ -236,8 +214,7 @@ filename=A.h
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
/*$*/virtual void foo();/*$$*/
@ -248,30 +225,25 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
A::~A()
{
A::~A() {
}
//=
#include "A.h"
A::A()
{
A::A() {
}
void A::foo()
{
void A::foo() {
}
A::~A()
{
A::~A() {
}
//!implement a function at start of source file
//!Implement a function at start of source file
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -279,18 +251,15 @@ filename=A.h
/*$*/void function();/*$$*/
void function_with_impl();
//@A.cpp
void function_with_impl()
{
void function_with_impl() {
}
//=
void function()
{
void function() {
}
void function_with_impl()
{
void function_with_impl() {
}
//!method at end, without parameters and void return value
//!Method at end, without parameters and void return value
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -298,8 +267,7 @@ filename=A.h
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
/*$*/void foo();/*$$*/
@ -309,24 +277,20 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
//=
#include "A.h"
A::A()
{
A::A() {
}
void A::foo()
{
void A::foo() {
}
//!method at beginning, without parameters, void return value and const
//!Method at beginning, without parameters, void return value and const
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -334,8 +298,7 @@ filename=A.h
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
/*$*/void foo() const;/*$$*/
A();
@ -345,22 +308,19 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
//=
#include "A.h"
void A::foo() const
{
void A::foo() const {
}
A::A()
{
A::A() {
}
//!method with int return value
//!Method with int return value
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -368,8 +328,7 @@ filename=A.h
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
/*$*/int foo();/*$$*/
@ -379,24 +338,20 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
//=
#include "A.h"
A::A()
{
A::A() {
}
int A::foo()
{
int A::foo() {
}
//!method with two int parameters
//!Method with two int parameters
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -404,8 +359,7 @@ filename=A.h
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
/*$*/int foo(int param1, int param2);/*$$*/
@ -415,59 +369,49 @@ public:
//@A.cpp
#include "A.h"
A::A()
{
A::A() {
}
//=
#include "A.h"
A::A()
{
A::A() {
}
int A::foo(int param1, int param2)
{
int A::foo(int param1, int param2) {
}
//!method defined in header
//!Method defined in header
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
infos=1
//@A.h
class A
{
class A {
public:
A();
/*$*/void test();/*$$*/
};
A::A()
{
A::A() {
}
//=
class A
{
class A {
public:
A();
void test();
};
A::A()
{
A::A() {
}
inline void A::test()
{
inline void A::test() {
}
//!implement a function at end of source file
//!Implement a function at end of source file
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -475,112 +419,110 @@ filename=A.h
void function_with_impl();
/*$*/void function();/*$$*/
//@A.cpp
void function_with_impl()
{
void function_with_impl() {
}
//=
void function_with_impl()
{
void function_with_impl() {
}
void function()
{
void function() {
}
//!implement with namespace
//!Implement with namespace
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
//@A.h
namespace NameSpace
{
class ClassInNamespace
{
namespace Namespace {
class ClassInNamespace {
public:
int other_test();
/*$*/void test();/*$$*/
};
}
//@A.cpp
#include "A.h"
void NameSpace::ClassInNamespace::other_test()
{
void Namespace::ClassInNamespace::other_test() {
}
//=
#include "A.h"
void NameSpace::ClassInNamespace::other_test()
{
void Namespace::ClassInNamespace::other_test() {
}
void NameSpace::ClassInNamespace::test()
{
void Namespace::ClassInNamespace::test() {
}
//!implement function within namespace
//!Implement function within namespace
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
//@A.h
namespace OuterSpace {
namespace NameSpace
{
namespace Namespace {
int test();
/*$*/int test2();/*$$*/
}
}
//@A.cpp
#include "A.h"
namespace OuterSpace {
int NameSpace::test()
{
int Namespace::test() {
}
}
//=
#include "A.h"
namespace OuterSpace {
int NameSpace::test()
{
int Namespace::test() {
}
int NameSpace::test2()
{}
int Namespace::test2() {
}
//!implement function within namespaces
}
//!Implement function within namespaces
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
//@A.h
namespace OuterSpace {
namespace NameSpace
{
namespace Namespace {
int test();
/*$*/int test2();/*$$*/
}
}
//@A.cpp
#include "A.h"
namespace OuterSpace {
namespace NameSpace {
int test()
{
namespace Namespace {
int test() {
}
}
}
//=
#include "A.h"
namespace OuterSpace {
namespace NameSpace {
int test()
{
namespace Namespace {
int test() {
}
int test2() {
}
int test2()
{}
}
}
//!class template member functions with multiple templates
@ -589,43 +531,41 @@ namespace OuterSpace {
filename=A.h
infos=1
//@A.h
template<class T, class U> class A
{
template<class T, class U>
class A {
public:
A();
/*$*/void test();/*$$*/
};
template<class T, class U> A<T,U>::A()
{
template<class T, class U>
A<T,U>::A() {
}
//=
template<class T, class U> class A
{
template<class T, class U>
class A {
public:
A();
void test();
};
template<class T, class U> A<T,U>::A()
{
template<class T, class U>
A<T,U>::A() {
}
template<class T, class U> inline void A<T,U>::test()
{
template<class T, class U>
inline void A<T, U>::test() {
}
//!with default parameters
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
//@A.h
class Class
{
class Class {
public:
/*$*/void test(int param1, int param2 = 5, int param3 = 10);/*$$*/
};
@ -637,20 +577,15 @@ public:
//=
#include "A.h"
void Class::test(int param1, int param2, int param3)
{
void Class::test(int param1, int param2, int param3) {
}
//!static method
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
//@A.h
class Class
{
class Class {
public:
/*$*/static void test();/*$$*/
};
@ -662,12 +597,8 @@ public:
//=
#include "A.h"
void Class::test()
{
void Class::test() {
}
//! Bug 238253 Pointer refence of the return value lost
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -686,20 +617,15 @@ public:
//=
#include "A.h"
int *TestClass::get(char *val)
{
int* TestClass::get(char* val) {
}
//! Bug 238554 void parameters
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
//@A.h
class Test
{
class Test {
public:
/*$*/void doNothing(void);/*$$*/
};
@ -711,12 +637,8 @@ class Test
//=
#include "A.h"
void Test::doNothing(void)
{
void Test::doNothing(void) {
}
//! Bug 282989 Refactor->Implement method option doesn't qualify the name in the method definition with a fully qualified container class name
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -727,9 +649,11 @@ infos=1
#define TESTCLASS_H_
namespace nspace {
class TestClass {
void /*$*/testMethod()/*$$*/;
};
}
#endif /* TESTCLASS_H_ */
@ -739,17 +663,17 @@ void /*$*/testMethod()/*$$*/;
#define TESTCLASS_H_
namespace nspace {
class TestClass {
void testMethod();
};
}
inline void nspace::TestClass::testMethod()
{
inline void nspace::TestClass::testMethod() {
}
#endif /* TESTCLASS_H_ */
//!Bug 290110 Source-> Implement Method
@ -768,6 +692,7 @@ public:
A();
~A();
void testmethod(int x);
protected:
class B {
public:
@ -810,12 +735,10 @@ A::~A() {
}
}
void n1::n2::A::B::testmethod2()
{
void n1::n2::A::B::testmethod2() {
}
//!Bug 337040 - Insert definition in empty implementation file (.cxx)
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -832,12 +755,8 @@ public:
//=
void TestClass::foo()
{
void TestClass::foo() {
}
//!Bug 355006 - NPE implementing template function
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -845,15 +764,14 @@ filename=A.h
infos=1
//@A.h
/*$*/template<typename T> void func(T&);/*$$*/
/*$*/template<typename T>
void func(T&);/*$$*/
//=
template<typename T> void func(T&);
template<typename T>
void func(T&);
template<typename T> inline void func(T& )
{
template<typename T>
inline void func(T&) {
}

View file

@ -17,8 +17,7 @@ void freefunction();
#include "A.h"
void freefunction()
{
void freefunction() {
return;
}
//!FreefunctionFromImplToHeader
@ -28,8 +27,7 @@ filename=A.cpp
newfilecreation=true
newfiles=A.h
//@A.cpp
void /*$*/freefunction/*$$*/()
{
void /*$*/freefunction/*$$*/() {
return;
}
//=
@ -40,8 +38,7 @@ void /*$*/freefunction/*$$*/()
//=
void freefunction()
{
void freefunction() {
return;
}

View file

@ -14,9 +14,7 @@ class A {
using namespace std;
class A {
int member()
{
int member() {
return int();
}
};

View file

@ -4,8 +4,7 @@
filename=A.h
//@A.h
class A {
void /*$*/member/*$$*/()
{
void /*$*/member/*$$*/() {
// return comment
return;
}
@ -15,13 +14,11 @@ class A {
void member();
};
inline void A::member()
{
inline void A::member() {
// return comment
return;
}
//!ClassToHeaderTopCommentOrder
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -30,8 +27,7 @@ filename=A.h
class A {
// First Top Comment
// Second Top Comment
void /*$*/member/*$$*/()
{
void /*$*/member/*$$*/() {
return;
}
};
@ -42,12 +38,10 @@ class A {
void member();
};
inline void A::member()
{
inline void A::member() {
return;
}
//!ClassToHeaderCatchComment
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -57,7 +51,8 @@ class A {
void /*$*/member/*$$*/() try
{
return;
} catch (int i) {
}
catch (int i) {
// catch comment
}
};
@ -67,15 +62,13 @@ class A {
};
inline void A::member()
try
{
try {
return;
}
catch (int i) {
// catch comment
}
//!ClassToHeaderTopComment
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -83,8 +76,7 @@ filename=A.h
//@A.h
class A {
// Top comment
void /*$*/member/*$$*/()
{
void /*$*/member/*$$*/() {
return;
}
};
@ -94,12 +86,10 @@ class A {
void member();
};
inline void A::member()
{
inline void A::member() {
return;
}
//!ClassToHeaderTemplateTopComment
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -108,8 +98,7 @@ filename=A.h
class A {
// Top comment
template<typename T>
T /*$*/member/*$$*/()
{
T /*$*/member/*$$*/() {
return T();
}
};
@ -122,20 +111,18 @@ class A {
};
// Top comment
template<typename T> inline T A::member()
{
template<typename T>
inline T A::member() {
return T();
}
//!ClassToHeaderTrailingComment
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
class A {
void /*$*/member/*$$*/()
{
void /*$*/member/*$$*/() {
return;
} // Trailing comment
};
@ -144,22 +131,21 @@ class A {
void member();
};
inline void A::member()
{
inline void A::member() {
return;
} // Trailing comment
//!ClassToHeaderTrailingCommentWithTryBlock
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
class A {
void /*$*/member/*$$*/() try
{
void /*$*/member/*$$*/()
try {
return;
} catch (int e) {
}
catch (int e) {
} // Trailing comment
};
//=
@ -168,22 +154,20 @@ class A {
};
inline void A::member()
try
{
try {
return;
}
catch (int e) {
}
// Trailing comment
//!ClassToHeaderTrailingMultipleCommentsInTryBlock
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
class A {
int /*$*/member/*$$*/() try
{
int /*$*/member/*$$*/()
try {
// aans
} /* one */ catch (int i) {
// zwaa
@ -197,8 +181,7 @@ class A {
};
inline int A::member()
try
{
try {
// aans
} /* one */
catch (int i) {
@ -208,4 +191,3 @@ catch(int i){
// draa
}
/* three */

View file

@ -8,15 +8,15 @@ class A {
T /*$*/member/*$$*/();
};
template<typename T> inline T A<T>::member() {
template<typename T>
inline T A<T>::member() {
// body comment
return T();
}
//=
template<typename T>
class A {
T member()
{
T member() {
// body comment
return T();
}
@ -38,8 +38,7 @@ class A {
// Third comment
// Fourth comment
template<typename T>
inline T A<T>::member()
{
inline T A<T>::member() {
return T();
}
//=
@ -49,8 +48,7 @@ class A {
// Fourth comment
// First comment
// Second comment
T member()
{
T member() {
return T();
}
};
@ -68,20 +66,23 @@ class A {
T /*$*/member/*$$*/();
};
template<typename T> inline T A<T>::member() try {
template<typename T>
inline T A<T>::member()
try {
// body comment
return T();
} catch(int e) {
}
catch (int e) {
// Catch 1
} catch(int e) {
}
catch (int e) {
// Catch 2
}
//=
template<typename T>
class A {
T member()
try
{
try {
// body comment
return T();
}
@ -118,13 +119,11 @@ template<typename S, typename T>
class A {
// Top Comment
template<typename U, typename V>
T member()
{
T member() {
// body comment
return T();
}
};
// 2nd Top Comment
@ -140,15 +139,15 @@ class A {
};
// Top comment
template<typename T> inline T A<T>::member() {
template<typename T>
inline T A<T>::member() {
return T();
}
//=
template<typename T>
class A {
// Top comment
T member()
{
T member() {
return T();
}
};

View file

@ -22,13 +22,10 @@ class A {
//=
#include "A.h"
void A::member()
{
void A::member() {
// body comment
return;
}
//!HeaderToImplTryCatchComment
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -54,10 +51,8 @@ class A {
//=
#include "A.h"
void A::member()
try
{
try {
// body comment
return;
}
@ -67,7 +62,6 @@ catch(/*1*/int e){
catch (/*3*/int e) {
/*4*/
}
//!HeaderToImplTopComment
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -94,14 +88,11 @@ class A {
//=
#include "A.h"
// Top comment
void A::member()
{
void A::member() {
// body comment
return;
}
//!HeaderToImplFreeFuncTopComment
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -121,11 +112,7 @@ void member();
//=
#include "A.h"
// Definition comment
void member()
{
void member() {
return;
}

View file

@ -5,8 +5,7 @@ filename=A.cpp
//@A.cpp
#include "A.h"
void A::/*$*/member/*$$*/()
{
void A::/*$*/member/*$$*/() {
// body comment
return;
}
@ -20,8 +19,7 @@ class A {
};
//=
class A {
void member()
{
void member() {
// body comment
return;
}
@ -34,8 +32,7 @@ filename=A.cpp
#include "A.h"
// Definition comment
void A::/*$*/member/*$$*/()
{
void A::/*$*/member/*$$*/() {
return;
}
//=
@ -50,8 +47,7 @@ class A {
//=
class A {
// Definition comment
void member()
{
void member() {
return;
}
};
@ -63,8 +59,7 @@ filename=A.cpp
#include "A.h"
// Definition comment
void A::/*$*/member/*$$*/() try
{
void A::/*$*/member/*$$*/() try {
return;
} /*1*/ catch (int e) { /*2*/ } /*3*/ catch (int e) { /*4*/ }
//=
@ -80,8 +75,7 @@ class A {
class A {
// Definition comment
void member()
try
{
try {
return;
} /*1*/
catch (int e) {
@ -98,8 +92,7 @@ filename=A.cpp
//@A.cpp
#include "A.h"
void /*$*/member/*$$*/()
{
void /*$*/member/*$$*/() {
// body comment
return;
}
@ -111,14 +104,10 @@ void /*$*/member/*$$*/()
//=
void member()
{
void member() {
// body comment
return;
}
//!ImplToHeaderTopCommentWithoutDeclaration
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -127,8 +116,7 @@ filename=A.cpp
#include "A.h"
// Top comment
void /*$*/member/*$$*/()
{
void /*$*/member/*$$*/() {
// body comment
return;
}
@ -141,12 +129,8 @@ void /*$*/member/*$$*/()
//=
// Top comment
void member()
{
void member() {
// body comment
return;
}

View file

@ -9,12 +9,12 @@ class A {
private:
int a;
int b;
public:
/*$*/A/*$$*/(int x, int y)
:a(x), b(y)
{}
~A()
{
/*$*/A/*$$*/(int x, int y) :
a(x), b(y) {
}
~A() {
}
};
//=
@ -24,19 +24,17 @@ class A {
private:
int a;
int b;
public:
A(int x, int y);
~A()
{
~A() {
}
};
inline A::A(int x, int y)
:a(x), b(y)
{
inline A::A(int x, int y) :
a(x), b(y) {
}
//!TestConstructorToggleInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -48,16 +46,15 @@ class A {
private:
int a;
int b;
public:
A(int x, int y);
~A()
{
~A() {
}
};
inline A::/*$*/A/*$$*/(int x, int y)
:a(x), b(y)
{
inline A::/*$*/A/*$$*/(int x, int y) :
a(x), b(y) {
}
//=
#include <iostream>
@ -66,10 +63,10 @@ class A {
private:
int a;
int b;
public:
A(int x, int y);
~A()
{
~A() {
}
};
@ -87,12 +84,10 @@ int main() {
return 0;
}
A::A(int x, int y)
:a(x), b(y)
{
A::A(int x, int y) :
a(x), b(y) {
}
//!TestConstructorToggleInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -100,9 +95,8 @@ filename=A.cpp
//@A.cpp
#include "A.h"
A::/*$*/A/*$$*/(int x, int y)
:a(x), b(y)
{
A::/*$*/A/*$$*/(int x, int y) :
a(x), b(y) {
}
int main() {
@ -121,20 +115,17 @@ int main() {
class A {
A(int x, int y);
~A()
{
~A() {
}
};
//=
#include <iostream>
class A {
A(int x, int y)
:a(x), b(y)
{
A(int x, int y) :
a(x), b(y) {
}
~A()
{
~A() {
}
};
//!TestDestructorToggleInClassToInHeader
@ -148,9 +139,10 @@ class A {
private:
int a;
int b;
public:
/*$*/~A/*$$*/()
{}
/*$*/~A/*$$*/() {
}
};
//=
#include <iostream>
@ -159,15 +151,14 @@ class A {
private:
int a;
int b;
public:
~A();
};
inline A::~A()
{
inline A::~A() {
}
//!TestDestructorToggleInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -179,12 +170,12 @@ class A {
private:
int a;
int b;
public:
~A();
};
inline /*$*/A::~A/*$$*/()
{
inline /*$*/A::~A/*$$*/() {
}
//=
#include <iostream>
@ -193,6 +184,7 @@ class A {
private:
int a;
int b;
public:
~A();
};
@ -211,11 +203,9 @@ int main() {
return 0;
}
A::~A()
{
A::~A() {
}
//!TestDestructorToggleInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -223,8 +213,7 @@ filename=A.cpp
//@A.cpp
#include "A.h"
/*$*/A::~A/*$$*/()
{
/*$*/A::~A/*$$*/() {
int x;
int y;
return;
@ -245,20 +234,19 @@ int main() {
#include <iostream>
class A {
A(int x, int y)
:a(x), b(y)
{}
A(int x, int y) :
a(x), b(y) {
}
~A();
};
//=
#include <iostream>
class A {
A(int x, int y)
:a(x), b(y)
{}
~A()
{
A(int x, int y) :
a(x), b(y) {
}
~A() {
int x;
int y;
return;

View file

@ -6,8 +6,7 @@ filename=A.h
#include <iostream>
class A {
void /*$*/member/*$$*/(int a=0, int b=0)
{
void /*$*/member/*$$*/(int a = 0, int b = 0) {
return;
}
};
@ -18,12 +17,10 @@ class A {
void member(int a = 0, int b = 0);
};
inline void A::member(int a, int b)
{
inline void A::member(int a, int b) {
return;
}
//!TestDefaultParameterInitializerInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -35,8 +32,7 @@ class A {
void member(int a = 0, int b = 0);
};
inline void /*$*/A::member/*$$*/(int a, int b)
{
inline void /*$*/A::member/*$$*/(int a, int b) {
return;
}
//=
@ -60,12 +56,10 @@ int main() {
return 0;
}
void A::member(int a, int b)
{
void A::member(int a, int b) {
return;
}
//!TestDefaultParameterInitializerInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -73,13 +67,11 @@ filename=A.cpp
//@A.cpp
#include "A.h"
void A::/*$*/member/*$$*/(int a, int b)
{
void A::/*$*/member/*$$*/(int a, int b) {
return;
}
int main()
{
int main() {
return 0;
}
//=
@ -87,8 +79,7 @@ int main()
int main()
{
int main() {
return 0;
}
//@A.h
@ -101,8 +92,7 @@ class A {
#include <iostream>
class A {
void member(int a = 0, int b = 0)
{
void member(int a = 0, int b = 0) {
return;
}
};

View file

@ -9,8 +9,7 @@ int main() {
return 0;
}
void N::A::/*$*/foo/*$$*/()
{
void N::A::/*$*/foo/*$$*/() {
return;
}
//=
@ -26,21 +25,24 @@ int main() {
#include <exception>
namespace N {
class A {
void foo();
};
}
//=
#include <iostream>
#include <exception>
namespace N {
class A {
void foo()
{
void foo() {
return;
}
};
}
//!TestImplementationToClassWithDeclarationSelected
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
@ -51,9 +53,11 @@ filename=A.h
#include <exception>
namespace N {
class A {
void /*$*/foo/*$$*/();
};
}
//=
@ -61,12 +65,13 @@ namespace N {
#include <exception>
namespace N {
class A {
void foo()
{
void foo() {
return;
}
};
}
//@A.cpp
@ -75,8 +80,8 @@ namespace N {
int main() {
return 0;
}
void N::A::foo()
{
void N::A::foo() {
return;
}
//=
@ -86,3 +91,4 @@ int main() {
return 0;
}

View file

@ -7,9 +7,9 @@ fatalerror=true
class A {
public:
void foo()
{
void foo() {
}
private:
int /*$*/x/*$$*/;
};
@ -28,8 +28,7 @@ public:
//@A.cpp
#include "A.h"
int main()
{
int main() {
return 0;
}
@ -60,8 +59,7 @@ class A {
//@A.cpp
#include "A.h"
int main()
{
int main() {
return 0;
}
@ -74,26 +72,21 @@ fatalerror=true
class A {
void foo();
void /*$*/foo/*$$*/()
{
void /*$*/foo/*$$*/() {
return;
}
};
void blah()
{
void blah() {
}
inline void A::foo()
{
inline void A::foo() {
return;
}
//@A.cpp
#include "A.h"
int main()
{
int main() {
return 0;
}
@ -105,8 +98,7 @@ fatalerror=true
#include <iostream>
class A {
void foo()
{
void foo() {
void /*$*/bar/*$$*/() {
}
}

View file

@ -9,12 +9,12 @@ class A {
private:
int a;
int b;
public:
A(int x, int y)
:a(x), b(y)
{}
~A()
{
A(int x, int y) :
a(x), b(y) {
}
~A() {
}
};
@ -28,12 +28,12 @@ class A {
private:
int a;
int b;
public:
A(int x, int y)
:a(x), b(y)
{}
~A()
{
A(int x, int y) :
a(x), b(y) {
}
~A() {
}
};
@ -52,12 +52,10 @@ int main() {
return 0;
}
int freeFunction(int *a, int & b)
{
int freeFunction(int* a, int& b) {
return 42;
}
//!TestFreeFunctionToggleFromImplementationToHeaderWithDeclaration
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -69,8 +67,7 @@ int main() {
return 0;
}
int /*$*/freeFunction/*$$*/(int *a, int & b)
{
int /*$*/freeFunction/*$$*/(int* a, int& b) {
return 42;
}
//=
@ -88,12 +85,12 @@ class A {
private:
int a;
int b;
public:
A(int x, int y)
:a(x), b(y)
{}
~A()
{
A(int x, int y) :
a(x), b(y) {
}
~A() {
}
};
@ -105,21 +102,19 @@ class A {
private:
int a;
int b;
public:
A(int x, int y)
:a(x), b(y)
{}
~A()
{
A(int x, int y) :
a(x), b(y) {
}
~A() {
}
};
int freeFunction(int *a, int & b)
{
int freeFunction(int* a, int& b) {
return 42;
}
//!TestFreeFunctionToggleFromImplementationToHeaderWithOutDeclaration
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -134,8 +129,8 @@ int main() {
int /*$*/freeFunction/*$$*/(int* a, int& b)
try {
return 42;
} catch (std::exception & e)
{
}
catch (std::exception& e) {
}
//=
#include "A.h"
@ -152,12 +147,12 @@ class A {
private:
int a;
int b;
public:
A(int x, int y)
:a(x), b(y)
{}
~A()
{
A(int x, int y) :
a(x), b(y) {
}
~A() {
}
};
@ -168,32 +163,29 @@ class A {
private:
int a;
int b;
public:
A(int x, int y)
:a(x), b(y)
{}
~A()
{
A(int x, int y) :
a(x), b(y) {
}
~A() {
}
};
int freeFunction(int* a, int& b)
try
{
try {
return 42;
}
catch (std::exception& e) {
}
//!TestFreeFunction
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
int /*$*/freeFunction/*$$*/()
{
int /*$*/freeFunction/*$$*/() {
return 42;
}
//=
@ -204,12 +196,9 @@ int freeFunction();
//=
#include "A.h"
int freeFunction()
{
int freeFunction() {
return 42;
}
//!TestQualifiedNameToggle
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -218,18 +207,15 @@ fatalerror=true
//@A.cpp
#include "A.h"
int /*$*/A::freefunction/*$$*/()
{
int /*$*/A::freefunction/*$$*/() {
return 42;
}
//=
#include "A.h"
int A::freefunction()
{
int A::freefunction() {
return 42;
}
//!TestNamespacedFreeFunction
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -241,10 +227,11 @@ filename=A.h
#include <iostream>
namespace N {
void /*$*/freefunction/*$$*/()
{
void /*$*/freefunction/*$$*/() {
return;
}
}
#endif /* A_H_ */
@ -255,7 +242,9 @@ namespace N {
#include <iostream>
namespace N {
void freefunction();
}
#endif /* A_H_ */
@ -272,10 +261,9 @@ int main() {
return 0;
}
namespace N
{
void freefunction()
{
namespace N {
void freefunction() {
return;
}

View file

@ -7,24 +7,28 @@ filename=A.h
#include <exception>
namespace N {
class A {
void /*$*/foo/*$$*/() {
return;
}
};
}
//=
#include <iostream>
#include <exception>
namespace N {
class A {
void foo();
};
inline void A::foo()
{
inline void A::foo() {
return;
}
}
//!TestSimpleNamespaceInHeaderToImplementationWithinNSDefinition
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
@ -35,22 +39,26 @@ filename=A.h
#include <exception>
namespace N {
class A {
void foo();
};
inline void A::/*$*/foo/*$$*/()
{
inline void A::/*$*/foo/*$$*/() {
return;
}
}
//=
#include <iostream>
#include <exception>
namespace N {
class A {
void foo();
};
}
//@A.cpp
#include "A.h"
@ -65,10 +73,9 @@ int main() {
return 0;
}
namespace N
{
void A::foo()
{
namespace N {
void A::foo() {
return;
}
@ -83,11 +90,12 @@ filename=A.h
#include <exception>
namespace N {
class A {
void foo();
};
inline void A::/*$*/foo/*$$*/()
{
inline void A::/*$*/foo/*$$*/() {
return;
}
@ -97,6 +105,7 @@ namespace N {
#include <exception>
namespace N {
class A {
void foo();
};
@ -109,8 +118,7 @@ int main() {
return 0;
}
namespace N
{
namespace N {
}
//=
#include "A.h"
@ -119,10 +127,9 @@ int main() {
return 0;
}
namespace N
{
void A::foo()
{
namespace N {
void A::foo() {
return;
}
}
@ -135,13 +142,14 @@ filename=A.h
#include <exception>
namespace N {
class A {
void foo();
};
}
inline void /*$*/N::A::foo/*$$*/()
{
inline void /*$*/N::A::foo/*$$*/() {
return;
}
//=
@ -149,9 +157,11 @@ inline void /*$*/N::A::foo/*$$*/()
#include <exception>
namespace N {
class A {
void foo();
};
}
@ -168,10 +178,9 @@ int main() {
return 0;
}
namespace N
{
void A::foo()
{
namespace N {
void A::foo() {
return;
}
@ -184,13 +193,11 @@ filename=A.cpp
//@A.cpp
#include "A.h"
void /*$*/N::A::foo/*$$*/()
{
void /*$*/N::A::foo/*$$*/() {
return;
}
int main()
{
int main() {
return 0;
}
//=
@ -198,28 +205,30 @@ int main()
int main()
{
int main() {
return 0;
}
//@A.h
#include <iostream>
namespace N {
class A {
void foo();
};
}
//=
#include <iostream>
namespace N {
class A {
void foo()
{
void foo() {
return;
}
};
}
//!TestRemoveEmptyNamespaceFromImplentation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
@ -229,10 +238,11 @@ filename=A.cpp
#include "A.h"
namespace N {
void /*$*/A::foo/*$$*/()
{
void /*$*/A::foo/*$$*/() {
return;
}
}
//=
#include "A.h"
@ -242,18 +252,21 @@ namespace N {
#include <iostream>
namespace N {
class A {
void foo();
};
}
//=
#include <iostream>
namespace N {
class A {
void foo()
{
void foo() {
return;
}
};
}

View file

@ -21,12 +21,10 @@ class A {
};
};
inline void A::B::member(int a, int b)
{
inline void A::B::member(int a, int b) {
return;
}
//!TestNestedClassInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -40,8 +38,7 @@ class A {
};
};
inline void A::B::/*$*/member/*$$*/(int a, int b)
{
inline void A::B::/*$*/member/*$$*/(int a, int b) {
return;
}
//=
@ -57,24 +54,20 @@ class A {
//@A.cpp
#include "A.h"
int main()
{
int main() {
return 0;
}
//=
#include "A.h"
int main()
{
int main() {
return 0;
}
void A::B::member(int a, int b)
{
void A::B::member(int a, int b) {
return;
}
//!TestNestedClassInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -82,20 +75,17 @@ filename=A.cpp
//@A.cpp
#include "A.h"
int main()
{
int main() {
return 0;
}
void A::B::/*$*/member/*$$*/(int a, int b)
{
void A::B::/*$*/member/*$$*/(int a, int b) {
return;
}
//=
#include "A.h"
int main()
{
int main() {
return 0;
}
@ -113,8 +103,7 @@ class A {
class A {
class B {
void member(int a, int b)
{
void member(int a, int b) {
return;
}
};

View file

@ -8,21 +8,17 @@ filename=A.h
class A {
public:
void func1();
void /*$*/func2/*$$*/()
{
void /*$*/func2/*$$*/() {
}
void func3();
void func4()
{
void func4() {
}
};
inline void A::func1()
{
inline void A::func1() {
}
inline void A::func3()
{
inline void A::func3() {
}
//=
#include <iostream>
@ -32,21 +28,17 @@ public:
void func1();
void func2();
void func3();
void func4()
{
void func4() {
}
};
inline void A::func1()
{
inline void A::func1() {
}
inline void A::func2()
{
inline void A::func2() {
}
inline void A::func3()
{
inline void A::func3() {
}
//!TestCorrectOrderingInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
@ -60,13 +52,11 @@ public:
void func1();
void func2();
void func3();
void func4()
{
void func4() {
}
};
inline void A::/*$*/func2/*$$*/()
{
inline void A::/*$*/func2/*$$*/() {
return;
}
@ -78,8 +68,7 @@ public:
void func1();
void func2();
void func3();
void func4()
{
void func4() {
}
};
@ -88,40 +77,33 @@ public:
//@A.cpp
#include "A.h"
int main()
{
int main() {
return 0;
}
void A::func1()
{
void A::func1() {
return;
}
void A::func3()
{
void A::func3() {
return;
}
//=
#include "A.h"
int main()
{
int main() {
return 0;
}
void A::func1()
{
void A::func1() {
return;
}
void A::func2()
{
void A::func2() {
return;
}
void A::func3()
{
void A::func3() {
return;
}
//!TestCorrectTemplateOrderingInClassToInHeader
@ -135,20 +117,19 @@ template <typename T>
class A {
public:
void func1();
void /*$*/func2/*$$*/()
{
void /*$*/func2/*$$*/() {
}
void func3();
void func4()
{
void func4() {
}
};
template<typename T> inline void A<T>::func1()
{
template<typename T>
inline void A<T>::func1() {
}
template<typename T> inline void A<T>::func3()
{
template<typename T>
inline void A<T>::func3() {
}
//=
#include <iostream>
@ -159,20 +140,20 @@ public:
void func1();
void func2();
void func3();
void func4()
{
void func4() {
}
};
template<typename T> inline void A<T>::func1()
{
}
template<typename T> inline void A<T>::func2()
{
template<typename T>
inline void A<T>::func1() {
}
template<typename T> inline void A<T>::func3()
{
template<typename T>
inline void A<T>::func2() {
}
template<typename T>
inline void A<T>::func3() {
}
//!TestCorrectTemplateOrderingInHeaderToInClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
@ -187,19 +168,20 @@ public:
void func1();
void func2();
void func3();
void func4()
{
void func4() {
}
};
template<typename T> inline void A<T>::func1()
{
template<typename T>
inline void A<T>::func1() {
}
template<typename T> inline void A<T>::/*$*/func2/*$$*/()
{
template<typename T>
inline void A<T>::/*$*/func2/*$$*/() {
}
template<typename T> inline void A<T>::func3()
{
template<typename T>
inline void A<T>::func3() {
}
//=
#include <iostream>
@ -208,19 +190,19 @@ template <typename T>
class A {
public:
void func1();
void func2()
{
void func2() {
}
void func3();
void func4()
{
void func4() {
}
};
template<typename T> inline void A<T>::func1()
{
template<typename T>
inline void A<T>::func1() {
}
template<typename T> inline void A<T>::func3()
{
template<typename T>
inline void A<T>::func3() {
}

View file

@ -4,8 +4,7 @@
filename=A.h
//@A.h
class A {
void me/*$*//*$$*/mber()
{
void me/*$*//*$$*/mber() {
return;
}
};
@ -14,20 +13,17 @@ class A {
void member();
};
inline void A::member()
{
inline void A::member() {
return;
}
//!TestSubstringSelection
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
class A {
void m/*$*/e/*$$*/mber()
{
void m/*$*/e/*$$*/mber() {
return;
}
};
@ -36,20 +32,17 @@ class A {
void member();
};
inline void A::member()
{
inline void A::member() {
return;
}
//!TestBodySelection
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
class A {
void member()
{
void member() {
r/*$*//*$$*/eturn;
}
};
@ -58,20 +51,17 @@ class A {
void member();
};
inline void A::member()
{
inline void A::member() {
return;
}
//!TestBodySelectionWithConfusingName
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
class A {
void member()
{
void member() {
int /*$*/abcd/*$$*/ = 42;
return;
}
@ -81,21 +71,18 @@ class A {
void member();
};
inline void A::member()
{
inline void A::member() {
int abcd = 42;
return;
}
//!TestLeftBorderSelection
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
class A {
/*$*//*$$*/void member()
{
/*$*//*$$*/void member() {
return;
}
};
@ -104,20 +91,17 @@ class A {
void member();
};
inline void A::member()
{
inline void A::member() {
return;
}
//!TestRightBorderSelection
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
class A {
void member()
{
void member() {
return;
}/*$*//*$$*/
};
@ -126,20 +110,17 @@ class A {
void member();
};
inline void A::member()
{
inline void A::member() {
return;
}
//!TestOverlappingSelection
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
class A {
vo/*$*/id member()
{
vo/*$*/id member() {
ret/*$$*/urn;
}
};
@ -148,9 +129,7 @@ class A {
void member();
};
inline void A::member()
{
inline void A::member() {
return;
}

View file

@ -7,10 +7,10 @@ filename=A.h
class A {
public:
int /*$*/function/*$$*/()
{
int /*$*/function/*$$*/() {
return 0;
}
private:
int a;
};
@ -20,16 +20,15 @@ private:
class A {
public:
int function();
private:
int a;
};
inline int A::function()
{
inline int A::function() {
return 0;
}
//!TestSimpleFunctionInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -40,12 +39,12 @@ filename=A.h
class A {
public:
int function();
private:
int a;
};
inline int A::/*$*/function/*$$*/()
{
inline int A::/*$*/function/*$$*/() {
return 0;
}
//=
@ -54,6 +53,7 @@ inline int A::/*$*/function/*$$*/()
class A {
public:
int function();
private:
int a;
};
@ -72,12 +72,10 @@ int main() {
return 0;
}
int A::function()
{
int A::function() {
return 0;
}
//!TestSimpleFunctionInImplementationToInClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -85,13 +83,11 @@ filename=A.cpp
//@A.cpp
#include "A.h"
int A::/*$*/function/*$$*/()
{
int A::/*$*/function/*$$*/() {
return 0;
}
int main()
{
int main() {
return 0;
}
//=
@ -99,8 +95,7 @@ int main()
int main()
{
int main() {
return 0;
}
//@A.h
@ -109,6 +104,7 @@ int main()
class A {
public:
int function();
private:
int a;
};
@ -117,10 +113,10 @@ private:
class A {
public:
int function()
{
int function() {
return 0;
}
private:
int a;
};
@ -131,10 +127,11 @@ filename=MyClass.cpp
//@MyClass.cpp
#include "MyClass.h"
myClass::/*$*/myClass/*$$*/(int implname) : fVal(implname) {}
myClass::/*$*/myClass/*$$*/(int implname) :
fVal(implname) {
}
int main()
{
int main() {
return 0;
}
//=
@ -142,8 +139,7 @@ int main()
int main()
{
int main() {
return 0;
}
//@MyClass.h
@ -157,9 +153,8 @@ struct myClass {
struct myClass {
int fVal;
myClass(int implname)
:fVal(implname)
{
myClass(int implname) :
fVal(implname) {
}
};
@ -170,10 +165,11 @@ filename=MyClass.cpp
//@MyClass.cpp
#include "MyClass.h"
myClass::/*$*/myClass/*$$*/(int implname) : fVal(implname) {}
myClass::/*$*/myClass/*$$*/(int implname) :
fVal(implname) {
}
int main()
{
int main() {
return 0;
}
//=
@ -181,8 +177,7 @@ int main()
int main()
{
int main() {
return 0;
}
//@MyClass.h
@ -196,9 +191,8 @@ struct myClass {
struct myClass {
int fVal;
myClass(int implname)
:fVal(implname)
{
myClass(int implname) :
fVal(implname) {
}
};

View file

@ -8,8 +8,7 @@ filename=A.h
template <typename T, typename U>
class A {
class B {
T /*$*/member/*$$*/()
{
T /*$*/member/*$$*/() {
return T();
}
};
@ -24,12 +23,11 @@ class A {
};
};
template<typename T, typename U> inline T A<T,U>::B::member()
{
template<typename T, typename U>
inline T A<T, U>::B::member() {
return T();
}
//!TestTemplateFunctionInHeaderToInClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -42,11 +40,10 @@ class A {
class B {
T member();
};
};
template<typename T> inline T A<T>::B::/*$*/member/*$$*/()
{
template<typename T>
inline T A<T>::B::/*$*/member/*$$*/() {
return T();
}
//=
@ -55,12 +52,10 @@ template<typename T> inline T A<T>::B::/*$*/member/*$$*/()
template <typename T>
class A {
class B {
T member()
{
T member() {
return T();
}
};
};
@ -82,74 +77,65 @@ class A {
};
template<typename T> inline T A::foo()
{
template<typename T>
inline T A::foo() {
return T();
}
//!TestComplexTemplateFunctionFromInClassToInheader
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
template<typename T, typename S>
class A
{
class A {
public:
template<typename U, typename V>
void /*$*/foo/*$$*/(const U & u, const V &v)
{
void /*$*/foo/*$$*/(const U& u, const V& v) {
return;
}
};
//=
template<typename T, typename S>
class A
{
class A {
public:
template<typename U, typename V>
void foo(const U& u, const V& v);
};
template<typename T, typename S> template<typename U, typename V> inline void A<T,S>::foo(const U & u, const V & v)
{
template<typename T, typename S>
template<typename U, typename V>
inline void A<T, S>::foo(const U& u, const V& v) {
return;
}
//!TestComplexTemplateFunctionFromInHeaderToInClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
//@A.h
template<typename T, typename S>
class A
{
class A {
public:
template<typename U, typename V>
void /*$*/foo/*$$*/(const U& u, const V& v);
};
template<typename T, typename S> template<typename U, typename V> inline void A<T,S>::foo(const U & u, const V & v)
{
template<typename T, typename S>
template<typename U, typename V>
inline void A<T,S>::foo(const U& u, const V& v) {
return;
}
//=
template<typename T, typename S>
class A
{
class A {
public:
template<typename U, typename V>
void foo(const U & u, const V &v)
{
void foo(const U& u, const V& v) {
return;
}
};

View file

@ -8,11 +8,10 @@ filename=A.h
class A {
void /*$*/member/*$$*/(int a, int b)
try
{
try {
return;
} catch (std::exception & e1)
{
}
catch (std::exception& e1){
return;
}
};
@ -25,15 +24,13 @@ class A {
};
inline void A::member(int a, int b)
try
{
try {
return;
}
catch (std::exception& e1) {
return;
}
//!TestTryCatchFromInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -47,8 +44,7 @@ class A {
};
inline void /*$*/A::member/*$$*/(int a, int b)
try
{
try {
return;
}
catch (std::exception& e1) {
@ -77,15 +73,13 @@ int main() {
}
void A::member(int a, int b)
try
{
try {
return;
}
catch (std::exception& e1) {
return;
}
//!TestTryCatchFromInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -95,17 +89,14 @@ filename=A.cpp
#include "A.h"
void A::/*$*/member/*$$*/()
try
{
try {
return;
}
catch(std::exception & e1)
{
catch (std::exception& e1) {
return;
}
int main()
{
int main() {
return 0;
}
//=
@ -114,8 +105,7 @@ int main()
int main()
{
int main() {
return 0;
}
//@A.h
@ -129,8 +119,7 @@ class A {
class A {
void member()
try
{
try {
return;
}
catch (std::exception& e1) {
@ -147,14 +136,13 @@ filename=A.h
class A {
void /*$*/member/*$$*/(int a, int b)
try
{
try {
return;
} catch (std::exception & e1)
{
}
catch (std::exception& e1) {
return;
} catch (std::exception & e2)
{
}
catch (std::exception& e2) {
return;
}
};
@ -167,8 +155,7 @@ class A {
};
inline void A::member(int a, int b)
try
{
try {
return;
}
catch (std::exception& e1) {
@ -178,7 +165,6 @@ catch(std::exception & e2){
return;
}
//!TestMultipleTryCatchFromInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -192,8 +178,7 @@ class A {
};
inline void /*$*/A::member/*$$*/(int a, int b)
try
{
try {
return;
}
catch (std::exception& e1) {
@ -225,8 +210,7 @@ int main() {
}
void A::member(int a, int b)
try
{
try {
return;
}
catch (std::exception& e1) {
@ -236,7 +220,6 @@ catch(std::exception & e2){
return;
}
//!TestMultipleTryCatchFromInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -246,21 +229,17 @@ filename=A.cpp
#include "A.h"
void A::/*$*/member/*$$*/()
try
{
try {
return;
}
catch(std::exception & e1)
{
catch (std::exception& e1) {
return;
}
catch(std::exception & e2)
{
catch (std::exception& e2) {
return;
}
int main()
{
int main() {
return 0;
}
//=
@ -269,8 +248,7 @@ int main()
int main()
{
int main() {
return 0;
}
//@A.h
@ -284,8 +262,7 @@ class A {
class A {
void member()
try
{
try {
return;
}
catch (std::exception& e1) {

View file

@ -5,8 +5,7 @@ filename=A.h
//@A.h
class A {
virtual int /*$*/foo/*$$*/()
{
virtual int /*$*/foo/*$$*/() {
return 0;
}
};
@ -16,12 +15,10 @@ class A {
virtual int foo();
};
inline int A::foo()
{
inline int A::foo() {
return 0;
}
//!TestVirtualSpecifierFromInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//%CPP
@ -33,8 +30,7 @@ class A {
virtual int /*$*/foo/*$$*/();
};
inline int A::foo()
{
inline int A::foo() {
return 0;
}
//=
@ -47,24 +43,20 @@ class A {
//@A.cpp
#include "A.h"
int main()
{
int main() {
return 0;
}
//=
#include "A.h"
int main()
{
int main() {
return 0;
}
int A::foo()
{
int A::foo() {
return 0;
}
//!TestVirtualSpecifierFromImplementationToHeader
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -77,28 +69,24 @@ class A {
//=
class A {
virtual int foo()
{
virtual int foo() {
return 0;
}
};
//@A.cpp
#include "A.h"
int main()
{
int main() {
return 0;
}
int A::foo()
{
int A::foo() {
return 0;
}
//=
#include "A.h"
int main()
{
int main() {
return 0;
}

View file

@ -7,8 +7,7 @@ offset=27
#ifndef A_H_
#define A_H_
class A
{
class A {
public:
A();
void foo();
@ -25,8 +24,7 @@ offset=0
//@A.h
typedef int nummere;
class A
{
class A {
public:
A();
};

View file

@ -29,7 +29,7 @@ public class ExtractFunctionTestSuite extends TestSuite {
suite.addTest(RefactoringTester.suite("ExtractMethodPreprocessorRefactoringTests", "resources/refactoring/ExtractMethodPreprocessor.rts"));
suite.addTest(RefactoringTester.suite("Extract Function Templates Tests", "resources/refactoring/ExtractFunctionTemplates.rts"));
suite.addTest(RefactoringTester.suite("Extract Method History Test", "resources/refactoring/ExtractMethodHistory.rts"));
suite.addTest(RefactoringTester.suite("Extract Function Dublicates Test", "resources/refactoring/ExtractMethodDuplicates.rts"));
suite.addTest(RefactoringTester.suite("Extract Function Duplicates Test", "resources/refactoring/ExtractMethodDuplicates.rts"));
return suite;
}
}

View file

@ -885,7 +885,7 @@ public class ExtractFunctionRefactoring extends CRefactoring {
arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$
arguments.put(ExtractFunctionRefactoringDescription.NAME, info.getMethodName());
arguments.put(ExtractFunctionRefactoringDescription.VISIBILITY, info.getVisibility().toString());
arguments.put(ExtractFunctionRefactoringDescription.REPLACE_DUBLICATES, Boolean.toString(info.isReplaceDuplicates()));
arguments.put(ExtractFunctionRefactoringDescription.REPLACE_DUPLICATES, Boolean.toString(info.isReplaceDuplicates()));
return arguments;
}
}

View file

@ -32,7 +32,7 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
public class ExtractFunctionRefactoringDescription extends CRefactoringDescription {
protected static final String NAME = "name"; //$NON-NLS-1$
protected static final String VISIBILITY = "visibility"; //$NON-NLS-1$
protected static final String REPLACE_DUBLICATES = "replaceDuplicates"; //$NON-NLS-1$
protected static final String REPLACE_DUPLICATES = "replaceDuplicates"; //$NON-NLS-1$
public ExtractFunctionRefactoringDescription(String project, String description,
String comment, Map<String, String> arguments) {
@ -47,7 +47,7 @@ public class ExtractFunctionRefactoringDescription extends CRefactoringDescripti
info.setMethodName(arguments.get(NAME));
info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY)));
info.setReplaceDuplicates(Boolean.parseBoolean(arguments.get(REPLACE_DUBLICATES)));
info.setReplaceDuplicates(Boolean.parseBoolean(arguments.get(REPLACE_DUPLICATES)));
proj = getCProject();
file = getFile();