mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 13:55:39 +02:00
Merge remote-tracking branch 'cdt/master' into sd90
This commit is contained in:
commit
bbec91c5bc
194 changed files with 2589 additions and 2873 deletions
|
@ -273,7 +273,8 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
|
||||||
// of the language as long as the encoding is set to UTF-8.
|
// of the language as long as the encoding is set to UTF-8.
|
||||||
// English language is chosen because parser relies on English messages
|
// English language is chosen because parser relies on English messages
|
||||||
// in the output of the 'gcc -v' command.
|
// in the output of the 'gcc -v' command.
|
||||||
props.put("LC_ALL", "en_US.UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
|
props.put("LANGUAGE", "en"); // override for GNU gettext //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
props.put("LC_ALL", "en_US.UTF-8"); // for other parts of the system libraries //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class ASTWriterTest extends RewriteBaseTest {
|
||||||
|
|
||||||
IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo);
|
IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||||
|
|
||||||
ISourceCodeParser parser2 = null;
|
ISourceCodeParser parser = null;
|
||||||
if (language == ParserLanguage.CPP) {
|
if (language == ParserLanguage.CPP) {
|
||||||
ICPPParserExtensionConfiguration config = null;
|
ICPPParserExtensionConfiguration config = null;
|
||||||
if (useGNUExtensions) {
|
if (useGNUExtensions) {
|
||||||
|
@ -105,7 +105,7 @@ public class ASTWriterTest extends RewriteBaseTest {
|
||||||
} else {
|
} else {
|
||||||
config = new ANSICPPParserExtensionConfiguration();
|
config = new ANSICPPParserExtensionConfiguration();
|
||||||
}
|
}
|
||||||
parser2 = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
|
parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
|
||||||
} else {
|
} else {
|
||||||
ICParserExtensionConfiguration config = null;
|
ICParserExtensionConfiguration config = null;
|
||||||
|
|
||||||
|
@ -115,9 +115,9 @@ public class ASTWriterTest extends RewriteBaseTest {
|
||||||
config = new ANSICParserExtensionConfiguration();
|
config = new ANSICParserExtensionConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
|
parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
|
||||||
}
|
}
|
||||||
return parser2;
|
return parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getGNUExtension(TestSourceFile file) {
|
private boolean getGNUExtension(TestSourceFile file) {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -35,18 +34,17 @@ public class SourceRewriteTester extends TestSuite {
|
||||||
private static final String codeTypeRegexp = "//%(C|CPP)( GNU)?$"; //$NON-NLS-1$
|
private static final String codeTypeRegexp = "//%(C|CPP)( GNU)?$"; //$NON-NLS-1$
|
||||||
private static final String resultRegexp = "//=.*$"; //$NON-NLS-1$
|
private static final String resultRegexp = "//=.*$"; //$NON-NLS-1$
|
||||||
|
|
||||||
enum MatcherState{skip, inTest, inSource, inExpectedResult}
|
enum MatcherState { skip, inTest, inSource, inExpectedResult }
|
||||||
|
|
||||||
protected static BufferedReader createReader(String file) throws IOException {
|
protected static BufferedReader createReader(String file) throws IOException {
|
||||||
Bundle bundle = CTestPlugin.getDefault().getBundle();
|
Bundle bundle = CTestPlugin.getDefault().getBundle();
|
||||||
Path path = new Path(file);
|
Path path = new Path(file);
|
||||||
String file2 = FileLocator.toFileURL(FileLocator.find(bundle, path, null)).getFile();
|
file = FileLocator.toFileURL(FileLocator.find(bundle, path, null)).getFile();
|
||||||
return new BufferedReader(new FileReader(file2));
|
return new BufferedReader(new FileReader(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite(String name, String file)throws Exception {
|
public static Test suite(String name, String file)throws Exception {
|
||||||
BufferedReader in = createReader(file);
|
BufferedReader in = createReader(file);
|
||||||
|
|
||||||
ArrayList<RewriteBaseTest> testCases = createTests(in);
|
ArrayList<RewriteBaseTest> testCases = createTests(in);
|
||||||
in.close();
|
in.close();
|
||||||
return createSuite(testCases, name);
|
return createSuite(testCases, name);
|
||||||
|
@ -54,9 +52,7 @@ public class SourceRewriteTester extends TestSuite {
|
||||||
|
|
||||||
private static TestSuite createSuite(ArrayList<RewriteBaseTest> testCases, String name) {
|
private static TestSuite createSuite(ArrayList<RewriteBaseTest> testCases, String name) {
|
||||||
TestSuite suite = new TestSuite(name);
|
TestSuite suite = new TestSuite(name);
|
||||||
Iterator<RewriteBaseTest> it = testCases.iterator();
|
for (RewriteBaseTest subject : testCases) {
|
||||||
while (it.hasNext()) {
|
|
||||||
RewriteBaseTest subject = it.next();
|
|
||||||
suite.addTest(subject);
|
suite.addTest(subject);
|
||||||
}
|
}
|
||||||
return suite;
|
return suite;
|
||||||
|
@ -155,7 +151,8 @@ public class SourceRewriteTester extends TestSuite {
|
||||||
return ParserLanguage.C;
|
return ParserLanguage.C;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RewriteBaseTest createTestClass(String testName, ASTWriterTestSourceFile file) throws Exception {
|
private static RewriteBaseTest createTestClass(String testName, ASTWriterTestSourceFile file)
|
||||||
|
throws Exception {
|
||||||
ASTWriterTest test = new ASTWriterTest(testName, file);
|
ASTWriterTest test = new ASTWriterTest(testName, file);
|
||||||
TextSelection sel = file.getSelection();
|
TextSelection sel = file.getSelection();
|
||||||
if (sel != null) {
|
if (sel != null) {
|
||||||
|
|
|
@ -16,13 +16,11 @@ import junit.framework.TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Thomas Corbat
|
* @author Thomas Corbat
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class AppendTestSuite{
|
public class AppendTestSuite {
|
||||||
|
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
TestSuite suite = new TestSuite("Changegenerator Append Child Tests");
|
TestSuite suite = new TestSuite("ChangeGenerator Append Child Tests");
|
||||||
|
|
||||||
suite.addTest(ParameterTest.suite());
|
suite.addTest(ParameterTest.suite());
|
||||||
suite.addTest(ParameterToListTest.suite());
|
suite.addTest(ParameterToListTest.suite());
|
||||||
suite.addTest(PointerToParameterTest.suite());
|
suite.addTest(PointerToParameterTest.suite());
|
||||||
|
@ -32,7 +30,6 @@ public class AppendTestSuite{
|
||||||
suite.addTest(ArrayModifierTest.suite());
|
suite.addTest(ArrayModifierTest.suite());
|
||||||
suite.addTest(ExpressionTest.suite());
|
suite.addTest(ExpressionTest.suite());
|
||||||
suite.addTest(ArraySizeExpressionTest.suite());
|
suite.addTest(ArraySizeExpressionTest.suite());
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,13 +49,14 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof IASTArrayDeclarator) {
|
if (declarator instanceof IASTArrayDeclarator) {
|
||||||
IASTArrayDeclarator arrayDeclarator = (IASTArrayDeclarator)declarator;
|
IASTArrayDeclarator arrayDeclarator = (IASTArrayDeclarator) declarator;
|
||||||
arrayDeclarator.getArrayModifiers();
|
arrayDeclarator.getArrayModifiers();
|
||||||
IASTArrayModifier newModifier = new CPPASTArrayModifier();
|
IASTArrayModifier newModifier = new CPPASTArrayModifier();
|
||||||
IASTExpression expr = new CPPASTLiteralExpression(
|
IASTExpression expr = new CPPASTLiteralExpression(
|
||||||
IASTLiteralExpression.lk_integer_constant, "3".toCharArray()); //$NON-NLS-1$
|
IASTLiteralExpression.lk_integer_constant, "3".toCharArray()); //$NON-NLS-1$
|
||||||
newModifier.setConstantExpression(expr);
|
newModifier.setConstantExpression(expr);
|
||||||
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD, declarator, newModifier, null);
|
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD,
|
||||||
|
declarator, newModifier, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -39,8 +39,7 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitExpressions = true;
|
shouldVisitExpressions = true;
|
||||||
|
@ -53,8 +52,9 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
|
||||||
IASTTypeId id= newExpression.getTypeId();
|
IASTTypeId id= newExpression.getTypeId();
|
||||||
IASTArrayDeclarator dtor= (IASTArrayDeclarator) id.getAbstractDeclarator();
|
IASTArrayDeclarator dtor= (IASTArrayDeclarator) id.getAbstractDeclarator();
|
||||||
IASTArrayModifier[] mods= dtor.getArrayModifiers();
|
IASTArrayModifier[] mods= dtor.getArrayModifiers();
|
||||||
IASTArrayModifier add= new CPPASTArrayModifier(new CPPASTLiteralExpression(0, "5"));
|
IASTArrayModifier add= new CPPASTArrayModifier(new CPPASTLiteralExpression(0, "5".toCharArray()));
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.APPEND_CHILD, dtor, add, null);
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.APPEND_CHILD,
|
||||||
|
dtor, add, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -33,14 +33,13 @@ public class CtorChainInitializerTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "TestClass::TestClass(int a, int b):beta(b){\n}\n\n"; //$NON-NLS-1$
|
source = "TestClass::TestClass(int a, int b) :\n\t\tbeta(b) {\n}\n"; //$NON-NLS-1$
|
||||||
expectedSource = "TestClass::TestClass(int a, int b):beta(b), alpha(a){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "TestClass::TestClass(int a, int b) :\n\t\tbeta(b), alpha(a) {\n}\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarations = true;
|
shouldVisitDeclarations = true;
|
||||||
|
@ -49,12 +48,13 @@ public class CtorChainInitializerTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclaration decl) {
|
public int visit(IASTDeclaration decl) {
|
||||||
if (decl instanceof CPPASTFunctionDefinition) {
|
if (decl instanceof CPPASTFunctionDefinition) {
|
||||||
CPPASTFunctionDefinition fdef = (CPPASTFunctionDefinition)decl;
|
CPPASTFunctionDefinition fdef = (CPPASTFunctionDefinition) decl;
|
||||||
CPPASTIdExpression initExpr = new CPPASTIdExpression(new CPPASTName("a".toCharArray())); //$NON-NLS-1$
|
CPPASTIdExpression initExpr = new CPPASTIdExpression(new CPPASTName("a".toCharArray())); //$NON-NLS-1$
|
||||||
CPPASTName initName = new CPPASTName("alpha".toCharArray()); //$NON-NLS-1$
|
CPPASTName initName = new CPPASTName("alpha".toCharArray()); //$NON-NLS-1$
|
||||||
ICPPASTConstructorChainInitializer newInitializer = new CPPASTConstructorChainInitializer(initName, null);
|
ICPPASTConstructorChainInitializer newInitializer = new CPPASTConstructorChainInitializer(initName, null);
|
||||||
newInitializer.setInitializerValue(initExpr);
|
newInitializer.setInitializerValue(initExpr);
|
||||||
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD, fdef, newInitializer, null);
|
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD,
|
||||||
|
fdef, newInitializer, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -35,8 +35,8 @@ public class ExceptionTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int parameter){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int parameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int parameter) throw (int){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int parameter) throw (int) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,8 @@ public class ExceptionTest extends ChangeGeneratorTest {
|
||||||
exDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
exDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
||||||
exception.setDeclSpecifier(exDeclSpec);
|
exception.setDeclSpecifier(exDeclSpec);
|
||||||
exception.setAbstractDeclarator(exceptionDeclarator);
|
exception.setAbstractDeclarator(exceptionDeclarator);
|
||||||
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD, declarator, exception, null);
|
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD,
|
||||||
|
declarator, exception, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -33,8 +33,8 @@ public class ExpressionTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void main(){int s = 0, c = 0, h = 0;\ns = 3, h = 5;}"; //$NON-NLS-1$
|
source = "void main() {\n\tint s = 0, c = 0, h = 0;\n\ts = 3, h = 5;\n}"; //$NON-NLS-1$
|
||||||
expectedSource = "void main(){int s = 0, c = 0, h = 0;\ns = 3, h = 5, c = 9;}"; //$NON-NLS-1$
|
expectedSource = "void main() {\n\tint s = 0, c = 0, h = 0;\n\ts = 3, h = 5, c = 9;\n}"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,18 +49,19 @@ public class ExpressionTest extends ChangeGeneratorTest {
|
||||||
if (expression instanceof IASTExpressionList) {
|
if (expression instanceof IASTExpressionList) {
|
||||||
IASTExpressionList expressionList = (IASTExpressionList) expression;
|
IASTExpressionList expressionList = (IASTExpressionList) expression;
|
||||||
expressionList.getExpressions();
|
expressionList.getExpressions();
|
||||||
CPPASTBinaryExpression binEx = new CPPASTBinaryExpression(IASTBinaryExpression.op_assign, new CPPASTIdExpression(new CPPASTName("c".toCharArray())), new CPPASTLiteralExpression(0, "9")); //$NON-NLS-1$ //$NON-NLS-2$
|
CPPASTIdExpression idExpression = new CPPASTIdExpression(new CPPASTName("c".toCharArray()));
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.APPEND_CHILD, expressionList, binEx, null);
|
CPPASTBinaryExpression binEx = new CPPASTBinaryExpression(IASTBinaryExpression.op_assign,
|
||||||
|
idExpression, new CPPASTLiteralExpression(0, "9".toCharArray())); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.APPEND_CHILD,
|
||||||
|
expressionList, binEx, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
|
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return new ExpressionTest();
|
return new ExpressionTest();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ public class ParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int existing){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int existing) {\n}\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int existing, int newParameter){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int existing, int newParameter) {\n}\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public class ParameterTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
|
|
||||||
CPPASTParameterDeclaration insertedParameter = new CPPASTParameterDeclaration();
|
CPPASTParameterDeclaration insertedParameter = new CPPASTParameterDeclaration();
|
||||||
CPPASTDeclarator parameterDeclarator = new CPPASTDeclarator();
|
CPPASTDeclarator parameterDeclarator = new CPPASTDeclarator();
|
||||||
|
@ -59,7 +59,8 @@ public class ParameterTest extends ChangeGeneratorTest {
|
||||||
CPPASTSimpleDeclSpecifier parameterDeclSpec = new CPPASTSimpleDeclSpecifier();
|
CPPASTSimpleDeclSpecifier parameterDeclSpec = new CPPASTSimpleDeclSpecifier();
|
||||||
parameterDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
parameterDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
||||||
insertedParameter.setDeclSpecifier(parameterDeclSpec);
|
insertedParameter.setDeclSpecifier(parameterDeclSpec);
|
||||||
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD, functionDeclarator, insertedParameter, null);
|
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD,
|
||||||
|
functionDeclarator, insertedParameter, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -34,8 +34,8 @@ public class ParameterToListTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo() {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int newParameter){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int newParameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public class ParameterToListTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
|
|
||||||
CPPASTParameterDeclaration insertedParameter = new CPPASTParameterDeclaration();
|
CPPASTParameterDeclaration insertedParameter = new CPPASTParameterDeclaration();
|
||||||
CPPASTDeclarator parameterDeclarator = new CPPASTDeclarator();
|
CPPASTDeclarator parameterDeclarator = new CPPASTDeclarator();
|
||||||
|
@ -59,7 +59,8 @@ public class ParameterToListTest extends ChangeGeneratorTest {
|
||||||
CPPASTSimpleDeclSpecifier parameterDeclSpec = new CPPASTSimpleDeclSpecifier();
|
CPPASTSimpleDeclSpecifier parameterDeclSpec = new CPPASTSimpleDeclSpecifier();
|
||||||
parameterDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
parameterDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
||||||
insertedParameter.setDeclSpecifier(parameterDeclSpec);
|
insertedParameter.setDeclSpecifier(parameterDeclSpec);
|
||||||
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD, functionDeclarator, insertedParameter, null);
|
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD,
|
||||||
|
functionDeclarator, insertedParameter, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -31,8 +31,8 @@ public class PointerToParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int parameter){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int parameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int *parameter){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int *parameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,12 +46,13 @@ public class PointerToParameterTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
||||||
for (IASTParameterDeclaration curParam : parameters){
|
for (IASTParameterDeclaration curParam : parameters){
|
||||||
if (String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("parameter")){ //$NON-NLS-1$
|
if (String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("parameter")){ //$NON-NLS-1$
|
||||||
CPPASTPointer addedPointer = new CPPASTPointer();
|
CPPASTPointer addedPointer = new CPPASTPointer();
|
||||||
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD, curParam.getDeclarator(), addedPointer, null);
|
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD,
|
||||||
|
curParam.getDeclarator(), addedPointer, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ public class PointerToPointerParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int *parameter){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int *parameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int **parameter){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int **parameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,12 +46,13 @@ public class PointerToPointerParameterTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
||||||
for (IASTParameterDeclaration curParam : parameters){
|
for (IASTParameterDeclaration curParam : parameters){
|
||||||
if (String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("parameter")){ //$NON-NLS-1$
|
if (String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("parameter")){ //$NON-NLS-1$
|
||||||
CPPASTPointer addedPointer = new CPPASTPointer();
|
CPPASTPointer addedPointer = new CPPASTPointer();
|
||||||
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD, curParam.getDeclarator(), addedPointer, null);
|
ASTModification modification = new ASTModification(ModificationKind.APPEND_CHILD,
|
||||||
|
curParam.getDeclarator(), addedPointer, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,8 @@ public class AddDeclarationBug extends ChangeGeneratorTest {
|
||||||
returnTyp.setType(IASTSimpleDeclSpecifier.t_int);
|
returnTyp.setType(IASTSimpleDeclSpecifier.t_int);
|
||||||
newDecl.setDeclSpecifier(returnTyp);
|
newDecl.setDeclSpecifier(returnTyp);
|
||||||
|
|
||||||
IASTStandardFunctionDeclarator declarator = new CPPASTFunctionDeclarator(new CPPASTName("exp".toCharArray())); //$NON-NLS-1$
|
IASTStandardFunctionDeclarator declarator = new CPPASTFunctionDeclarator(
|
||||||
|
new CPPASTName("exp".toCharArray())); //$NON-NLS-1$
|
||||||
IASTSimpleDeclSpecifier paramTyp = new CPPASTSimpleDeclSpecifier();
|
IASTSimpleDeclSpecifier paramTyp = new CPPASTSimpleDeclSpecifier();
|
||||||
paramTyp.setType(IASTSimpleDeclSpecifier.t_int);
|
paramTyp.setType(IASTSimpleDeclSpecifier.t_int);
|
||||||
IASTDeclarator decl = new CPPASTDeclarator(new CPPASTName("i".toCharArray())); //$NON-NLS-1$
|
IASTDeclarator decl = new CPPASTDeclarator(new CPPASTName("i".toCharArray())); //$NON-NLS-1$
|
||||||
|
@ -77,7 +78,8 @@ public class AddDeclarationBug extends ChangeGeneratorTest {
|
||||||
declarator.addParameterDeclaration(param);
|
declarator.addParameterDeclaration(param);
|
||||||
newDecl.addDeclarator(declarator);
|
newDecl.addDeclarator(declarator);
|
||||||
|
|
||||||
ASTModification mod = new ASTModification(ModificationKind.APPEND_CHILD, classNode, newDecl, null);
|
ASTModification mod = new ASTModification(ModificationKind.APPEND_CHILD, classNode,
|
||||||
|
newDecl, null);
|
||||||
modStore.storeModification(null, mod);
|
modStore.storeModification(null, mod);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -60,7 +60,8 @@ public class ArrayModifierTest extends ChangeGeneratorTest {
|
||||||
IASTExpression expr =
|
IASTExpression expr =
|
||||||
new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, "5".toCharArray()); //$NON-NLS-1$
|
new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, "5".toCharArray()); //$NON-NLS-1$
|
||||||
newModifier.setConstantExpression(expr);
|
newModifier.setConstantExpression(expr);
|
||||||
ASTModification modification = new ASTModification(ModificationKind.INSERT_BEFORE, modifiers[0], newModifier, null);
|
ASTModification modification = new ASTModification(ModificationKind.INSERT_BEFORE,
|
||||||
|
modifiers[0], newModifier, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -59,7 +59,8 @@ public class ArraySizeExpressionTest extends ChangeGeneratorTest {
|
||||||
IASTArrayModifier[] mods= dtor.getArrayModifiers();
|
IASTArrayModifier[] mods= dtor.getArrayModifiers();
|
||||||
IASTArrayModifier add= new CPPASTArrayModifier(
|
IASTArrayModifier add= new CPPASTArrayModifier(
|
||||||
new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, "6".toCharArray()));
|
new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, "6".toCharArray()));
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.INSERT_BEFORE, mods[0], add, null);
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.INSERT_BEFORE,
|
||||||
|
mods[0], add, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -60,7 +60,6 @@ public class CtorChainInitializerTest extends ChangeGeneratorTest {
|
||||||
newInitializer.setInitializerValue(initExpr);
|
newInitializer.setInitializerValue(initExpr);
|
||||||
ASTModification modification = new ASTModification(ModificationKind.INSERT_BEFORE, ctorInitializer, newInitializer, null);
|
ASTModification modification = new ASTModification(ModificationKind.INSERT_BEFORE, ctorInitializer, newInitializer, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
|
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class ExceptionTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTTypeId existingException = functionDeclarator.getExceptionSpecification()[0];
|
IASTTypeId existingException = functionDeclarator.getExceptionSpecification()[0];
|
||||||
|
|
||||||
IASTTypeId exception = new CPPASTTypeId();
|
IASTTypeId exception = new CPPASTTypeId();
|
||||||
|
@ -64,9 +64,9 @@ public class ExceptionTest extends ChangeGeneratorTest {
|
||||||
exDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
exDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
||||||
exception.setDeclSpecifier(exDeclSpec);
|
exception.setDeclSpecifier(exDeclSpec);
|
||||||
exception.setAbstractDeclarator(exceptionDeclarator);
|
exception.setAbstractDeclarator(exceptionDeclarator);
|
||||||
ASTModification modification = new ASTModification(ModificationKind.INSERT_BEFORE, existingException, exception, null);
|
ASTModification modification = new ASTModification(ModificationKind.INSERT_BEFORE,
|
||||||
|
existingException, exception, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
|
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@ public class ExpressionTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void main(){int s = 0, c = 0, h = 0;\ns = 3, h = 5;}"; //$NON-NLS-1$
|
source = "void main() {\n\tint s = 0, c = 0, h = 0;\n\ts = 3, h = 5;\n}"; //$NON-NLS-1$
|
||||||
expectedSource = "void main(){int s = 0, c = 0, h = 0;\ns = 3, c = 9, h = 5;}"; //$NON-NLS-1$
|
expectedSource = "void main() {\n\tint s = 0, c = 0, h = 0;\n\ts = 3, c = 9, h = 5;\n}"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +54,11 @@ public class ExpressionTest extends ChangeGeneratorTest {
|
||||||
if (expression instanceof IASTExpressionList) {
|
if (expression instanceof IASTExpressionList) {
|
||||||
IASTExpressionList expressionList = (IASTExpressionList) expression;
|
IASTExpressionList expressionList = (IASTExpressionList) expression;
|
||||||
IASTExpression[] expressions = expressionList.getExpressions();
|
IASTExpression[] expressions = expressionList.getExpressions();
|
||||||
CPPASTBinaryExpression binEx = new CPPASTBinaryExpression(IASTBinaryExpression.op_assign, new CPPASTIdExpression(new CPPASTName("c".toCharArray())), new CPPASTLiteralExpression(0, "9")); //$NON-NLS-1$ //$NON-NLS-2$
|
CPPASTIdExpression idExpression = new CPPASTIdExpression(new CPPASTName("c".toCharArray())); //$NON-NLS-1$
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.INSERT_BEFORE, expressions[1], binEx, null);
|
CPPASTBinaryExpression binEx = new CPPASTBinaryExpression(IASTBinaryExpression.op_assign,
|
||||||
|
idExpression, new CPPASTLiteralExpression(0, "9".toCharArray())); //$NON-NLS-1$
|
||||||
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.INSERT_BEFORE,
|
||||||
|
expressions[1], binEx, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class FirstParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int a){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int a) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int newParameter, int a){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int newParameter, int a) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +54,10 @@ public class FirstParameterTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
||||||
for(IASTParameterDeclaration curParam : parameters){
|
for (IASTParameterDeclaration curParam : parameters){
|
||||||
if(String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("a")){ //$NON-NLS-1$
|
if (String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("a")){ //$NON-NLS-1$
|
||||||
CPPASTParameterDeclaration insertedParameter = new CPPASTParameterDeclaration();
|
CPPASTParameterDeclaration insertedParameter = new CPPASTParameterDeclaration();
|
||||||
CPPASTDeclarator parameterDeclarator = new CPPASTDeclarator();
|
CPPASTDeclarator parameterDeclarator = new CPPASTDeclarator();
|
||||||
CPPASTName parameterName = new CPPASTName("newParameter".toCharArray()); //$NON-NLS-1$
|
CPPASTName parameterName = new CPPASTName("newParameter".toCharArray()); //$NON-NLS-1$
|
||||||
|
@ -66,7 +66,8 @@ public class FirstParameterTest extends ChangeGeneratorTest {
|
||||||
CPPASTSimpleDeclSpecifier parameterDeclSpec = new CPPASTSimpleDeclSpecifier();
|
CPPASTSimpleDeclSpecifier parameterDeclSpec = new CPPASTSimpleDeclSpecifier();
|
||||||
parameterDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
parameterDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
||||||
insertedParameter.setDeclSpecifier(parameterDeclSpec);
|
insertedParameter.setDeclSpecifier(parameterDeclSpec);
|
||||||
ASTModification modification = new ASTModification(ModificationKind.INSERT_BEFORE, curParam, insertedParameter, null);
|
ASTModification modification = new ASTModification(ModificationKind.INSERT_BEFORE,
|
||||||
|
curParam, insertedParameter, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ public class MultilineWhitespaceHandlingTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
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$
|
source = "void foo() {\n\tfor (int i = 0; i < 10; i++) {\n\n\n\t}\n}\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$
|
expectedSource = "void foo() {\n\tfor (int i = 0; i < 10; i++) {\n\t\tint i;\n\t\tint j;\n\t}\n}\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,8 @@ public class MultilineWhitespaceHandlingTest extends ChangeGeneratorTest {
|
||||||
newSimpleDeclaration.addDeclarator(nf.newDeclarator(nf.newName(variableName.toCharArray())));
|
newSimpleDeclaration.addDeclarator(nf.newDeclarator(nf.newName(variableName.toCharArray())));
|
||||||
IASTDeclarationStatement newDeclaration = nf.newDeclarationStatement(newSimpleDeclaration);
|
IASTDeclarationStatement newDeclaration = nf.newDeclarationStatement(newSimpleDeclaration);
|
||||||
|
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.APPEND_CHILD, compoundStatement, newDeclaration, null);
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.APPEND_CHILD,
|
||||||
|
compoundStatement, newDeclaration, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,8 +36,8 @@ public class PointerParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int *parameter){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int *parameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int **parameter){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int **parameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,8 @@ public class SelfInsertionTest extends ChangeGeneratorTest {
|
||||||
IASTForStatement forStatement = (IASTForStatement) statement;
|
IASTForStatement forStatement = (IASTForStatement) statement;
|
||||||
IASTCompoundStatement compoundStatement = (IASTCompoundStatement) forStatement.getBody();
|
IASTCompoundStatement compoundStatement = (IASTCompoundStatement) forStatement.getBody();
|
||||||
|
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.APPEND_CHILD, compoundStatement, forStatement, null);
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.APPEND_CHILD,
|
||||||
|
compoundStatement, forStatement, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,14 +24,14 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKin
|
||||||
|
|
||||||
public class CtorChainInitializerTest extends ChangeGeneratorTest {
|
public class CtorChainInitializerTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
public CtorChainInitializerTest(){
|
public CtorChainInitializerTest() {
|
||||||
super("Remove Ctor Initializer"); //$NON-NLS-1$
|
super("Remove Ctor Initializer"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "TestClass::TestClass(int a):alpha(a){\n}\n\n"; //$NON-NLS-1$
|
source = "TestClass::TestClass(int a):alpha(a) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "TestClass::TestClass(int a){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "TestClass::TestClass(int a) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,7 @@ public class CtorChainInitializerTest extends ChangeGeneratorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarators = true;
|
shouldVisitDeclarators = true;
|
||||||
|
@ -50,10 +49,11 @@ public class CtorChainInitializerTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
ICPPASTConstructorChainInitializer[] ctorInitializers = functionDeclarator.getConstructorChain();
|
ICPPASTConstructorChainInitializer[] ctorInitializers = functionDeclarator.getConstructorChain();
|
||||||
for(ICPPASTConstructorChainInitializer curInitializer : ctorInitializers){
|
for (ICPPASTConstructorChainInitializer curInitializer : ctorInitializers){
|
||||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, curInitializer, null, null);
|
ASTModification modification = new ASTModification(ModificationKind.REPLACE,
|
||||||
|
curInitializer, null, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ public class ExceptionTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int parameter) throw (int){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int parameter) throw (int) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int parameter) throw (){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int parameter) throw () {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,7 @@ public class ExceptionTest extends ChangeGeneratorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarators = true;
|
shouldVisitDeclarators = true;
|
||||||
|
@ -50,10 +49,11 @@ public class ExceptionTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTTypeId[] exceptions = functionDeclarator.getExceptionSpecification();
|
IASTTypeId[] exceptions = functionDeclarator.getExceptionSpecification();
|
||||||
for(IASTTypeId curException : exceptions){
|
for (IASTTypeId curException : exceptions) {
|
||||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, curException, null, null);
|
ASTModification modification = new ASTModification(ModificationKind.REPLACE,
|
||||||
|
curException, null, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,20 +20,16 @@ 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.ASTModification;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class ExpressionTest extends ChangeGeneratorTest {
|
public class ExpressionTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
public ExpressionTest(){
|
public ExpressionTest() {
|
||||||
super("Remove Expression"); //$NON-NLS-1$
|
super("Remove Expression"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void main(){int s = 0, c = 0, h = 0;\ns = 3, c = 4, h = 5;}"; //$NON-NLS-1$
|
source = "void main() {\n\tint s = 0, c = 0, h = 0;\n\ts = 3, c = 4, h = 5;\n}"; //$NON-NLS-1$
|
||||||
expectedSource = "void main(){int s = 0, c = 0, h = 0;\ns = 3, h = 5;}"; //$NON-NLS-1$
|
expectedSource = "void main() {\n\tint s = 0, c = 0, h = 0;\n\ts = 3, h = 5;\n}"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +38,7 @@ public class ExpressionTest extends ChangeGeneratorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitExpressions = true;
|
shouldVisitExpressions = true;
|
||||||
|
@ -54,13 +49,12 @@ public class ExpressionTest extends ChangeGeneratorTest {
|
||||||
if (expression instanceof IASTExpressionList) {
|
if (expression instanceof IASTExpressionList) {
|
||||||
IASTExpressionList expressionList = (IASTExpressionList) expression;
|
IASTExpressionList expressionList = (IASTExpressionList) expression;
|
||||||
IASTExpression[] expressions = expressionList.getExpressions();
|
IASTExpression[] expressions = expressionList.getExpressions();
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE, expressions[1], null, null);
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE,
|
||||||
|
expressions[1], null, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,31 +22,25 @@ 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.ASTModificationStore;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class FirstParameterTest extends ChangeGeneratorTest {
|
public class FirstParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
public FirstParameterTest(){
|
public FirstParameterTest() {
|
||||||
super("Remove First Parameter Node"); //$NON-NLS-1$
|
super("Remove First Parameter Node"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int a, int b, int c){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int a, int b, int c) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int b, int c){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int b, int c) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return new FirstParameterTest();
|
return new FirstParameterTest();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarators = true;
|
shouldVisitDeclarators = true;
|
||||||
|
@ -55,11 +49,12 @@ public class FirstParameterTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
||||||
for(IASTParameterDeclaration curParam : parameters){
|
for (IASTParameterDeclaration curParam : parameters){
|
||||||
if(String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("a")){ //$NON-NLS-1$
|
if (String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("a")) { //$NON-NLS-1$
|
||||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, curParam, null, null);
|
ASTModification modification = new ASTModification(ModificationKind.REPLACE,
|
||||||
|
curParam, null, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +64,4 @@ public class FirstParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,18 +22,16 @@ 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.ASTModificationStore;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class LastParameterTest extends ChangeGeneratorTest {
|
public class LastParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
public LastParameterTest(){
|
public LastParameterTest() {
|
||||||
super("Remove Last Parameter Node"); //$NON-NLS-1$
|
super("Remove Last Parameter Node"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int a, int b, int c){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int a, int b, int c) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int a, int b){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int a, int b) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +40,7 @@ public class LastParameterTest extends ChangeGeneratorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarators = true;
|
shouldVisitDeclarators = true;
|
||||||
|
@ -52,17 +49,17 @@ public class LastParameterTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
||||||
for(IASTParameterDeclaration curParam : parameters){
|
for (IASTParameterDeclaration curParam : parameters){
|
||||||
if(String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("c")){ //$NON-NLS-1$
|
if (String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("c")) { //$NON-NLS-1$
|
||||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, curParam, null, null);
|
ASTModification modification = new ASTModification(ModificationKind.REPLACE,
|
||||||
|
curParam, null, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,10 +22,6 @@ 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.ASTModificationStore;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class MiddleParameterTest extends ChangeGeneratorTest {
|
public class MiddleParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
public MiddleParameterTest(){
|
public MiddleParameterTest(){
|
||||||
|
@ -34,8 +30,8 @@ public class MiddleParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int a, int b, int c){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int a, int b, int c) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int a, int c){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int a, int c) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +40,8 @@ public class MiddleParameterTest extends ChangeGeneratorTest {
|
||||||
return new MiddleParameterTest();
|
return new MiddleParameterTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarators = true;
|
shouldVisitDeclarators = true;
|
||||||
|
@ -56,11 +50,12 @@ public class MiddleParameterTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
||||||
for(IASTParameterDeclaration curParam : parameters){
|
for (IASTParameterDeclaration curParam : parameters){
|
||||||
if(String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("b")){ //$NON-NLS-1$
|
if (String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("b")) { //$NON-NLS-1$
|
||||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, curParam, null, null);
|
ASTModification modification = new ASTModification(ModificationKind.REPLACE,
|
||||||
|
curParam, null, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,25 +25,23 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKin
|
||||||
|
|
||||||
public class PointerInParameterTest extends ChangeGeneratorTest {
|
public class PointerInParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
public PointerInParameterTest(){
|
public PointerInParameterTest() {
|
||||||
super("Remove Pointer in Parameter"); //$NON-NLS-1$
|
super("Remove Pointer in Parameter"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int *parameter){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int *parameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int parameter){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int parameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return new PointerInParameterTest();
|
return new PointerInParameterTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarators = true;
|
shouldVisitDeclarators = true;
|
||||||
|
@ -52,18 +50,18 @@ public class PointerInParameterTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
||||||
for(IASTParameterDeclaration curParam : parameters){
|
for (IASTParameterDeclaration curParam : parameters){
|
||||||
if(String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("parameter")){ //$NON-NLS-1$
|
if (String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("parameter")){ //$NON-NLS-1$
|
||||||
IASTPointerOperator pointer = curParam.getDeclarator().getPointerOperators()[0];
|
IASTPointerOperator pointer = curParam.getDeclarator().getPointerOperators()[0];
|
||||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, pointer, null, null);
|
ASTModification modification = new ASTModification(ModificationKind.REPLACE,
|
||||||
|
pointer, null, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,11 @@ import junit.framework.TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Thomas Corbat
|
* @author Thomas Corbat
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RemoveTestSuite{
|
public class RemoveTestSuite {
|
||||||
|
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
TestSuite suite = new TestSuite("Changegenerator Remove Tests");
|
TestSuite suite = new TestSuite("ChangeGenerator Remove Tests");
|
||||||
|
|
||||||
suite.addTest(DeclarationTest.suite());
|
suite.addTest(DeclarationTest.suite());
|
||||||
suite.addTest(FirstParameterTest.suite());
|
suite.addTest(FirstParameterTest.suite());
|
||||||
suite.addTest(MiddleParameterTest.suite());
|
suite.addTest(MiddleParameterTest.suite());
|
||||||
|
@ -36,7 +34,6 @@ public class RemoveTestSuite{
|
||||||
suite.addTest(ArraySizeExpressionTest.suite());
|
suite.addTest(ArraySizeExpressionTest.suite());
|
||||||
suite.addTest(NewInitializerExpressionTest.suite());
|
suite.addTest(NewInitializerExpressionTest.suite());
|
||||||
suite.addTest(StatementTest.suite());
|
suite.addTest(StatementTest.suite());
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,25 +24,23 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKin
|
||||||
|
|
||||||
public class SingleParameterTest extends ChangeGeneratorTest {
|
public class SingleParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
public SingleParameterTest(){
|
public SingleParameterTest() {
|
||||||
super("Remove The Only Parameter Node"); //$NON-NLS-1$
|
super("Remove The Only Parameter Node"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int parameter){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int parameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo() {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return new SingleParameterTest();
|
return new SingleParameterTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarators = true;
|
shouldVisitDeclarators = true;
|
||||||
|
@ -51,11 +49,12 @@ public class SingleParameterTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
||||||
for(IASTParameterDeclaration curParam : parameters){
|
for (IASTParameterDeclaration curParam : parameters){
|
||||||
if(String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("parameter")){ //$NON-NLS-1$
|
if (String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("parameter")){ //$NON-NLS-1$
|
||||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, curParam, null, null);
|
ASTModification modification = new ASTModification(ModificationKind.REPLACE,
|
||||||
|
curParam, null, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,15 +29,14 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKin
|
||||||
|
|
||||||
public class ExceptionTest extends ChangeGeneratorTest {
|
public class ExceptionTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
|
|
||||||
public ExceptionTest(){
|
public ExceptionTest(){
|
||||||
super("Remove Exception Declaration"); //$NON-NLS-1$
|
super("Remove Exception Declaration"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int parameter) throw (float){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int parameter) throw (float) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int parameter) throw (int){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int parameter) throw (int) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +45,7 @@ public class ExceptionTest extends ChangeGeneratorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarators = true;
|
shouldVisitDeclarators = true;
|
||||||
|
@ -56,7 +54,7 @@ public class ExceptionTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTTypeId existingException = functionDeclarator.getExceptionSpecification()[0];
|
IASTTypeId existingException = functionDeclarator.getExceptionSpecification()[0];
|
||||||
|
|
||||||
IASTTypeId exception = new CPPASTTypeId();
|
IASTTypeId exception = new CPPASTTypeId();
|
||||||
|
@ -66,13 +64,12 @@ public class ExceptionTest extends ChangeGeneratorTest {
|
||||||
exDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
exDeclSpec.setType(IASTSimpleDeclSpecifier.t_int);
|
||||||
exception.setDeclSpecifier(exDeclSpec);
|
exception.setDeclSpecifier(exDeclSpec);
|
||||||
exception.setAbstractDeclarator(exceptionDeclarator);
|
exception.setAbstractDeclarator(exceptionDeclarator);
|
||||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, existingException, exception, null);
|
ASTModification modification = new ASTModification(ModificationKind.REPLACE,
|
||||||
|
existingException, exception, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,20 +25,16 @@ 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.ASTModification;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class ExpressionTest extends ChangeGeneratorTest {
|
public class ExpressionTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
public ExpressionTest(){
|
public ExpressionTest() {
|
||||||
super("Replace Expression"); //$NON-NLS-1$
|
super("Replace Expression"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void main(){int s = 0, c = 0, h = 0;\ns = 3, c = 4, h = 5;}"; //$NON-NLS-1$
|
source = "void main() {\n\tint s = 0, c = 0, h = 0;\n\ts = 3, c = 4, h = 5;\n}"; //$NON-NLS-1$
|
||||||
expectedSource = "void main(){int s = 0, c = 0, h = 0;\ns = 3, c = 9, h = 5;}"; //$NON-NLS-1$
|
expectedSource = "void main() {\n\tint s = 0, c = 0, h = 0;\n\ts = 3, c = 9, h = 5;\n}"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,10 +42,8 @@ public class ExpressionTest extends ChangeGeneratorTest {
|
||||||
return new ExpressionTest();
|
return new ExpressionTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitExpressions = true;
|
shouldVisitExpressions = true;
|
||||||
|
@ -60,8 +54,11 @@ public class ExpressionTest extends ChangeGeneratorTest {
|
||||||
if (expression instanceof IASTExpressionList) {
|
if (expression instanceof IASTExpressionList) {
|
||||||
IASTExpressionList expressionList = (IASTExpressionList) expression;
|
IASTExpressionList expressionList = (IASTExpressionList) expression;
|
||||||
IASTExpression[] expressions = expressionList.getExpressions();
|
IASTExpression[] expressions = expressionList.getExpressions();
|
||||||
CPPASTBinaryExpression binEx = new CPPASTBinaryExpression(IASTBinaryExpression.op_assign, new CPPASTIdExpression(new CPPASTName("c".toCharArray())), new CPPASTLiteralExpression(0, "9")); //$NON-NLS-1$ //$NON-NLS-2$
|
CPPASTBinaryExpression binEx = new CPPASTBinaryExpression(IASTBinaryExpression.op_assign,
|
||||||
ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE, expressions[1], binEx, null);
|
new CPPASTIdExpression(new CPPASTName("c".toCharArray())), //$NON-NLS-1$
|
||||||
|
new CPPASTLiteralExpression(0, "9".toCharArray())); //$NON-NLS-1$
|
||||||
|
ASTModification modification = new ASTModification(ASTModification.ModificationKind.REPLACE,
|
||||||
|
expressions[1], binEx, null);
|
||||||
modStore.storeModification(null, modification);
|
modStore.storeModification(null, modification);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
|
|
|
@ -26,14 +26,14 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKin
|
||||||
|
|
||||||
public class PointerInParameterTest extends ChangeGeneratorTest {
|
public class PointerInParameterTest extends ChangeGeneratorTest {
|
||||||
|
|
||||||
public PointerInParameterTest(){
|
public PointerInParameterTest() {
|
||||||
super("Replace Pointer for Parameter"); //$NON-NLS-1$
|
super("Replace Pointer for Parameter"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
source = "void foo(int ¶meter){\n}\n\n"; //$NON-NLS-1$
|
source = "void foo(int ¶meter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
expectedSource = "void foo(int *parameter){\n}\n\n"; //$NON-NLS-1$
|
expectedSource = "void foo(int *parameter) {\n}\n\n"; //$NON-NLS-1$
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,7 @@ public class PointerInParameterTest extends ChangeGeneratorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ASTVisitor createModificator(
|
protected ASTVisitor createModificator(final ASTModificationStore modStore) {
|
||||||
final ASTModificationStore modStore) {
|
|
||||||
return new ASTVisitor() {
|
return new ASTVisitor() {
|
||||||
{
|
{
|
||||||
shouldVisitDeclarators = true;
|
shouldVisitDeclarators = true;
|
||||||
|
@ -52,10 +51,10 @@ public class PointerInParameterTest extends ChangeGeneratorTest {
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclarator declarator) {
|
public int visit(IASTDeclarator declarator) {
|
||||||
if (declarator instanceof CPPASTFunctionDeclarator) {
|
if (declarator instanceof CPPASTFunctionDeclarator) {
|
||||||
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator)declarator;
|
CPPASTFunctionDeclarator functionDeclarator = (CPPASTFunctionDeclarator) declarator;
|
||||||
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
IASTParameterDeclaration[] parameters = functionDeclarator.getParameters();
|
||||||
for(IASTParameterDeclaration curParam : parameters){
|
for (IASTParameterDeclaration curParam : parameters){
|
||||||
if(String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("parameter")){ //$NON-NLS-1$
|
if (String.valueOf(curParam.getDeclarator().getName().toCharArray()).equals("parameter")) { //$NON-NLS-1$
|
||||||
IASTPointerOperator pointer = curParam.getDeclarator().getPointerOperators()[0];
|
IASTPointerOperator pointer = curParam.getDeclarator().getPointerOperators()[0];
|
||||||
CPPASTPointer newPointer = new CPPASTPointer();
|
CPPASTPointer newPointer = new CPPASTPointer();
|
||||||
ASTModification modification = new ASTModification(ModificationKind.REPLACE, pointer, newPointer, null);
|
ASTModification modification = new ASTModification(ModificationKind.REPLACE, pointer, newPointer, null);
|
||||||
|
|
|
@ -16,12 +16,11 @@ import junit.framework.TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Thomas Corbat
|
* @author Thomas Corbat
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ReplaceTestSuite{
|
public class ReplaceTestSuite {
|
||||||
|
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
TestSuite suite = new TestSuite("ChangegeneratorReplaceTests");
|
TestSuite suite = new TestSuite("ChangeGeneratorReplaceTests");
|
||||||
|
|
||||||
suite.addTest(NameTest.suite());
|
suite.addTest(NameTest.suite());
|
||||||
suite.addTest(MoveTest.suite());
|
suite.addTest(MoveTest.suite());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -11,9 +11,9 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.rewrite.comenthandler;
|
package org.eclipse.cdt.core.parser.tests.rewrite.comenthandler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -74,7 +74,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* @author Guido Zgraggen IFS, Lukas Felber IFS
|
* @author Guido Zgraggen IFS, Lukas Felber IFS
|
||||||
*/
|
*/
|
||||||
public class CommentHandlingTest extends RewriteBaseTest {
|
public class CommentHandlingTest extends RewriteBaseTest {
|
||||||
|
|
||||||
private static final String ANY_CHAR_REGEXP = "(.*)"; //$NON-NLS-1$
|
private static final String ANY_CHAR_REGEXP = "(.*)"; //$NON-NLS-1$
|
||||||
private static final String SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
|
private static final String SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ public class CommentHandlingTest extends RewriteBaseTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void runTest() throws Throwable {
|
protected void runTest() throws Throwable {
|
||||||
if (fileMap.size() == 0) {
|
if (fileMap.isEmpty()) {
|
||||||
fail("No file for testing"); //$NON-NLS-1$
|
fail("No file for testing"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,12 +139,12 @@ public class CommentHandlingTest extends RewriteBaseTest {
|
||||||
return actualResultBuilder;
|
return actualResultBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCommentMapResult(HashMap<IASTNode, ArrayList<IASTComment>> map) {
|
private String getCommentMapResult(Map<IASTNode, List<IASTComment>> map) {
|
||||||
TreeSet<IASTNode> keyTree = new TreeSet<IASTNode>(new NodeOffsetComparator());
|
TreeSet<IASTNode> keyTree = new TreeSet<IASTNode>(new NodeOffsetComparator());
|
||||||
keyTree.addAll(map.keySet());
|
keyTree.addAll(map.keySet());
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
for (IASTNode actNode : keyTree) {
|
for (IASTNode actNode : keyTree) {
|
||||||
ArrayList<IASTComment> comments = map.get(actNode);
|
List<IASTComment> comments = map.get(actNode);
|
||||||
output.append(getSignature(actNode) + " = "); //$NON-NLS-1$
|
output.append(getSignature(actNode) + " = "); //$NON-NLS-1$
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (IASTComment actComment : comments) {
|
for (IASTComment actComment : comments) {
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCProjectNature;
|
import org.eclipse.cdt.core.CCProjectNature;
|
||||||
|
@ -1425,7 +1424,7 @@ public class CoreModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* forces the cached data of the specified projects to be re-calculated.
|
* Forces the cached data of the specified projects to be re-calculated.
|
||||||
* if the <code>projects</code> argument is <code>null</code> al projects
|
* if the <code>projects</code> argument is <code>null</code> al projects
|
||||||
* within the workspace are updated
|
* within the workspace are updated
|
||||||
*
|
*
|
||||||
|
@ -1438,14 +1437,14 @@ public class CoreModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven
|
* Answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven
|
||||||
*/
|
*/
|
||||||
public boolean isNewStyleProject(IProject project){
|
public boolean isNewStyleProject(IProject project){
|
||||||
return descriptionManager.isNewStyleProject(project);
|
return descriptionManager.isNewStyleProject(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven
|
* Answers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven
|
||||||
*/
|
*/
|
||||||
public boolean isNewStyleProject(ICProjectDescription des){
|
public boolean isNewStyleProject(ICProjectDescription des){
|
||||||
return descriptionManager.isNewStyleProject(des);
|
return descriptionManager.isNewStyleProject(des);
|
||||||
|
|
|
@ -44,10 +44,12 @@ public interface IASTExpressionList extends IASTExpression {
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IASTExpressionList copy();
|
public IASTExpressionList copy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IASTExpressionList copy(CopyStyle style);
|
public IASTExpressionList copy(CopyStyle style);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public interface IASTParameterDeclaration extends IASTNode {
|
||||||
/**
|
/**
|
||||||
* Constant/sentinel.
|
* Constant/sentinel.
|
||||||
*/
|
*/
|
||||||
public static final IASTParameterDeclaration[] EMPTY_PARAMETERDECLARATION_ARRAY = new IASTParameterDeclaration[0];
|
public static final IASTParameterDeclaration[] EMPTY_PARAMETERDECLARATION_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>DECL_SPECIFIER</code> represents the relationship between an
|
* <code>DECL_SPECIFIER</code> represents the relationship between an
|
||||||
|
@ -71,10 +71,12 @@ public interface IASTParameterDeclaration extends IASTNode {
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IASTParameterDeclaration copy();
|
public IASTParameterDeclaration copy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IASTParameterDeclaration copy(CopyStyle style);
|
public IASTParameterDeclaration copy(CopyStyle style);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IASTStandardFunctionDeclarator extends IASTFunctionDeclarator {
|
public interface IASTStandardFunctionDeclarator extends IASTFunctionDeclarator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>FUNCTION_PARAMETER</code> represents the relationship between an
|
* <code>FUNCTION_PARAMETER</code> represents the relationship between an
|
||||||
* <code>IASTStandardFunctionDeclarator</code> and it's nested
|
* <code>IASTStandardFunctionDeclarator</code> and it's nested
|
||||||
|
@ -67,10 +66,12 @@ public interface IASTStandardFunctionDeclarator extends IASTFunctionDeclarator {
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IASTStandardFunctionDeclarator copy();
|
public IASTStandardFunctionDeclarator copy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IASTStandardFunctionDeclarator copy(CopyStyle style);
|
public IASTStandardFunctionDeclarator copy(CopyStyle style);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPASTCatchHandler extends IASTStatement {
|
public interface ICPPASTCatchHandler extends IASTStatement {
|
||||||
|
public static final ICPPASTCatchHandler[] EMPTY_CATCHHANDLER_ARRAY = {};
|
||||||
public static final ICPPASTCatchHandler[] EMPTY_CATCHHANDLER_ARRAY = new ICPPASTCatchHandler[0];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>DECLARATION</code> represents the nested declaration within the catch handler.
|
* <code>DECLARATION</code> represents the nested declaration within the catch handler.
|
||||||
|
@ -78,10 +77,12 @@ public interface ICPPASTCatchHandler extends IASTStatement {
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ICPPASTCatchHandler copy();
|
public ICPPASTCatchHandler copy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ICPPASTCatchHandler copy(CopyStyle style);
|
public ICPPASTCatchHandler copy(CopyStyle style);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarator, ICPPASTDeclarator {
|
public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarator, ICPPASTDeclarator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used as return value for {@link #getExceptionSpecification()}.
|
* Used as return value for {@link #getExceptionSpecification()}.
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
|
@ -80,6 +79,7 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
|
||||||
/**
|
/**
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ICPPASTParameterDeclaration[] getParameters();
|
public ICPPASTParameterDeclaration[] getParameters();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,6 +117,7 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
|
||||||
* Get function scope this node represents. Returns <code>null</code>, if this declarator does not
|
* Get function scope this node represents. Returns <code>null</code>, if this declarator does not
|
||||||
* declare a function-prototype or function-definition.
|
* declare a function-prototype or function-definition.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ICPPFunctionScope getFunctionScope();
|
public ICPPFunctionScope getFunctionScope();
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,10 +137,12 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ICPPASTFunctionDeclarator copy();
|
public ICPPASTFunctionDeclarator copy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ICPPASTFunctionDeclarator copy(CopyStyle style);
|
public ICPPASTFunctionDeclarator copy(CopyStyle style);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,11 +42,13 @@ public interface ICPPASTFunctionDefinition extends IASTFunctionDefinition {
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ICPPASTFunctionDefinition copy();
|
public ICPPASTFunctionDefinition copy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ICPPASTFunctionDefinition copy(CopyStyle style);
|
public ICPPASTFunctionDefinition copy(CopyStyle style);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPASTFunctionWithTryBlock extends ICPPASTFunctionDefinition {
|
public interface ICPPASTFunctionWithTryBlock extends ICPPASTFunctionDefinition {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A <code>CATCH_HANDLER</code> is the role of an ICPPASTCatchHandler in
|
* A <code>CATCH_HANDLER</code> is the role of an ICPPASTCatchHandler in
|
||||||
* this interface.
|
* this interface.
|
||||||
|
@ -44,6 +43,6 @@ public interface ICPPASTFunctionWithTryBlock extends ICPPASTFunctionDefinition {
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ICPPASTFunctionWithTryBlock copy();
|
public ICPPASTFunctionWithTryBlock copy();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwner, IASTDeclarationListOwner {
|
public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwner, IASTDeclarationListOwner {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>OWNED_DECLARATION</code> is the role served by all the nested
|
* <code>OWNED_DECLARATION</code> is the role served by all the nested
|
||||||
* declarations.
|
* declarations.
|
||||||
|
@ -68,22 +67,22 @@ public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwn
|
||||||
public boolean isInline();
|
public boolean isInline();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A translation unit contains an ordered sequence of declarations.
|
* A namespace contains an ordered sequence of declarations.
|
||||||
*
|
*
|
||||||
* @return <code>IASTDeclaration []</code>
|
* @return an array of declarations contained in the namespace
|
||||||
*/
|
*/
|
||||||
public IASTDeclaration[] getDeclarations();
|
public IASTDeclaration[] getDeclarations();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a declaration to the namespace.
|
* Adds a declaration to the namespace.
|
||||||
*
|
*
|
||||||
* @param declaration
|
* @param declaration <code>IASTDeclaration</code>
|
||||||
* <code>IASTDeclaration</code>
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void addDeclaration(IASTDeclaration declaration);
|
public void addDeclaration(IASTDeclaration declaration);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the scope object represented by this construct.
|
* Returns the scope object represented by this construct.
|
||||||
*
|
*
|
||||||
* @return <code>IScope</code>
|
* @return <code>IScope</code>
|
||||||
*/
|
*/
|
||||||
|
@ -92,10 +91,12 @@ public interface ICPPASTNamespaceDefinition extends IASTDeclaration, IASTNameOwn
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ICPPASTNamespaceDefinition copy();
|
public ICPPASTNamespaceDefinition copy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ICPPASTNamespaceDefinition copy(CopyStyle style);
|
public ICPPASTNamespaceDefinition copy(CopyStyle style);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,32 +17,31 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ASTCopyLocation implements IASTCopyLocation {
|
public class ASTCopyLocation implements IASTCopyLocation {
|
||||||
|
|
||||||
private IASTNode originalNode;
|
private IASTNode originalNode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ASTCopyLocation(IASTNode originalNode) {
|
public ASTCopyLocation(IASTNode originalNode) {
|
||||||
this.originalNode = originalNode;
|
this.originalNode = originalNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNodeOffset() {
|
public int getNodeOffset() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getNodeLength() {
|
public int getNodeLength() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTFileLocation asFileLocation() {
|
public IASTFileLocation asFileLocation() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode getOriginalNode() {
|
public IASTNode getOriginalNode() {
|
||||||
return originalNode;
|
return originalNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setName(IASTName name) {
|
public void setName(IASTName name) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -49,10 +50,12 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTName getName() {
|
public IASTName getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setValue(IASTExpression expression) {
|
public void setValue(IASTExpression expression) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.value = expression;
|
this.value = expression;
|
||||||
|
@ -62,6 +65,7 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTExpression getValue() {
|
public IASTExpression getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -87,6 +91,7 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getRoleForName(IASTName n) {
|
public int getRoleForName(IASTName n) {
|
||||||
if (n == name)
|
if (n == name)
|
||||||
return r_definition;
|
return r_definition;
|
||||||
|
@ -94,6 +99,7 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
|
||||||
return r_reference;
|
return r_reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if (child == value) {
|
if (child == value) {
|
||||||
other.setPropertyInParent(child.getPropertyInParent());
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
|
|
|
@ -32,10 +32,12 @@ public abstract class ASTEqualsInitializer extends ASTNode implements IASTEquals
|
||||||
setInitializerClause(arg);
|
setInitializerClause(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTInitializerClause getInitializerClause() {
|
public IASTInitializerClause getInitializerClause() {
|
||||||
return fArgument;
|
return fArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setInitializerClause(IASTInitializerClause clause) {
|
public void setInitializerClause(IASTInitializerClause clause) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
fArgument = clause;
|
fArgument = clause;
|
||||||
|
@ -64,6 +66,7 @@ public abstract class ASTEqualsInitializer extends ASTNode implements IASTEquals
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if (child == fArgument) {
|
if (child == fArgument) {
|
||||||
other.setPropertyInParent(child.getPropertyInParent());
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
|
|
|
@ -42,23 +42,29 @@ public abstract class ASTNode implements IASTNode {
|
||||||
|
|
||||||
private int length;
|
private int length;
|
||||||
private int offset;
|
private int offset;
|
||||||
|
private IASTNodeLocation[] locations;
|
||||||
|
private IASTFileLocation fileLocation;
|
||||||
|
|
||||||
private boolean frozen = false;
|
private boolean frozen = false;
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode getParent() {
|
public IASTNode getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode[] getChildren() {
|
public IASTNode[] getChildren() {
|
||||||
ChildCollector collector= new ChildCollector(this);
|
ChildCollector collector= new ChildCollector(this);
|
||||||
return collector.getChildren();
|
return collector.getChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isFrozen() {
|
public boolean isFrozen() {
|
||||||
return frozen;
|
return frozen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
@ -78,15 +84,18 @@ public abstract class ASTNode implements IASTNode {
|
||||||
throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$
|
throw new IllegalStateException("attempt to modify frozen AST node"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setParent(IASTNode node) {
|
public void setParent(IASTNode node) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.parent = node;
|
this.parent = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ASTNodeProperty getPropertyInParent() {
|
public ASTNodeProperty getPropertyInParent() {
|
||||||
return property;
|
return property;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setPropertyInParent(ASTNodeProperty property) {
|
public void setPropertyInParent(ASTNodeProperty property) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.property = property;
|
this.property = property;
|
||||||
|
@ -120,9 +129,7 @@ public abstract class ASTNode implements IASTNode {
|
||||||
setOffsetAndLength(node.getOffset(), node.getLength());
|
setOffsetAndLength(node.getOffset(), node.getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTNodeLocation[] locations = null;
|
@Override
|
||||||
private IASTFileLocation fileLocation = null;
|
|
||||||
|
|
||||||
public IASTNodeLocation[] getNodeLocations() {
|
public IASTNodeLocation[] getNodeLocations() {
|
||||||
if (locations != null)
|
if (locations != null)
|
||||||
return locations;
|
return locations;
|
||||||
|
@ -163,10 +170,12 @@ public abstract class ASTNode implements IASTNode {
|
||||||
return CharArrayUtils.EMPTY;
|
return CharArrayUtils.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getRawSignature() {
|
public String getRawSignature() {
|
||||||
return new String(getRawSignatureChars());
|
return new String(getRawSignatureChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getContainingFilename() {
|
public String getContainingFilename() {
|
||||||
if (offset <= 0 && (length == 0 || offset < 0)) {
|
if (offset <= 0 && (length == 0 || offset < 0)) {
|
||||||
final IASTNode parent = getParent();
|
final IASTNode parent = getParent();
|
||||||
|
@ -181,6 +190,7 @@ public abstract class ASTNode implements IASTNode {
|
||||||
return getTranslationUnit().getContainingFilename(offset);
|
return getTranslationUnit().getContainingFilename(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTFileLocation getFileLocation() {
|
public IASTFileLocation getFileLocation() {
|
||||||
if (fileLocation != null)
|
if (fileLocation != null)
|
||||||
return fileLocation;
|
return fileLocation;
|
||||||
|
@ -201,6 +211,7 @@ public abstract class ASTNode implements IASTNode {
|
||||||
return fileLocation;
|
return fileLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPartOfTranslationUnitFile() {
|
public boolean isPartOfTranslationUnitFile() {
|
||||||
IASTTranslationUnit ast = getTranslationUnit();
|
IASTTranslationUnit ast = getTranslationUnit();
|
||||||
if (ast != null) {
|
if (ast != null) {
|
||||||
|
@ -223,14 +234,17 @@ public abstract class ASTNode implements IASTNode {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTTranslationUnit getTranslationUnit() {
|
public IASTTranslationUnit getTranslationUnit() {
|
||||||
return parent != null ? parent.getTranslationUnit() : null;
|
return parent != null ? parent.getTranslationUnit() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean accept(ASTVisitor visitor) {
|
public boolean accept(ASTVisitor visitor) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean contains(IASTNode node) {
|
public boolean contains(IASTNode node) {
|
||||||
if (node instanceof ASTNode) {
|
if (node instanceof ASTNode) {
|
||||||
ASTNode astNode= (ASTNode) node;
|
ASTNode astNode= (ASTNode) node;
|
||||||
|
@ -240,15 +254,18 @@ public abstract class ASTNode implements IASTNode {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IToken getSyntax() throws ExpansionOverlapsBoundaryException {
|
public IToken getSyntax() throws ExpansionOverlapsBoundaryException {
|
||||||
return getSyntax(offset, offset+length, 0);
|
return getSyntax(offset, offset+length, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IToken getLeadingSyntax() throws ExpansionOverlapsBoundaryException {
|
public IToken getLeadingSyntax() throws ExpansionOverlapsBoundaryException {
|
||||||
int left= getBoundary(-1);
|
int left= getBoundary(-1);
|
||||||
return getSyntax(left, offset, -1);
|
return getSyntax(left, offset, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IToken getTrailingSyntax() throws ExpansionOverlapsBoundaryException {
|
public IToken getTrailingSyntax() throws ExpansionOverlapsBoundaryException {
|
||||||
int right= getBoundary(1);
|
int right= getBoundary(1);
|
||||||
return getSyntax(offset+length, right, 1);
|
return getSyntax(offset+length, right, 1);
|
||||||
|
@ -346,5 +363,4 @@ public abstract class ASTNode implements IASTNode {
|
||||||
protected void setCopyLocation(IASTNode originalNode) {
|
protected void setCopyLocation(IASTNode originalNode) {
|
||||||
locations = new IASTNodeLocation[] {new ASTCopyLocation(originalNode)};
|
locations = new IASTNodeLocation[] {new ASTCopyLocation(originalNode)};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public class ASTNodeSelector implements IASTNodeSelector {
|
public class ASTNodeSelector implements IASTNodeSelector {
|
||||||
|
|
||||||
private ASTTranslationUnit fTu;
|
private ASTTranslationUnit fTu;
|
||||||
private ILocationResolver fLocationResolver;
|
private ILocationResolver fLocationResolver;
|
||||||
private String fFilePath;
|
private String fFilePath;
|
||||||
|
@ -74,7 +73,7 @@ public class ASTNodeSelector implements IASTNodeSelector {
|
||||||
sequenceLength= 0;
|
sequenceLength= 0;
|
||||||
if (offsetInFile > 0) {
|
if (offsetInFile > 0) {
|
||||||
altSequenceNumber= fLocationResolver.getSequenceNumberForFileOffset(fFilePath, offsetInFile-1);
|
altSequenceNumber= fLocationResolver.getSequenceNumberForFileOffset(fFilePath, offsetInFile-1);
|
||||||
if (altSequenceNumber+1 == sequenceNumber) {
|
if (altSequenceNumber + 1 == sequenceNumber) {
|
||||||
altSequenceNumber= -1;
|
altSequenceNumber= -1;
|
||||||
} else {
|
} else {
|
||||||
// we are on a context boundary and we need to check the variant to the left and
|
// we are on a context boundary and we need to check the variant to the left and
|
||||||
|
@ -118,55 +117,67 @@ public class ASTNodeSelector implements IASTNodeSelector {
|
||||||
return nodeSpec.getBestNode();
|
return nodeSpec.getBestNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode findFirstContainedNode(int offset, int length) {
|
public IASTNode findFirstContainedNode(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.FIRST_CONTAINED, IASTNode.class);
|
return findNode(offset, length, Relation.FIRST_CONTAINED, IASTNode.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode findNode(int offset, int length) {
|
public IASTNode findNode(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.EXACT_MATCH, IASTNode.class);
|
return findNode(offset, length, Relation.EXACT_MATCH, IASTNode.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode findEnclosingNode(int offset, int length) {
|
public IASTNode findEnclosingNode(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.ENCLOSING, IASTNode.class);
|
return findNode(offset, length, Relation.ENCLOSING, IASTNode.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode findStrictlyEnclosingNode(int offset, int length) {
|
public IASTNode findStrictlyEnclosingNode(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.STRICTLY_ENCLOSING, IASTNode.class);
|
return findNode(offset, length, Relation.STRICTLY_ENCLOSING, IASTNode.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode findFirstContainedNodeInExpansion(int offset, int length) {
|
public IASTNode findFirstContainedNodeInExpansion(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.FIRST_CONTAINED, IASTNode.class, true);
|
return findNode(offset, length, Relation.FIRST_CONTAINED, IASTNode.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode findNodeInExpansion(int offset, int length) {
|
public IASTNode findNodeInExpansion(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.EXACT_MATCH, IASTNode.class, true);
|
return findNode(offset, length, Relation.EXACT_MATCH, IASTNode.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode findEnclosingNodeInExpansion(int offset, int length) {
|
public IASTNode findEnclosingNodeInExpansion(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.ENCLOSING, IASTNode.class, true);
|
return findNode(offset, length, Relation.ENCLOSING, IASTNode.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTName findFirstContainedName(int offset, int length) {
|
public IASTName findFirstContainedName(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.FIRST_CONTAINED, IASTName.class);
|
return findNode(offset, length, Relation.FIRST_CONTAINED, IASTName.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTName findName(int offset, int length) {
|
public IASTName findName(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.EXACT_MATCH, IASTName.class);
|
return findNode(offset, length, Relation.EXACT_MATCH, IASTName.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTName findEnclosingName(int offset, int length) {
|
public IASTName findEnclosingName(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.ENCLOSING, IASTName.class);
|
return findNode(offset, length, Relation.ENCLOSING, IASTName.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTImplicitName findImplicitName(int offset, int length) {
|
public IASTImplicitName findImplicitName(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.EXACT_MATCH, IASTImplicitName.class);
|
return findNode(offset, length, Relation.EXACT_MATCH, IASTImplicitName.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTImplicitName findEnclosingImplicitName(int offset, int length) {
|
public IASTImplicitName findEnclosingImplicitName(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.ENCLOSING, IASTImplicitName.class);
|
return findNode(offset, length, Relation.ENCLOSING, IASTImplicitName.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTPreprocessorMacroExpansion findEnclosingMacroExpansion(int offset, int length) {
|
public IASTPreprocessorMacroExpansion findEnclosingMacroExpansion(int offset, int length) {
|
||||||
return findNode(offset, length, Relation.ENCLOSING, IASTPreprocessorMacroExpansion.class);
|
return findNode(offset, length, Relation.ENCLOSING, IASTPreprocessorMacroExpansion.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,12 +41,12 @@ public class ASTNodeSpecification<T extends IASTNode> {
|
||||||
fRelation= relation;
|
fRelation= relation;
|
||||||
fClass= clazz;
|
fClass= clazz;
|
||||||
fFileOffset= fileOffset;
|
fFileOffset= fileOffset;
|
||||||
fFileEndOffset= fileOffset+fileLength;
|
fFileEndOffset= fileOffset + fileLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRangeInSequence(int offsetInSeq, int lengthInSeq) {
|
public void setRangeInSequence(int offsetInSeq, int lengthInSeq) {
|
||||||
fSeqNumber= offsetInSeq;
|
fSeqNumber= offsetInSeq;
|
||||||
fSeqEndNumber= offsetInSeq+lengthInSeq;
|
fSeqEndNumber= offsetInSeq + lengthInSeq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRangeInSequence(int offsetInSeq, int lengthInSeq, boolean zeroRangeToLeft) {
|
public void setRangeInSequence(int offsetInSeq, int lengthInSeq, boolean zeroRangeToLeft) {
|
||||||
|
|
|
@ -23,95 +23,10 @@ import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
||||||
|
|
||||||
import com.ibm.icu.text.MessageFormat;
|
import com.ibm.icu.text.MessageFormat;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Models problems, all problems should derive from this class.
|
* Models problems, all problems should derive from this class.
|
||||||
*/
|
*/
|
||||||
public class ASTProblem extends ASTNode implements IASTProblem {
|
public class ASTProblem extends ASTNode implements IASTProblem {
|
||||||
|
|
||||||
private final int id;
|
|
||||||
private final char[] arg;
|
|
||||||
private boolean isError= false;
|
|
||||||
|
|
||||||
public ASTProblem(IASTNode parent, ASTNodeProperty property, int id, char[] arg, boolean isError, int startNumber, int endNumber) {
|
|
||||||
setParent(parent);
|
|
||||||
setPropertyInParent(property);
|
|
||||||
setOffset(startNumber);
|
|
||||||
setLength(endNumber-startNumber);
|
|
||||||
|
|
||||||
this.isError= isError;
|
|
||||||
this.id = id;
|
|
||||||
this.arg = arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ASTProblem(int id, char[] arg, boolean isError) {
|
|
||||||
this.id = id;
|
|
||||||
this.arg = arg;
|
|
||||||
this.isError= isError;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ASTProblem copy() {
|
|
||||||
return copy(CopyStyle.withoutLocations);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ASTProblem copy(CopyStyle style) {
|
|
||||||
ASTProblem problem = new ASTProblem(id, arg == null ? null : arg.clone(), isError);
|
|
||||||
problem.setOffsetAndLength(this);
|
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
problem.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return problem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isError() {
|
|
||||||
return isError;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWarning() {
|
|
||||||
return !isError;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessageWithLocation() {
|
|
||||||
String msg= getMessage();
|
|
||||||
|
|
||||||
char[] file= getOriginatingFileName();
|
|
||||||
int line= getSourceLineNumber();
|
|
||||||
Object[] args = new Object[] { msg, new String(file), new Integer(line) };
|
|
||||||
return ParserMessages.getFormattedString("BaseProblemFactory.problemPattern", args); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getMessage(int id, String arg) {
|
|
||||||
String msg = errorMessages.get(new Integer(id));
|
|
||||||
if (msg == null)
|
|
||||||
msg = ""; //$NON-NLS-1$
|
|
||||||
|
|
||||||
if (arg != null) {
|
|
||||||
return MessageFormat.format(msg, new Object[] {arg});
|
|
||||||
}
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return getMessage(id, arg == null ? null : new String(arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkCategory(int bitmask) {
|
|
||||||
return ((id & bitmask) != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getArguments() {
|
|
||||||
return arg == null ? new String[0] : new String[] {new String(arg)};
|
|
||||||
}
|
|
||||||
|
|
||||||
public char[] getArgument() {
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected static final Map<Integer, String> errorMessages;
|
protected static final Map<Integer, String> errorMessages;
|
||||||
static {
|
static {
|
||||||
errorMessages = new HashMap<Integer, String>();
|
errorMessages = new HashMap<Integer, String>();
|
||||||
|
@ -179,16 +94,104 @@ public class ASTProblem extends ASTNode implements IASTProblem {
|
||||||
ParserMessages.getString("ParserProblemFactory.error.syntax.missingSemicolon")); //$NON-NLS-1$
|
ParserMessages.getString("ParserProblemFactory.error.syntax.missingSemicolon")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
private final int id;
|
||||||
* @see org.eclipse.cdt.core.parser.IProblem#getOriginatingFileName()
|
private final char[] arg;
|
||||||
*/
|
private boolean isError;
|
||||||
|
|
||||||
|
public ASTProblem(IASTNode parent, ASTNodeProperty property, int id, char[] arg, boolean isError,
|
||||||
|
int startNumber, int endNumber) {
|
||||||
|
setParent(parent);
|
||||||
|
setPropertyInParent(property);
|
||||||
|
setOffset(startNumber);
|
||||||
|
setLength(endNumber-startNumber);
|
||||||
|
|
||||||
|
this.isError= isError;
|
||||||
|
this.id = id;
|
||||||
|
this.arg = arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ASTProblem(int id, char[] arg, boolean isError) {
|
||||||
|
this.id = id;
|
||||||
|
this.arg = arg;
|
||||||
|
this.isError= isError;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ASTProblem copy() {
|
||||||
|
return copy(CopyStyle.withoutLocations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ASTProblem copy(CopyStyle style) {
|
||||||
|
ASTProblem problem = new ASTProblem(id, arg == null ? null : arg.clone(), isError);
|
||||||
|
problem.setOffsetAndLength(this);
|
||||||
|
if (style == CopyStyle.withLocations) {
|
||||||
|
problem.setCopyLocation(this);
|
||||||
|
}
|
||||||
|
return problem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getID() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isError() {
|
||||||
|
return isError;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWarning() {
|
||||||
|
return !isError;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessageWithLocation() {
|
||||||
|
String msg= getMessage();
|
||||||
|
|
||||||
|
char[] file= getOriginatingFileName();
|
||||||
|
int line= getSourceLineNumber();
|
||||||
|
Object[] args = new Object[] { msg, new String(file), new Integer(line) };
|
||||||
|
return ParserMessages.getFormattedString("BaseProblemFactory.problemPattern", args); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessage(int id, String arg) {
|
||||||
|
String msg = errorMessages.get(new Integer(id));
|
||||||
|
if (msg == null)
|
||||||
|
msg = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (arg != null) {
|
||||||
|
return MessageFormat.format(msg, new Object[] {arg});
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return getMessage(id, arg == null ? null : new String(arg));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkCategory(int bitmask) {
|
||||||
|
return (id & bitmask) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getArguments() {
|
||||||
|
return arg == null ? new String[0] : new String[] { new String(arg) };
|
||||||
|
}
|
||||||
|
|
||||||
|
public char[] getArgument() {
|
||||||
|
return arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public char[] getOriginatingFileName() {
|
public char[] getOriginatingFileName() {
|
||||||
return getContainingFilename().toCharArray();
|
return getContainingFilename().toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see org.eclipse.cdt.core.parser.IProblem#getSourceEnd()
|
|
||||||
*/
|
|
||||||
public int getSourceEnd() {
|
public int getSourceEnd() {
|
||||||
final IASTFileLocation location= getFileLocation();
|
final IASTFileLocation location= getFileLocation();
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
@ -197,9 +200,7 @@ public class ASTProblem extends ASTNode implements IASTProblem {
|
||||||
return INT_VALUE_NOT_PROVIDED;
|
return INT_VALUE_NOT_PROVIDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see org.eclipse.cdt.core.parser.IProblem#getSourceLineNumber()
|
|
||||||
*/
|
|
||||||
public int getSourceLineNumber() {
|
public int getSourceLineNumber() {
|
||||||
final IASTFileLocation location= getFileLocation();
|
final IASTFileLocation location= getFileLocation();
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
@ -208,9 +209,7 @@ public class ASTProblem extends ASTNode implements IASTProblem {
|
||||||
return INT_VALUE_NOT_PROVIDED;
|
return INT_VALUE_NOT_PROVIDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* @see org.eclipse.cdt.core.parser.IProblem#getSourceStart()
|
|
||||||
*/
|
|
||||||
public int getSourceStart() {
|
public int getSourceStart() {
|
||||||
final IASTFileLocation location= getFileLocation();
|
final IASTFileLocation location= getFileLocation();
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
|
|
@ -41,10 +41,12 @@ public abstract class ASTTypeIdInitializerExpression extends ASTNode implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTTypeId getTypeId() {
|
public IASTTypeId getTypeId() {
|
||||||
return typeId;
|
return typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTypeId(IASTTypeId typeId) {
|
public void setTypeId(IASTTypeId typeId) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.typeId = typeId;
|
this.typeId = typeId;
|
||||||
|
@ -54,10 +56,12 @@ public abstract class ASTTypeIdInitializerExpression extends ASTNode implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTInitializer getInitializer() {
|
public IASTInitializer getInitializer() {
|
||||||
return initializer;
|
return initializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setInitializer(IASTInitializer initializer) {
|
public void setInitializer(IASTInitializer initializer) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.initializer = initializer;
|
this.initializer = initializer;
|
||||||
|
@ -68,32 +72,34 @@ public abstract class ASTTypeIdInitializerExpression extends ASTNode implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitExpressions ){
|
if (action.shouldVisitExpressions) {
|
||||||
switch( action.visit( this ) ){
|
switch(action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( typeId != null ) if( !typeId.accept( action ) ) return false;
|
if (typeId != null && !typeId.accept(action)) return false;
|
||||||
if( initializer != null ) if( !initializer.accept( action ) ) return false;
|
if (initializer != null && !initializer.accept(action)) return false;
|
||||||
|
|
||||||
if( action.shouldVisitExpressions ){
|
if (action.shouldVisitExpressions) {
|
||||||
switch( action.leave( this ) ){
|
switch(action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final boolean isLValue() {
|
public final boolean isLValue() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final ValueCategory getValueCategory() {
|
public final ValueCategory getValueCategory() {
|
||||||
return ValueCategory.PRVALUE;
|
return ValueCategory.PRVALUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
* Collector to find all children for an ast-node.
|
* Collector to find all children for an ast-node.
|
||||||
*/
|
*/
|
||||||
class ChildCollector extends ASTGenericVisitor {
|
class ChildCollector extends ASTGenericVisitor {
|
||||||
|
|
||||||
private final IASTNode fNode;
|
private final IASTNode fNode;
|
||||||
private List<IASTNode> fNodes;
|
private List<IASTNode> fNodes;
|
||||||
|
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Corporation - initial API and implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
|
||||||
import org.eclipse.cdt.core.parser.ICodeReaderCache;
|
|
||||||
import org.eclipse.cdt.internal.core.parser.InternalParserUtil;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an empty implementation of the ICodeReaderCache interface. It is used to implement a
|
|
||||||
* cache for the interface that isn't actually a cache, but rather always creates new CodeReaders
|
|
||||||
* every time a CodeReader is retrieved.
|
|
||||||
*
|
|
||||||
* This cache is not optimized to be run from within Eclipse (i.e. it ignores IResources).
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class EmptyCodeReaderCache implements ICodeReaderCache {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new CodeReader for the given file location.
|
|
||||||
*/
|
|
||||||
public CodeReader get(String location) {
|
|
||||||
try {
|
|
||||||
return new CodeReader(location);
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CodeReader get(String key, IIndexFileLocation ifl) throws CoreException, IOException {
|
|
||||||
return InternalParserUtil.createCodeReader(ifl, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns null.
|
|
||||||
*/
|
|
||||||
public CodeReader remove(String key) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns 0.
|
|
||||||
*/
|
|
||||||
public int getCurrentSpace() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void flush() {
|
|
||||||
// nothing to do
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -63,7 +63,7 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
||||||
private static final Map<String, char[]> CHAR_ARRAYS = new HashMap<String, char[]>();
|
private static final Map<String, char[]> CHAR_ARRAYS = new HashMap<String, char[]>();
|
||||||
|
|
||||||
private IBinding[] fBindings;
|
private IBinding[] fBindings;
|
||||||
private IScope fScope= null;
|
private IScope fScope;
|
||||||
private final boolean fCpp;
|
private final boolean fCpp;
|
||||||
private final boolean fGnu;
|
private final boolean fGnu;
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider {
|
||||||
fGnu= supportGnuSymbols;
|
fGnu= supportGnuSymbols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IBinding[] getBuiltinBindings(IScope scope) {
|
public IBinding[] getBuiltinBindings(IScope scope) {
|
||||||
fScope= scope;
|
fScope= scope;
|
||||||
initialize();
|
initialize();
|
||||||
|
|
|
@ -13,22 +13,24 @@ package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal interface for c- or c++ enumeration specifiers.
|
* Internal interface for C or C++ enumeration specifiers.
|
||||||
*/
|
*/
|
||||||
public interface IASTInternalEnumerationSpecifier extends IASTEnumerationSpecifier {
|
public interface IASTInternalEnumerationSpecifier extends IASTEnumerationSpecifier {
|
||||||
/**
|
/**
|
||||||
* Notifies that the value computation for the enumeration is started. Returns whether this is the
|
* Notifies that the value computation for the enumeration is started. Returns whether this is
|
||||||
* first attempt to do so.
|
* the first attempt to do so.
|
||||||
*/
|
*/
|
||||||
boolean startValueComputation();
|
boolean startValueComputation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IASTInternalEnumerationSpecifier copy();
|
public IASTInternalEnumerationSpecifier copy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public IASTInternalEnumerationSpecifier copy(CopyStyle style);
|
public IASTInternalEnumerationSpecifier copy(CopyStyle style);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,18 @@ import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
||||||
*/
|
*/
|
||||||
public abstract class NodeFactory implements INodeFactory {
|
public abstract class NodeFactory implements INodeFactory {
|
||||||
|
|
||||||
|
@Override
|
||||||
public final void setOffsets(IASTNode node, int offset, int endOffset) {
|
public final void setOffsets(IASTNode node, int offset, int endOffset) {
|
||||||
((ASTNode) node).setOffsetAndLength(offset, endOffset-offset);
|
((ASTNode) node).setOffsetAndLength(offset, endOffset-offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final void setEndOffset(IASTNode node, int endOffset) {
|
public final void setEndOffset(IASTNode node, int endOffset) {
|
||||||
ASTNode a= (ASTNode) node;
|
ASTNode a= (ASTNode) node;
|
||||||
a.setLength(endOffset - a.getOffset());
|
a.setLength(endOffset - a.getOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public final void setEndOffset(IASTNode node, IASTNode endNode) {
|
public final void setEndOffset(IASTNode node, IASTNode endNode) {
|
||||||
ASTNode a= (ASTNode) node;
|
ASTNode a= (ASTNode) node;
|
||||||
ASTNode e= (ASTNode) endNode;
|
ASTNode e= (ASTNode) endNode;
|
||||||
|
|
|
@ -36,26 +36,32 @@ public class ProblemFunctionType extends ProblemType implements ICPPFunctionType
|
||||||
return new ProblemFunctionType(buffer.getShort());
|
return new ProblemFunctionType(buffer.getShort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IType getReturnType() {
|
public IType getReturnType() {
|
||||||
return new ProblemType(getID());
|
return new ProblemType(getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IType[] getParameterTypes() {
|
public IType[] getParameterTypes() {
|
||||||
return new IType[] {new ProblemType(getID())};
|
return new IType[] {new ProblemType(getID())};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isConst() {
|
public boolean isConst() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isVolatile() {
|
public boolean isVolatile() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean takesVarArgs() {
|
public boolean takesVarArgs() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IPointerType getThisType() {
|
public IPointerType getThisType() {
|
||||||
return new CPPPointerType(new ProblemType(getID()));
|
return new CPPPointerType(new ProblemType(getID()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of problem types.
|
* Implementation of problem types.
|
||||||
*/
|
*/
|
||||||
|
@ -28,14 +27,17 @@ public class ProblemType implements IProblemType, ISerializableType {
|
||||||
fID= id;
|
fID= id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getID() {
|
public int getID() {
|
||||||
return fID;
|
return fID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return ParserMessages.getProblemPattern(this);
|
return ParserMessages.getProblemPattern(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSameType(IType type) {
|
public boolean isSameType(IType type) {
|
||||||
return type == this;
|
return type == this;
|
||||||
}
|
}
|
||||||
|
@ -49,6 +51,7 @@ public class ProblemType implements IProblemType, ISerializableType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
||||||
buffer.putByte(ITypeMarshalBuffer.PROBLEM_TYPE);
|
buffer.putByte(ITypeMarshalBuffer.PROBLEM_TYPE);
|
||||||
buffer.putShort((short) getID());
|
buffer.putShort((short) getID());
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, IASTAmbiguityParent {
|
public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler, IASTAmbiguityParent {
|
||||||
|
|
||||||
private boolean isCatchAll;
|
private boolean isCatchAll;
|
||||||
private IASTStatement body;
|
private IASTStatement body;
|
||||||
private IASTDeclaration declaration;
|
private IASTDeclaration declaration;
|
||||||
|
@ -38,10 +37,12 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler,
|
||||||
setDeclaration(declaration);
|
setDeclaration(declaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CPPASTCatchHandler copy() {
|
public CPPASTCatchHandler copy() {
|
||||||
return copy(CopyStyle.withoutLocations);
|
return copy(CopyStyle.withoutLocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CPPASTCatchHandler copy(CopyStyle style) {
|
public CPPASTCatchHandler copy(CopyStyle style) {
|
||||||
CPPASTCatchHandler copy = new CPPASTCatchHandler();
|
CPPASTCatchHandler copy = new CPPASTCatchHandler();
|
||||||
copy.setDeclaration(declaration == null ? null : declaration.copy(style));
|
copy.setDeclaration(declaration == null ? null : declaration.copy(style));
|
||||||
|
@ -54,15 +55,18 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler,
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setIsCatchAll(boolean isEllipsis) {
|
public void setIsCatchAll(boolean isEllipsis) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
isCatchAll = isEllipsis;
|
isCatchAll = isEllipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isCatchAll() {
|
public boolean isCatchAll() {
|
||||||
return isCatchAll;
|
return isCatchAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setCatchBody(IASTStatement compoundStatement) {
|
public void setCatchBody(IASTStatement compoundStatement) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
body = compoundStatement;
|
body = compoundStatement;
|
||||||
|
@ -72,10 +76,12 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTStatement getCatchBody() {
|
public IASTStatement getCatchBody() {
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setDeclaration(IASTDeclaration decl) {
|
public void setDeclaration(IASTDeclaration decl) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
declaration = decl;
|
declaration = decl;
|
||||||
|
@ -85,48 +91,48 @@ public class CPPASTCatchHandler extends ASTNode implements ICPPASTCatchHandler,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTDeclaration getDeclaration() {
|
public IASTDeclaration getDeclaration() {
|
||||||
return declaration;
|
return declaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( declaration != null ) if( !declaration.accept( action ) ) return false;
|
if (declaration != null && !declaration.accept(action)) return false;
|
||||||
if( body != null ) if( !body.accept( action ) ) return false;
|
if (body != null && !body.accept(action)) return false;
|
||||||
|
|
||||||
if( action.shouldVisitStatements ){
|
if (action.shouldVisitStatements) {
|
||||||
switch( action.leave( this ) ){
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( body == child )
|
if (body == child) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
body = (IASTStatement) other;
|
body = (IASTStatement) other;
|
||||||
}
|
}
|
||||||
if( declaration == child )
|
if (declaration == child) {
|
||||||
{
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
|
||||||
declaration = (IASTDeclaration) other;
|
declaration = (IASTDeclaration) other;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
scope = new CPPBlockScope(this);
|
scope = new CPPBlockScope(this);
|
||||||
|
|
|
@ -77,6 +77,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ICPPASTParameterDeclaration[] getParameters() {
|
public ICPPASTParameterDeclaration[] getParameters() {
|
||||||
if (parameters == null)
|
if (parameters == null)
|
||||||
return ICPPASTParameterDeclaration.EMPTY_CPPPARAMETERDECLARATION_ARRAY;
|
return ICPPASTParameterDeclaration.EMPTY_CPPPARAMETERDECLARATION_ARRAY;
|
||||||
|
@ -84,6 +85,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
||||||
return parameters= ArrayUtil.trim(parameters);
|
return parameters= ArrayUtil.trim(parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addParameterDeclaration(IASTParameterDeclaration parameter) {
|
public void addParameterDeclaration(IASTParameterDeclaration parameter) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
if (parameter != null) {
|
if (parameter != null) {
|
||||||
|
@ -93,51 +95,62 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean takesVarArgs() {
|
public boolean takesVarArgs() {
|
||||||
return varArgs;
|
return varArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setVarArgs(boolean value) {
|
public void setVarArgs(boolean value) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
varArgs = value;
|
varArgs = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isConst() {
|
public boolean isConst() {
|
||||||
return isConst;
|
return isConst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setConst(boolean value) {
|
public void setConst(boolean value) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.isConst = value;
|
this.isConst = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isVolatile() {
|
public boolean isVolatile() {
|
||||||
return isVolatile;
|
return isVolatile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setVolatile(boolean value) {
|
public void setVolatile(boolean value) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.isVolatile = value;
|
this.isVolatile = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isMutable() {
|
public boolean isMutable() {
|
||||||
return isMutable;
|
return isMutable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setMutable(boolean value) {
|
public void setMutable(boolean value) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.isMutable = value;
|
this.isMutable = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTTypeId[] getExceptionSpecification() {
|
public IASTTypeId[] getExceptionSpecification() {
|
||||||
return typeIds= ArrayUtil.trim(typeIds);
|
return typeIds= ArrayUtil.trim(typeIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setEmptyExceptionSpecification() {
|
public void setEmptyExceptionSpecification() {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
typeIds= IASTTypeId.EMPTY_TYPEID_ARRAY;
|
typeIds= IASTTypeId.EMPTY_TYPEID_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addExceptionSpecificationTypeId(IASTTypeId typeId) {
|
public void addExceptionSpecificationTypeId(IASTTypeId typeId) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
if (typeId != null) {
|
if (typeId != null) {
|
||||||
|
@ -148,11 +161,12 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTTypeId getTrailingReturnType() {
|
public IASTTypeId getTrailingReturnType() {
|
||||||
return trailingReturnType;
|
return trailingReturnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTrailingReturnType(IASTTypeId typeId) {
|
public void setTrailingReturnType(IASTTypeId typeId) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
trailingReturnType= typeId;
|
trailingReturnType= typeId;
|
||||||
|
@ -162,20 +176,23 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPureVirtual() {
|
public boolean isPureVirtual() {
|
||||||
return pureVirtual;
|
return pureVirtual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setPureVirtual(boolean isPureVirtual) {
|
public void setPureVirtual(boolean isPureVirtual) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.pureVirtual = isPureVirtual;
|
this.pureVirtual = isPureVirtual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer[] getConstructorChain() {
|
public org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer[] getConstructorChain() {
|
||||||
if (ASTQueries.findTypeRelevantDeclarator(this) == this) {
|
if (ASTQueries.findTypeRelevantDeclarator(this) == this) {
|
||||||
IASTNode parent= getParent();
|
IASTNode parent= getParent();
|
||||||
while(!(parent instanceof IASTDeclaration)) {
|
while (!(parent instanceof IASTDeclaration)) {
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
break;
|
break;
|
||||||
parent= parent.getParent();
|
parent= parent.getParent();
|
||||||
|
@ -187,18 +204,20 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
||||||
return org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer.EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY;
|
return org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer.EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void addConstructorToChain(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer initializer) {
|
public void addConstructorToChain(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer initializer) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ICPPFunctionScope getFunctionScope() {
|
public ICPPFunctionScope getFunctionScope() {
|
||||||
if (scope != null)
|
if (scope != null)
|
||||||
return scope;
|
return scope;
|
||||||
|
|
||||||
// introduce a scope for function declarations and definitions, only.
|
// introduce a scope for function declarations and definitions, only.
|
||||||
IASTNode node= getParent();
|
IASTNode node= getParent();
|
||||||
while(!(node instanceof IASTDeclaration)) {
|
while (!(node instanceof IASTDeclaration)) {
|
||||||
if (node==null)
|
if (node==null)
|
||||||
return null;
|
return null;
|
||||||
node= node.getParent();
|
node= node.getParent();
|
||||||
|
@ -232,6 +251,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
|
||||||
return super.postAccept(action);
|
return super.postAccept(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if (parameters != null) {
|
if (parameters != null) {
|
||||||
for (int i = 0; i < parameters.length; ++i) {
|
for (int i = 0; i < parameters.length; ++i) {
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
* @see ICPPASTFunctionWithTryBlock
|
* @see ICPPASTFunctionWithTryBlock
|
||||||
*/
|
*/
|
||||||
public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition implements ICPPASTFunctionWithTryBlock {
|
public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition implements ICPPASTFunctionWithTryBlock {
|
||||||
|
private ICPPASTCatchHandler[] catchHandlers;
|
||||||
|
private int catchHandlersPos= -1;
|
||||||
|
|
||||||
public CPPASTFunctionWithTryBlock() {
|
public CPPASTFunctionWithTryBlock() {
|
||||||
}
|
}
|
||||||
|
@ -49,10 +51,12 @@ public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition impleme
|
||||||
copy.setDeclarator(declarator == null ? null : declarator.copy(style));
|
copy.setDeclarator(declarator == null ? null : declarator.copy(style));
|
||||||
copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style));
|
copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style));
|
||||||
|
|
||||||
for (ICPPASTConstructorChainInitializer initializer : getMemberInitializers())
|
for (ICPPASTConstructorChainInitializer initializer : getMemberInitializers()) {
|
||||||
copy.addMemberInitializer(initializer == null ? null : initializer.copy(style));
|
copy.addMemberInitializer(initializer == null ? null : initializer.copy(style));
|
||||||
for (ICPPASTCatchHandler handler : getCatchHandlers())
|
}
|
||||||
|
for (ICPPASTCatchHandler handler : getCatchHandlers()) {
|
||||||
copy.addCatchHandler(handler == null ? null : handler.copy(style));
|
copy.addCatchHandler(handler == null ? null : handler.copy(style));
|
||||||
|
}
|
||||||
|
|
||||||
copy.setOffsetAndLength(this);
|
copy.setOffsetAndLength(this);
|
||||||
if (style == CopyStyle.withLocations) {
|
if (style == CopyStyle.withLocations) {
|
||||||
|
@ -61,29 +65,27 @@ public class CPPASTFunctionWithTryBlock extends CPPASTFunctionDefinition impleme
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addCatchHandler(ICPPASTCatchHandler statement) {
|
public void addCatchHandler(ICPPASTCatchHandler statement) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
if (statement != null) {
|
if (statement != null) {
|
||||||
catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.append( ICPPASTCatchHandler.class, catchHandlers, ++catchHandlersPos, statement );
|
catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.append(ICPPASTCatchHandler.class, catchHandlers, ++catchHandlersPos, statement);
|
||||||
statement.setParent(this);
|
statement.setParent(this);
|
||||||
statement.setPropertyInParent(CATCH_HANDLER);
|
statement.setPropertyInParent(CATCH_HANDLER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPASTCatchHandler [] getCatchHandlers() {
|
@Override
|
||||||
if( catchHandlers == null ) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY;
|
public ICPPASTCatchHandler[] getCatchHandlers() {
|
||||||
catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.removeNullsAfter( ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos );
|
if (catchHandlers == null) return ICPPASTCatchHandler.EMPTY_CATCHHANDLER_ARRAY;
|
||||||
|
catchHandlers = (ICPPASTCatchHandler[]) ArrayUtil.removeNullsAfter(ICPPASTCatchHandler.class, catchHandlers, catchHandlersPos);
|
||||||
return catchHandlers;
|
return catchHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ICPPASTCatchHandler [] catchHandlers = null;
|
|
||||||
private int catchHandlersPos=-1;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean acceptCatchHandlers( ASTVisitor action ){
|
protected boolean acceptCatchHandlers(ASTVisitor action) {
|
||||||
final ICPPASTCatchHandler [] handlers = getCatchHandlers();
|
final ICPPASTCatchHandler[] handlers = getCatchHandlers();
|
||||||
for (int i=0; i<handlers.length; i++) {
|
for (int i= 0; i < handlers.length; i++) {
|
||||||
if (!handlers[i].accept(action))
|
if (!handlers[i].accept(action))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,12 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
|
||||||
setDeclSpecifier(declSpecifier);
|
setDeclSpecifier(declSpecifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CPPASTSimpleDeclaration copy() {
|
public CPPASTSimpleDeclaration copy() {
|
||||||
return copy(CopyStyle.withoutLocations);
|
return copy(CopyStyle.withoutLocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CPPASTSimpleDeclaration copy(CopyStyle style) {
|
public CPPASTSimpleDeclaration copy(CopyStyle style) {
|
||||||
CPPASTSimpleDeclaration copy = new CPPASTSimpleDeclaration();
|
CPPASTSimpleDeclaration copy = new CPPASTSimpleDeclaration();
|
||||||
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
|
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
|
||||||
|
@ -48,16 +50,20 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTDeclSpecifier getDeclSpecifier() {
|
public IASTDeclSpecifier getDeclSpecifier() {
|
||||||
return declSpecifier;
|
return declSpecifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTDeclarator[] getDeclarators() {
|
public IASTDeclarator[] getDeclarators() {
|
||||||
if (declarators == null) return IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
if (declarators == null)
|
||||||
|
return IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||||
declarators = (IASTDeclarator[]) ArrayUtil.removeNullsAfter(IASTDeclarator.class, declarators, declaratorsPos);
|
declarators = (IASTDeclarator[]) ArrayUtil.removeNullsAfter(IASTDeclarator.class, declarators, declaratorsPos);
|
||||||
return declarators;
|
return declarators;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addDeclarator(IASTDeclarator d) {
|
public void addDeclarator(IASTDeclarator d) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
|
@ -67,13 +73,14 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTDeclarator[] declarators = null;
|
private IASTDeclarator[] declarators;
|
||||||
private int declaratorsPos = -1;
|
private int declaratorsPos = -1;
|
||||||
private IASTDeclSpecifier declSpecifier;
|
private IASTDeclSpecifier declSpecifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param declSpecifier The declSpecifier to set.
|
* @param declSpecifier The declSpecifier to set.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDeclSpecifier(IASTDeclSpecifier declSpecifier) {
|
public void setDeclSpecifier(IASTDeclSpecifier declSpecifier) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.declSpecifier = declSpecifier;
|
this.declSpecifier = declSpecifier;
|
||||||
|
@ -93,10 +100,12 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (declSpecifier != null) if (!declSpecifier.accept(action)) return false;
|
if (declSpecifier != null && !declSpecifier.accept(action)) return false;
|
||||||
IASTDeclarator[] dtors = getDeclarators();
|
IASTDeclarator[] dtors = getDeclarators();
|
||||||
for (int i = 0; i < dtors.length; i++)
|
for (int i = 0; i < dtors.length; i++) {
|
||||||
if (!dtors[i].accept(action)) return false;
|
if (!dtors[i].accept(action))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (action.shouldVisitDeclarations) {
|
if (action.shouldVisitDeclarations) {
|
||||||
switch (action.leave(this)) {
|
switch (action.leave(this)) {
|
||||||
|
@ -108,6 +117,7 @@ public class CPPASTSimpleDeclaration extends ASTNode implements IASTSimpleDeclar
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
IASTDeclarator[] declarators = getDeclarators();
|
IASTDeclarator[] declarators = getDeclarators();
|
||||||
for (int i = 0; i < declarators.length; i++) {
|
for (int i = 0; i < declarators.length; i++) {
|
||||||
|
|
|
@ -25,7 +25,6 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
|
||||||
private IASTDeclarator absDecl;
|
private IASTDeclarator absDecl;
|
||||||
private boolean isPackExpansion;
|
private boolean isPackExpansion;
|
||||||
|
|
||||||
|
|
||||||
public CPPASTTypeId() {
|
public CPPASTTypeId() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,10 +33,12 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
|
||||||
setAbstractDeclarator(absDecl);
|
setAbstractDeclarator(absDecl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CPPASTTypeId copy() {
|
public CPPASTTypeId copy() {
|
||||||
return copy(CopyStyle.withoutLocations);
|
return copy(CopyStyle.withoutLocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CPPASTTypeId copy(CopyStyle style) {
|
public CPPASTTypeId copy(CopyStyle style) {
|
||||||
CPPASTTypeId copy = new CPPASTTypeId();
|
CPPASTTypeId copy = new CPPASTTypeId();
|
||||||
copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy(style));
|
copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy(style));
|
||||||
|
@ -50,10 +51,12 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTDeclSpecifier getDeclSpecifier() {
|
public IASTDeclSpecifier getDeclSpecifier() {
|
||||||
return declSpec;
|
return declSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
|
public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.declSpec = declSpec;
|
this.declSpec = declSpec;
|
||||||
|
@ -63,11 +66,12 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTDeclarator getAbstractDeclarator() {
|
public IASTDeclarator getAbstractDeclarator() {
|
||||||
return absDecl;
|
return absDecl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setAbstractDeclarator(IASTDeclarator abstractDeclarator) {
|
public void setAbstractDeclarator(IASTDeclarator abstractDeclarator) {
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
this.absDecl = abstractDeclarator;
|
this.absDecl = abstractDeclarator;
|
||||||
|
@ -77,10 +81,12 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPackExpansion() {
|
public boolean isPackExpansion() {
|
||||||
return isPackExpansion;
|
return isPackExpansion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setIsPackExpansion(boolean val) {
|
public void setIsPackExpansion(boolean val) {
|
||||||
isPackExpansion= val;
|
isPackExpansion= val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite;
|
package org.eclipse.cdt.internal.core.dom.rewrite;
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind;
|
||||||
|
@ -22,20 +24,18 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKin
|
||||||
/**
|
/**
|
||||||
* Represents a list of modifications to an AST node. If there are nested modifications
|
* Represents a list of modifications to an AST node. If there are nested modifications
|
||||||
* to nodes introduced by insertions or replacements, these modifications are collected
|
* to nodes introduced by insertions or replacements, these modifications are collected
|
||||||
* in separate modification maps. I.e. a modification map represents one level of
|
* in separate modification maps. I.e. a modification map represents one level of modifications.
|
||||||
* modifications.
|
|
||||||
* @see ASTModificationStore
|
* @see ASTModificationStore
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public class ASTModificationMap {
|
public class ASTModificationMap {
|
||||||
private HashMap<IASTNode, List<ASTModification>> fModifications= new HashMap<IASTNode, List<ASTModification>>();
|
private final Map<IASTNode, List<ASTModification>> fModifications= new HashMap<IASTNode, List<ASTModification>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a modification to this modification map.
|
* Adds a modification to this modification map.
|
||||||
*/
|
*/
|
||||||
public void addModification(ASTModification mod) {
|
public void addModification(ASTModification mod) {
|
||||||
final IASTNode targetNode = mod.getKind() == ASTModification.ModificationKind.INSERT_BEFORE ?
|
IASTNode targetNode = mod.getTargetNode();
|
||||||
mod.getTargetNode().getParent() : mod.getTargetNode();
|
|
||||||
List<ASTModification> mods= fModifications.get(targetNode);
|
List<ASTModification> mods= fModifications.get(targetNode);
|
||||||
if (mods == null || mods.isEmpty()) {
|
if (mods == null || mods.isEmpty()) {
|
||||||
mods= new ArrayList<ASTModification>();
|
mods= new ArrayList<ASTModification>();
|
||||||
|
|
|
@ -14,9 +14,13 @@ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
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.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||||
|
@ -34,7 +38,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||||
*/
|
*/
|
||||||
public class ASTWriter {
|
public class ASTWriter {
|
||||||
private ASTModificationStore modificationStore = new ASTModificationStore();
|
private ASTModificationStore modificationStore = new ASTModificationStore();
|
||||||
private String givenIndentation = ""; //$NON-NLS-1$
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a <code>ASTWriter</code>.
|
* Creates a <code>ASTWriter</code>.
|
||||||
|
@ -43,16 +46,6 @@ public class ASTWriter {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a <code>ASTWriter</code> that indents the code.
|
|
||||||
*
|
|
||||||
* @param givenIndentation The indentation added to each line
|
|
||||||
*/
|
|
||||||
public ASTWriter(String givenIndentation) {
|
|
||||||
super();
|
|
||||||
this.givenIndentation = givenIndentation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the source code representing this node.
|
* Generates the source code representing this node.
|
||||||
*
|
*
|
||||||
|
@ -75,10 +68,9 @@ public class ASTWriter {
|
||||||
*
|
*
|
||||||
* @see ASTCommenter#getCommentedNodeMap(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
|
* @see ASTCommenter#getCommentedNodeMap(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
|
||||||
*/
|
*/
|
||||||
public String write(IASTNode rootNode, NodeCommentMap commentMap)
|
public String write(IASTNode rootNode, NodeCommentMap commentMap) throws ProblemRuntimeException {
|
||||||
throws ProblemRuntimeException {
|
|
||||||
ChangeGeneratorWriterVisitor writer = new ChangeGeneratorWriterVisitor(
|
ChangeGeneratorWriterVisitor writer = new ChangeGeneratorWriterVisitor(
|
||||||
modificationStore, givenIndentation, null, commentMap);
|
modificationStore, null, commentMap);
|
||||||
if (rootNode != null) {
|
if (rootNode != null) {
|
||||||
rootNode.accept(writer);
|
rootNode.accept(writer);
|
||||||
}
|
}
|
||||||
|
@ -152,10 +144,35 @@ public class ASTWriter {
|
||||||
* @return <code>true</code> if the blank line between the nodes is needed.
|
* @return <code>true</code> if the blank line between the nodes is needed.
|
||||||
*/
|
*/
|
||||||
public static boolean requireBlankLineInBetween(IASTNode node1, IASTNode node2) {
|
public static boolean requireBlankLineInBetween(IASTNode node1, IASTNode node2) {
|
||||||
if (requiresTrailingBlankLine(node1))
|
if (node1 instanceof ICPPASTVisibilityLabel && node2 instanceof ICPPASTVisibilityLabel) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
if (suppressesTrailingBlankLine(node1)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (node1 instanceof IASTPreprocessorIncludeStatement !=
|
||||||
|
node2 instanceof IASTPreprocessorIncludeStatement) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (isFunctionDeclaration(node1) != isFunctionDeclaration(node2)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (requiresTrailingBlankLine(node1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return !suppressesTrailingBlankLine(node1) && requiresLeadingBlankLine(node2);
|
return requiresLeadingBlankLine(node2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isFunctionDeclaration(IASTNode node) {
|
||||||
|
if (!(node instanceof IASTSimpleDeclaration)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (IASTDeclarator declarator : ((IASTSimpleDeclaration) node).getDeclarators()) {
|
||||||
|
if (declarator instanceof IASTFunctionDeclarator)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
|
||||||
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
|
@ -62,28 +63,25 @@ public class ASTWriterVisitor extends ASTVisitor {
|
||||||
private boolean spaceNeededBeforeName;
|
private boolean spaceNeededBeforeName;
|
||||||
|
|
||||||
{
|
{
|
||||||
shouldVisitExpressions = true;
|
shouldVisitArrayModifiers = true;
|
||||||
shouldVisitStatements = true;
|
|
||||||
shouldVisitNames = true;
|
|
||||||
shouldVisitDeclarations = true;
|
|
||||||
shouldVisitDeclSpecifiers = true;
|
|
||||||
shouldVisitDeclarators = true;
|
|
||||||
shouldVisitArrayModifiers= true;
|
|
||||||
shouldVisitInitializers = true;
|
|
||||||
shouldVisitBaseSpecifiers = true;
|
shouldVisitBaseSpecifiers = true;
|
||||||
|
shouldVisitDeclarations = true;
|
||||||
|
shouldVisitDeclarators = true;
|
||||||
|
shouldVisitDeclSpecifiers = true;
|
||||||
|
shouldVisitExpressions = true;
|
||||||
|
shouldVisitInitializers = true;
|
||||||
|
shouldVisitNames = true;
|
||||||
shouldVisitNamespaces = true;
|
shouldVisitNamespaces = true;
|
||||||
shouldVisitTemplateParameters = true;
|
|
||||||
shouldVisitParameterDeclarations = true;
|
shouldVisitParameterDeclarations = true;
|
||||||
|
shouldVisitPointerOperators = true;
|
||||||
|
shouldVisitStatements = true;
|
||||||
|
shouldVisitTemplateParameters = true;
|
||||||
shouldVisitTranslationUnit = true;
|
shouldVisitTranslationUnit = true;
|
||||||
|
shouldVisitTypeIds = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ASTWriterVisitor(NodeCommentMap commentMap) {
|
public ASTWriterVisitor(NodeCommentMap commentMap) {
|
||||||
this("", commentMap); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
public ASTWriterVisitor(String givenIndentation, NodeCommentMap commentMap) {
|
|
||||||
super();
|
super();
|
||||||
scribe.setGivenIndentation(givenIndentation);
|
|
||||||
init(commentMap);
|
init(commentMap);
|
||||||
this.commentMap = commentMap;
|
this.commentMap = commentMap;
|
||||||
this.suppressLeadingBlankLine = true;
|
this.suppressLeadingBlankLine = true;
|
||||||
|
@ -123,8 +121,8 @@ public class ASTWriterVisitor extends ASTVisitor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<IASTComment> getLeadingComments(IASTNode node) {
|
private List<IASTComment> getLeadingComments(IASTNode node) {
|
||||||
ArrayList<IASTComment> leadingComments = commentMap.getLeadingCommentsForNode(node);
|
List<IASTComment> leadingComments = commentMap.getLeadingCommentsForNode(node);
|
||||||
IASTNodeLocation[] locs = node.getNodeLocations();
|
IASTNodeLocation[] locs = node.getNodeLocations();
|
||||||
if (locs != null && locs.length > 0 && locs[0] instanceof IASTCopyLocation) {
|
if (locs != null && locs.length > 0 && locs[0] instanceof IASTCopyLocation) {
|
||||||
IASTCopyLocation copyLoc = (IASTCopyLocation) locs[0];
|
IASTCopyLocation copyLoc = (IASTCopyLocation) locs[0];
|
||||||
|
@ -240,6 +238,15 @@ public class ASTWriterVisitor extends ASTVisitor {
|
||||||
return ASTVisitor.PROCESS_SKIP;
|
return ASTVisitor.PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTPointerOperator pointerOperator) {
|
||||||
|
writeLeadingComments(pointerOperator);
|
||||||
|
if (!macroHandler.checkisMacroExpansionNode(pointerOperator)) {
|
||||||
|
declaratorWriter.writePointerOperator(pointerOperator);
|
||||||
|
}
|
||||||
|
return ASTVisitor.PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
protected IASTName getParameterName(IASTDeclarator declarator) {
|
protected IASTName getParameterName(IASTDeclarator declarator) {
|
||||||
return declarator.getName();
|
return declarator.getName();
|
||||||
}
|
}
|
||||||
|
@ -303,6 +310,10 @@ public class ASTWriterVisitor extends ASTVisitor {
|
||||||
this.spaceNeededBeforeName = value;
|
this.spaceNeededBeforeName = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Scribe getScribe() {
|
||||||
|
return scribe;
|
||||||
|
}
|
||||||
|
|
||||||
public void newLine() {
|
public void newLine() {
|
||||||
scribe.newLine();
|
scribe.newLine();
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasFreestandingComments(compDeclSpec)) {
|
if (hasFreestandingComments(compDeclSpec)) {
|
||||||
writeFreeStandingComments(compDeclSpec);
|
writeFreestandingComments(compDeclSpec);
|
||||||
}
|
}
|
||||||
scribe.decrementIndentationLevel();
|
scribe.decrementIndentationLevel();
|
||||||
scribe.print('}');
|
scribe.print('}');
|
||||||
|
|
|
@ -98,17 +98,12 @@ public class DeclarationWriter extends NodeWriter {
|
||||||
writeVisibilityLabel((ICPPASTVisibilityLabel) declaration);
|
writeVisibilityLabel((ICPPASTVisibilityLabel) declaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasTrailingComments(declaration)) {
|
writeTrailingComments(declaration, addNewLine);
|
||||||
writeTrailingComments(declaration, false);
|
|
||||||
}
|
|
||||||
if (addNewLine) {
|
|
||||||
scribe.newLine();
|
|
||||||
}
|
|
||||||
if (hasFreestandingComments(declaration)) {
|
if (hasFreestandingComments(declaration)) {
|
||||||
if (declaration instanceof IASTFunctionDefinition) {
|
if (declaration instanceof IASTFunctionDefinition) {
|
||||||
scribe.newLine();
|
scribe.newLine();
|
||||||
}
|
}
|
||||||
writeFreeStandingComments(declaration);
|
writeFreestandingComments(declaration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +181,7 @@ public class DeclarationWriter extends NodeWriter {
|
||||||
scribe.newLine(2);
|
scribe.newLine(2);
|
||||||
writeDeclarationsInNamespace(namespaceDefinition, namespaceDefinition.getDeclarations());
|
writeDeclarationsInNamespace(namespaceDefinition, namespaceDefinition.getDeclarations());
|
||||||
if (hasFreestandingComments(namespaceDefinition)) {
|
if (hasFreestandingComments(namespaceDefinition)) {
|
||||||
writeFreeStandingComments(namespaceDefinition);
|
writeFreestandingComments(namespaceDefinition);
|
||||||
}
|
}
|
||||||
scribe.newLine();
|
scribe.newLine();
|
||||||
scribe.print('}');
|
scribe.print('}');
|
||||||
|
|
|
@ -62,10 +62,8 @@ public class DeclaratorWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
visitor.setSpaceNeededBeforeName(false);
|
visitor.setSpaceNeededBeforeName(false);
|
||||||
if (hasTrailingComments(declarator)) {
|
|
||||||
writeTrailingComments(declarator, false);
|
writeTrailingComments(declarator, false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected void writeDefaultDeclarator(IASTDeclarator declarator) {
|
protected void writeDefaultDeclarator(IASTDeclarator declarator) {
|
||||||
IASTPointerOperator[] pointOps = declarator.getPointerOperators();
|
IASTPointerOperator[] pointOps = declarator.getPointerOperators();
|
||||||
|
@ -81,7 +79,7 @@ public class DeclaratorWriter extends NodeWriter {
|
||||||
|
|
||||||
protected void writePointerOperators(IASTDeclarator declarator, IASTPointerOperator[] pointOps) {
|
protected void writePointerOperators(IASTDeclarator declarator, IASTPointerOperator[] pointOps) {
|
||||||
for (IASTPointerOperator operator : pointOps) {
|
for (IASTPointerOperator operator : pointOps) {
|
||||||
writePointerOp(operator);
|
writePointerOperator(operator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +192,7 @@ public class DeclaratorWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writePointerOp(IASTPointerOperator operator) {
|
public void writePointerOperator(IASTPointerOperator operator) {
|
||||||
if (operator instanceof IASTPointer) {
|
if (operator instanceof IASTPointer) {
|
||||||
IASTPointer pointOp = (IASTPointer) operator;
|
IASTPointer pointOp = (IASTPointer) operator;
|
||||||
writePointer(pointOp);
|
writePointer(pointOp);
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class InitializerWriter extends NodeWriter{
|
||||||
} else if (initializer instanceof ICPPASTConstructorChainInitializer) {
|
} else if (initializer instanceof ICPPASTConstructorChainInitializer) {
|
||||||
writeConstructorChainInitializer((ICPPASTConstructorChainInitializer) initializer);
|
writeConstructorChainInitializer((ICPPASTConstructorChainInitializer) initializer);
|
||||||
}
|
}
|
||||||
if (hasTrailingComments(initializer))
|
|
||||||
writeTrailingComments(initializer, false);
|
writeTrailingComments(initializer, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCopyLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTCopyLocation;
|
||||||
|
@ -83,7 +83,7 @@ public class NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeTrailingComments(IASTNode node) {
|
protected void writeTrailingComments(IASTNode node) {
|
||||||
// Default is to write a new line after trailing comments.
|
// Default is to write a new line after the trailing comments.
|
||||||
writeTrailingComments(node, true);
|
writeTrailingComments(node, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,8 +106,8 @@ public class NodeWriter {
|
||||||
return !getTrailingComments(node).isEmpty();
|
return !getTrailingComments(node).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<IASTComment> getTrailingComments(IASTNode node) {
|
private List<IASTComment> getTrailingComments(IASTNode node) {
|
||||||
ArrayList<IASTComment> trailingComments = commentMap.getTrailingCommentsForNode(node);
|
List<IASTComment> trailingComments = commentMap.getTrailingCommentsForNode(node);
|
||||||
IASTNodeLocation[] locs = node.getNodeLocations();
|
IASTNodeLocation[] locs = node.getNodeLocations();
|
||||||
if (locs != null && locs.length > 0 && locs[0] instanceof IASTCopyLocation) {
|
if (locs != null && locs.length > 0 && locs[0] instanceof IASTCopyLocation) {
|
||||||
IASTCopyLocation loc = (IASTCopyLocation) locs[0];
|
IASTCopyLocation loc = (IASTCopyLocation) locs[0];
|
||||||
|
@ -120,8 +120,8 @@ public class NodeWriter {
|
||||||
return !getFreestandingComments(node).isEmpty();
|
return !getFreestandingComments(node).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<IASTComment> getFreestandingComments(IASTNode node) {
|
private List<IASTComment> getFreestandingComments(IASTNode node) {
|
||||||
ArrayList<IASTComment> freestandingComments = commentMap.getFreestandingCommentsForNode(node);
|
List<IASTComment> freestandingComments = commentMap.getFreestandingCommentsForNode(node);
|
||||||
IASTNodeLocation[] locs = node.getNodeLocations();
|
IASTNodeLocation[] locs = node.getNodeLocations();
|
||||||
if (locs != null && locs.length > 0 && locs[0] instanceof IASTCopyLocation) {
|
if (locs != null && locs.length > 0 && locs[0] instanceof IASTCopyLocation) {
|
||||||
IASTCopyLocation loc = (IASTCopyLocation) locs[0];
|
IASTCopyLocation loc = (IASTCopyLocation) locs[0];
|
||||||
|
@ -130,7 +130,7 @@ public class NodeWriter {
|
||||||
return freestandingComments;
|
return freestandingComments;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeFreeStandingComments(IASTNode node) {
|
protected void writeFreestandingComments(IASTNode node) {
|
||||||
for (IASTComment comment : getFreestandingComments(node)) {
|
for (IASTComment comment : getFreestandingComments(node)) {
|
||||||
scribe.print(comment.getComment());
|
scribe.print(comment.getComment());
|
||||||
scribe.newLine();
|
scribe.newLine();
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||||
|
|
||||||
|
@ -19,42 +20,43 @@ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*/
|
*/
|
||||||
public class Scribe {
|
public class Scribe {
|
||||||
private int indentationLevel = 0;
|
// Indentation is not necessary since the code is going to be formatted anyway.
|
||||||
// Any positive indentation size is good enough since the code is going to be formatted anyway.
|
// Preserved because some tests depend on it.
|
||||||
private int indentationSize = 4;
|
private static final int INDENTATION_SIZE = 4;
|
||||||
|
private final String newLine = System.getProperty("line.separator"); //$NON-NLS-1$
|
||||||
private StringBuilder buffer = new StringBuilder();
|
private StringBuilder buffer = new StringBuilder();
|
||||||
private boolean isAtLineBeginning = true;
|
private int indentationLevel = 0;
|
||||||
private String newLine = System.getProperty("line.separator"); //$NON-NLS-1$
|
private boolean isAtBeginningOfLine = true;
|
||||||
private String givenIndentation;
|
|
||||||
|
|
||||||
private boolean skipLineBreaks;
|
private boolean skipLineBreaks;
|
||||||
private boolean skipSemicolons;
|
private boolean skipSemicolons;
|
||||||
|
|
||||||
|
public String getLineSeparator() {
|
||||||
|
return newLine;
|
||||||
|
}
|
||||||
|
|
||||||
public void newLine() {
|
public void newLine() {
|
||||||
if (!skipLineBreaks) {
|
if (!skipLineBreaks) {
|
||||||
isAtLineBeginning = true;
|
isAtBeginningOfLine = true;
|
||||||
buffer.append(getNewline());
|
buffer.append(newLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAtBeginningOfLine() {
|
||||||
|
return isAtBeginningOfLine;
|
||||||
|
}
|
||||||
|
|
||||||
private void indent() {
|
private void indent() {
|
||||||
if (givenIndentation != null) {
|
printSpaces(indentationLevel * INDENTATION_SIZE);
|
||||||
buffer.append(givenIndentation);
|
|
||||||
}
|
|
||||||
printSpaces(indentationLevel * indentationSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void indentIfNewLine() {
|
private void indentIfNewLine() {
|
||||||
if (isAtLineBeginning) {
|
if (isAtBeginningOfLine) {
|
||||||
isAtLineBeginning = false;
|
isAtBeginningOfLine = false;
|
||||||
indent();
|
indent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNewline() {
|
|
||||||
return newLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void print(String code) {
|
public void print(String code) {
|
||||||
indentIfNewLine();
|
indentIfNewLine();
|
||||||
buffer.append(code);
|
buffer.append(code);
|
||||||
|
@ -171,14 +173,6 @@ public class Scribe {
|
||||||
buffer.append(' ');
|
buffer.append(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGivenIndentation() {
|
|
||||||
return givenIndentation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGivenIndentation(String givenIndentation) {
|
|
||||||
this.givenIndentation = givenIndentation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cleanCache() {
|
public void cleanCache() {
|
||||||
buffer = new StringBuilder();
|
buffer = new StringBuilder();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
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.core.resources.IFile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates source code of statement nodes. The actual string operations are delegated
|
* Generates source code of statement nodes. The actual string operations are delegated
|
||||||
|
@ -154,11 +151,7 @@ public class StatementWriter extends NodeWriter {
|
||||||
throw new ProblemRuntimeException((IASTProblemStatement)statement);
|
throw new ProblemRuntimeException((IASTProblemStatement)statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasTrailingComments(statement)) {
|
|
||||||
writeTrailingComments(statement, newLine);
|
writeTrailingComments(statement, newLine);
|
||||||
} else if (newLine) {
|
|
||||||
scribe.newLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ASTVisitor.PROCESS_SKIP;
|
return ASTVisitor.PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
@ -389,7 +382,7 @@ public class StatementWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasFreestandingComments(compoundStatement)) {
|
if (hasFreestandingComments(compoundStatement)) {
|
||||||
writeFreeStandingComments(compoundStatement);
|
writeFreestandingComments(compoundStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decrementIndentationLevelOneMore) {
|
if (decrementIndentationLevelOneMore) {
|
||||||
|
@ -438,11 +431,7 @@ public class StatementWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int writeMixedStatement(IASTStatement statement) {
|
protected int writeMixedStatement(IASTStatement statement) {
|
||||||
IFile file = FileHelper.getFileFromNode(statement);
|
String code = statement.getRawSignature();
|
||||||
int offset = statement.getFileLocation().getNodeOffset();
|
|
||||||
int length = statement.getFileLocation().getNodeLength();
|
|
||||||
String code = FileContentHelper.getContent(file, offset, length);
|
|
||||||
|
|
||||||
scribe.println(code);
|
scribe.println(code);
|
||||||
return ASTVisitor.PROCESS_SKIP;
|
return ASTVisitor.PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
@ -100,29 +100,29 @@ public class ASTModificationHelper {
|
||||||
|
|
||||||
private void copyComments(IASTNode newNode, IASTNode oldNode, NodeCommentMap commentMap) {
|
private void copyComments(IASTNode newNode, IASTNode oldNode, NodeCommentMap commentMap) {
|
||||||
// Attach all the comments that is attached to oldNode to newNode
|
// Attach all the comments that is attached to oldNode to newNode
|
||||||
ArrayList<IASTComment> leadingComments = commentMap.getLeadingCommentsForNode(oldNode);
|
List<IASTComment> leadingComments = commentMap.getLeadingCommentsForNode(oldNode);
|
||||||
for (IASTComment comment : leadingComments) {
|
for (IASTComment comment : leadingComments) {
|
||||||
commentMap.addLeadingCommentToNode(newNode, comment);
|
commentMap.addLeadingCommentToNode(newNode, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<IASTComment> trailingComments = commentMap.getTrailingCommentsForNode(oldNode);
|
List<IASTComment> trailingComments = commentMap.getTrailingCommentsForNode(oldNode);
|
||||||
for (IASTComment comment : trailingComments) {
|
for (IASTComment comment : trailingComments) {
|
||||||
commentMap.addTrailingCommentToNode(newNode, comment);
|
commentMap.addTrailingCommentToNode(newNode, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<IASTComment> freestandingComments = commentMap.getFreestandingCommentsForNode(oldNode);
|
List<IASTComment> freestandingComments = commentMap.getFreestandingCommentsForNode(oldNode);
|
||||||
for (IASTComment comment : freestandingComments) {
|
for (IASTComment comment : freestandingComments) {
|
||||||
commentMap.addFreestandingCommentToNode(newNode, comment);
|
commentMap.addFreestandingCommentToNode(newNode, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detach comments from oldNode (to avoid memory leak)
|
// Detach comments from oldNode (to avoid memory leak)
|
||||||
HashMap<IASTNode, ArrayList<IASTComment>> leadingMap = commentMap.getLeadingMap();
|
Map<IASTNode, List<IASTComment>> leadingMap = commentMap.getLeadingMap();
|
||||||
leadingMap.remove(oldNode);
|
leadingMap.remove(oldNode);
|
||||||
|
|
||||||
HashMap<IASTNode, ArrayList<IASTComment>> trailingMap = commentMap.getTrailingMap();
|
Map<IASTNode, List<IASTComment>> trailingMap = commentMap.getTrailingMap();
|
||||||
trailingMap.remove(oldNode);
|
trailingMap.remove(oldNode);
|
||||||
|
|
||||||
HashMap<IASTNode, ArrayList<IASTComment>> freestandingMap = commentMap.getFreestandingMap();
|
Map<IASTNode, List<IASTComment>> freestandingMap = commentMap.getFreestandingMap();
|
||||||
freestandingMap.remove(oldNode);
|
freestandingMap.remove(oldNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -16,15 +16,15 @@ import org.eclipse.osgi.util.NLS;
|
||||||
* External strings for the change generator.
|
* External strings for the change generator.
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public class Messages extends NLS {
|
public class ChangeGeneratorMessages extends NLS {
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.dom.rewrite.changegenerator.messages"; //$NON-NLS-1$
|
|
||||||
public static String ChangeGenerator_compositeChange;
|
public static String ChangeGenerator_compositeChange;
|
||||||
public static String ChangeGenerator_group;
|
public static String ChangeGenerator_group;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// Initialize resource bundle
|
||||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
NLS.initializeMessages(ChangeGeneratorMessages.class.getName(), ChangeGeneratorMessages.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Messages() {
|
private ChangeGeneratorMessages() {
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
@ -43,7 +44,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*/
|
*/
|
||||||
public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
||||||
private static final String DEFAULT_INDENTATION = ""; //$NON-NLS-1$
|
|
||||||
private final ASTModificationStore modificationStore;
|
private final ASTModificationStore modificationStore;
|
||||||
private final String fileScope;
|
private final String fileScope;
|
||||||
private ModificationScopeStack stack;
|
private ModificationScopeStack stack;
|
||||||
|
@ -56,30 +56,31 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
||||||
this.fileScope = fileScope;
|
this.fileScope = fileScope;
|
||||||
this.stack = new ModificationScopeStack(modificationStore);
|
this.stack = new ModificationScopeStack(modificationStore);
|
||||||
|
|
||||||
shouldVisitExpressions = delegateVisitor.shouldVisitExpressions;
|
|
||||||
shouldVisitStatements = delegateVisitor.shouldVisitStatements;
|
|
||||||
shouldVisitNames = delegateVisitor.shouldVisitNames;
|
|
||||||
shouldVisitDeclarations = delegateVisitor.shouldVisitDeclarators;
|
|
||||||
shouldVisitDeclSpecifiers = delegateVisitor.shouldVisitDeclSpecifiers;
|
|
||||||
shouldVisitDeclarators = delegateVisitor.shouldVisitDeclarators;
|
|
||||||
shouldVisitInitializers = delegateVisitor.shouldVisitInitializers;
|
|
||||||
shouldVisitBaseSpecifiers = delegateVisitor.shouldVisitBaseSpecifiers;
|
|
||||||
shouldVisitNamespaces = delegateVisitor.shouldVisitNamespaces;
|
|
||||||
shouldVisitTemplateParameters = delegateVisitor.shouldVisitTemplateParameters;
|
|
||||||
shouldVisitParameterDeclarations = delegateVisitor.shouldVisitParameterDeclarations;
|
|
||||||
shouldVisitTranslationUnit = delegateVisitor.shouldVisitTranslationUnit;
|
|
||||||
shouldVisitProblems = delegateVisitor.shouldVisitProblems;
|
|
||||||
shouldVisitTypeIds = delegateVisitor.shouldVisitTypeIds;
|
|
||||||
shouldVisitArrayModifiers= delegateVisitor.shouldVisitArrayModifiers;
|
shouldVisitArrayModifiers= delegateVisitor.shouldVisitArrayModifiers;
|
||||||
|
shouldVisitBaseSpecifiers = delegateVisitor.shouldVisitBaseSpecifiers;
|
||||||
|
shouldVisitDeclarations = delegateVisitor.shouldVisitDeclarators;
|
||||||
|
shouldVisitDeclarators = delegateVisitor.shouldVisitDeclarators;
|
||||||
|
shouldVisitDeclSpecifiers = delegateVisitor.shouldVisitDeclSpecifiers;
|
||||||
|
shouldVisitExpressions = delegateVisitor.shouldVisitExpressions;
|
||||||
|
shouldVisitInitializers = delegateVisitor.shouldVisitInitializers;
|
||||||
|
shouldVisitNames = delegateVisitor.shouldVisitNames;
|
||||||
|
shouldVisitNamespaces = delegateVisitor.shouldVisitNamespaces;
|
||||||
|
shouldVisitParameterDeclarations = delegateVisitor.shouldVisitParameterDeclarations;
|
||||||
|
shouldVisitPointerOperators= delegateVisitor.shouldVisitPointerOperators;
|
||||||
|
shouldVisitProblems = delegateVisitor.shouldVisitProblems;
|
||||||
|
shouldVisitStatements = delegateVisitor.shouldVisitStatements;
|
||||||
|
shouldVisitTemplateParameters = delegateVisitor.shouldVisitTemplateParameters;
|
||||||
|
shouldVisitTranslationUnit = delegateVisitor.shouldVisitTranslationUnit;
|
||||||
|
shouldVisitTypeIds = delegateVisitor.shouldVisitTypeIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeGeneratorWriterVisitor(ASTModificationStore modStore, NodeCommentMap nodeMap) {
|
public ChangeGeneratorWriterVisitor(ASTModificationStore modStore, NodeCommentMap nodeMap) {
|
||||||
this(modStore, DEFAULT_INDENTATION, null, nodeMap);
|
this(modStore, null, nodeMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeGeneratorWriterVisitor(ASTModificationStore modStore, String givenIndentation,
|
public ChangeGeneratorWriterVisitor(ASTModificationStore modStore, String fileScope,
|
||||||
String fileScope, NodeCommentMap commentMap) {
|
NodeCommentMap commentMap) {
|
||||||
super(givenIndentation, commentMap);
|
super(commentMap);
|
||||||
this.modificationStore = modStore;
|
this.modificationStore = modStore;
|
||||||
this.fileScope = fileScope;
|
this.fileScope = fileScope;
|
||||||
this.shouldVisitTranslationUnit = true;
|
this.shouldVisitTranslationUnit = true;
|
||||||
|
@ -209,6 +210,12 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int leave(IASTPointerOperator pointerOperator) {
|
||||||
|
super.leave(pointerOperator);
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int leave(IASTProblem problem) {
|
public int leave(IASTProblem problem) {
|
||||||
super.leave(problem);
|
super.leave(problem);
|
||||||
|
@ -305,6 +312,14 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTPointerOperator pointerOperator) {
|
||||||
|
if (doBeforeEveryNode(pointerOperator) == PROCESS_CONTINUE) {
|
||||||
|
return super.visit(pointerOperator);
|
||||||
|
}
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTProblem problem) {
|
public int visit(IASTProblem problem) {
|
||||||
if (doBeforeEveryNode(problem) == PROCESS_CONTINUE) {
|
if (doBeforeEveryNode(problem) == PROCESS_CONTINUE) {
|
||||||
|
@ -369,10 +384,8 @@ public class ChangeGeneratorWriterVisitor extends ASTWriterVisitor {
|
||||||
stack.pushScope(node);
|
stack.pushScope(node);
|
||||||
currentMod.getNewNode().accept(this);
|
currentMod.getNewNode().accept(this);
|
||||||
stack.popScope(node);
|
stack.popScope(node);
|
||||||
return PROCESS_SKIP;
|
|
||||||
} else {
|
|
||||||
return PROCESS_SKIP;
|
|
||||||
}
|
}
|
||||||
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
@ -22,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
@ -36,7 +38,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.util.OffsetHelper;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -171,26 +172,25 @@ public class ASTCommenter {
|
||||||
* @return NodeCommentMap
|
* @return NodeCommentMap
|
||||||
*/
|
*/
|
||||||
public static NodeCommentMap getCommentedNodeMap(IASTTranslationUnit transUnit){
|
public static NodeCommentMap getCommentedNodeMap(IASTTranslationUnit transUnit){
|
||||||
if (transUnit== null) {
|
if (transUnit == null) {
|
||||||
return new NodeCommentMap();
|
return new NodeCommentMap();
|
||||||
}
|
}
|
||||||
ArrayList<IASTComment> comments = removeNotNeededComments(transUnit);
|
List<IASTComment> comments = removeNotNeededComments(transUnit);
|
||||||
if (comments == null || comments.size() == 0) {
|
if (comments == null || comments.isEmpty()) {
|
||||||
return new NodeCommentMap();
|
return new NodeCommentMap();
|
||||||
}
|
}
|
||||||
return addCommentsToCommentMap(transUnit, comments);
|
return addCommentsToCommentMap(transUnit, comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<IASTComment> removeNotNeededComments(IASTTranslationUnit transUnit) {
|
private static List<IASTComment> removeNotNeededComments(IASTTranslationUnit transUnit) {
|
||||||
ArrayList<IASTComment> comments = getCommentsInWorkspace(transUnit);
|
List<IASTComment> comments = getCommentsInWorkspace(transUnit);
|
||||||
if (comments == null || comments.size() == 0) {
|
if (comments == null || comments.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ArrayList<IASTComment> com = removeAllPreprocessorComments(transUnit, comments);
|
return removeAllPreprocessorComments(transUnit, comments);
|
||||||
return com;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<IASTComment> getCommentsInWorkspace(IASTTranslationUnit tu) {
|
private static List<IASTComment> getCommentsInWorkspace(IASTTranslationUnit tu) {
|
||||||
IASTComment[] comments = tu.getComments();
|
IASTComment[] comments = tu.getComments();
|
||||||
ArrayList<IASTComment> commentsInWorkspace = new ArrayList<IASTComment>();
|
ArrayList<IASTComment> commentsInWorkspace = new ArrayList<IASTComment>();
|
||||||
|
|
||||||
|
@ -206,8 +206,8 @@ public class ASTCommenter {
|
||||||
return commentsInWorkspace;
|
return commentsInWorkspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<IASTComment> removeAllPreprocessorComments(IASTTranslationUnit tu,
|
private static List<IASTComment> removeAllPreprocessorComments(IASTTranslationUnit tu,
|
||||||
ArrayList<IASTComment> comments) {
|
List<IASTComment> comments) {
|
||||||
IASTPreprocessorStatement[] preprocessorStatements = tu.getAllPreprocessorStatements();
|
IASTPreprocessorStatement[] preprocessorStatements = tu.getAllPreprocessorStatements();
|
||||||
TreeMap<Integer, String> treeOfPreProcessorLines = new TreeMap<Integer,String>();
|
TreeMap<Integer, String> treeOfPreProcessorLines = new TreeMap<Integer,String>();
|
||||||
TreeMap<String, ArrayList<Integer>> ppOffsetForFiles = new TreeMap<String, ArrayList<Integer>>();
|
TreeMap<String, ArrayList<Integer>> ppOffsetForFiles = new TreeMap<String, ArrayList<Integer>>();
|
||||||
|
@ -215,7 +215,7 @@ public class ASTCommenter {
|
||||||
for (IASTPreprocessorStatement statement : preprocessorStatements) {
|
for (IASTPreprocessorStatement statement : preprocessorStatements) {
|
||||||
if (isInWorkspace(statement)) {
|
if (isInWorkspace(statement)) {
|
||||||
String fileName = statement.getFileLocation().getFileName();
|
String fileName = statement.getFileLocation().getFileName();
|
||||||
treeOfPreProcessorLines.put(OffsetHelper.getStartingLineNumber(statement), fileName);
|
treeOfPreProcessorLines.put(statement.getFileLocation().getStartingLineNumber(), fileName);
|
||||||
ArrayList<Integer> offsetList = ppOffsetForFiles.get(fileName);
|
ArrayList<Integer> offsetList = ppOffsetForFiles.get(fileName);
|
||||||
if (offsetList == null) {
|
if (offsetList == null) {
|
||||||
offsetList = new ArrayList<Integer>();
|
offsetList = new ArrayList<Integer>();
|
||||||
|
@ -227,8 +227,9 @@ public class ASTCommenter {
|
||||||
|
|
||||||
ArrayList<IASTComment> commentsInCode = new ArrayList<IASTComment>();
|
ArrayList<IASTComment> commentsInCode = new ArrayList<IASTComment>();
|
||||||
for (IASTComment comment : comments) {
|
for (IASTComment comment : comments) {
|
||||||
int comStartLineNumber = OffsetHelper.getStartingLineNumber(comment);
|
IASTFileLocation commentFileLocation = comment.getFileLocation();
|
||||||
String fileName = comment.getFileLocation().getFileName();
|
int comStartLineNumber = commentFileLocation.getStartingLineNumber();
|
||||||
|
String fileName = commentFileLocation.getFileName();
|
||||||
if (treeOfPreProcessorLines.containsKey(comStartLineNumber)
|
if (treeOfPreProcessorLines.containsKey(comStartLineNumber)
|
||||||
&& treeOfPreProcessorLines.get(comStartLineNumber).equals(fileName)) {
|
&& treeOfPreProcessorLines.get(comStartLineNumber).equals(fileName)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -248,7 +249,7 @@ public class ASTCommenter {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comment.getTranslationUnit()==null || comment.getTranslationUnit().getDeclarations().length < 1) {
|
if (comment.getTranslationUnit() == null || comment.getTranslationUnit().getDeclarations().length < 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
IASTDeclaration decl = comment.getTranslationUnit().getDeclarations()[0];
|
IASTDeclaration decl = comment.getTranslationUnit().getDeclarations()[0];
|
||||||
|
@ -286,7 +287,7 @@ public class ASTCommenter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NodeCommentMap addCommentsToCommentMap(IASTTranslationUnit rootNode,
|
private static NodeCommentMap addCommentsToCommentMap(IASTTranslationUnit rootNode,
|
||||||
ArrayList<IASTComment> comments){
|
List<IASTComment> comments){
|
||||||
NodeCommentMap commentMap = new NodeCommentMap();
|
NodeCommentMap commentMap = new NodeCommentMap();
|
||||||
CommentHandler commHandler = new CommentHandler(comments);
|
CommentHandler commHandler = new CommentHandler(comments);
|
||||||
|
|
||||||
|
@ -296,8 +297,8 @@ public class ASTCommenter {
|
||||||
ASTCommenterVisitor commenter = new ASTCommenterVisitor(commHandler, commentMap);
|
ASTCommenterVisitor commenter = new ASTCommenterVisitor(commHandler, commentMap);
|
||||||
declarations[i].accept(commenter);
|
declarations[i].accept(commenter);
|
||||||
|
|
||||||
//add remaining comments to the last declaration => Comments won't get lost
|
// Add the remaining comments to the last declaration to prevent comment loss.
|
||||||
if (i + 1 == declarations.length) {
|
if (i == declarations.length - 1) {
|
||||||
commenter.addRemainingComments(declarations[i]);
|
commenter.addRemainingComments(declarations[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,17 +45,18 @@ public class ASTCommenterVisitor extends ASTVisitor {
|
||||||
private NodeCommenter nodeCommenter;
|
private NodeCommenter nodeCommenter;
|
||||||
|
|
||||||
{
|
{
|
||||||
shouldVisitExpressions = true;
|
|
||||||
shouldVisitStatements = true;
|
|
||||||
shouldVisitNames = true;
|
|
||||||
shouldVisitDeclarations = true;
|
|
||||||
shouldVisitDeclSpecifiers = true;
|
|
||||||
shouldVisitDeclarators = true;
|
|
||||||
shouldVisitInitializers = true;
|
|
||||||
shouldVisitBaseSpecifiers = true;
|
shouldVisitBaseSpecifiers = true;
|
||||||
|
shouldVisitDeclarations = true;
|
||||||
|
shouldVisitDeclarators = true;
|
||||||
|
shouldVisitDeclSpecifiers = true;
|
||||||
|
shouldVisitExpressions = true;
|
||||||
|
shouldVisitInitializers = true;
|
||||||
|
shouldVisitNames = true;
|
||||||
shouldVisitNamespaces = true;
|
shouldVisitNamespaces = true;
|
||||||
shouldVisitTemplateParameters = true;
|
|
||||||
shouldVisitParameterDeclarations = true;
|
shouldVisitParameterDeclarations = true;
|
||||||
|
shouldVisitStatements = true;
|
||||||
|
shouldVisitTemplateParameters = true;
|
||||||
|
shouldVisitTypeIds = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ASTCommenterVisitor(CommentHandler commHandler, NodeCommentMap commentMap) {
|
public ASTCommenterVisitor(CommentHandler commHandler, NodeCommentMap commentMap) {
|
||||||
|
@ -92,6 +93,11 @@ public class ASTCommenterVisitor extends ASTVisitor {
|
||||||
return nodeCommenter.appendComments((ASTNode) statement);
|
return nodeCommenter.appendComments((ASTNode) statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTTypeId typeId) {
|
||||||
|
return nodeCommenter.appendComments((ASTNode) typeId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int visit(IASTDeclaration declaration) {
|
public int visit(IASTDeclaration declaration) {
|
||||||
return nodeCommenter.appendComments((ASTNode) declaration);
|
return nodeCommenter.appendComments((ASTNode) declaration);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler;
|
package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||||
|
|
||||||
|
@ -23,10 +23,9 @@ import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||||
* @author Guido Zgraggen IFS
|
* @author Guido Zgraggen IFS
|
||||||
*/
|
*/
|
||||||
public class CommentHandler {
|
public class CommentHandler {
|
||||||
|
private final List<IASTComment> comments;
|
||||||
|
|
||||||
private final ArrayList<IASTComment> comments;
|
public CommentHandler(List<IASTComment> comments) {
|
||||||
|
|
||||||
public CommentHandler(ArrayList<IASTComment> comments) {
|
|
||||||
super();
|
super();
|
||||||
this.comments = comments;
|
this.comments = comments;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +35,7 @@ public class CommentHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasMore() {
|
public boolean hasMore() {
|
||||||
return comments.size()>0;
|
return !comments.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTComment getFirst() {
|
public IASTComment getFirst() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -13,6 +13,8 @@ package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
@ -25,18 +27,18 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
* @author Guido Zgraggen IFS
|
* @author Guido Zgraggen IFS
|
||||||
*/
|
*/
|
||||||
public class NodeCommentMap {
|
public class NodeCommentMap {
|
||||||
protected final HashMap<IASTNode, ArrayList<IASTComment>> leadingMap = new HashMap<IASTNode, ArrayList<IASTComment>>();
|
protected final Map<IASTNode, List<IASTComment>> leadingMap = new HashMap<IASTNode, List<IASTComment>>();
|
||||||
protected final HashMap<IASTNode, ArrayList<IASTComment>> trailingMap = new HashMap<IASTNode, ArrayList<IASTComment>>();
|
protected final Map<IASTNode, List<IASTComment>> trailingMap = new HashMap<IASTNode, List<IASTComment>>();
|
||||||
protected final HashMap<IASTNode, ArrayList<IASTComment>> freestandingMap = new HashMap<IASTNode, ArrayList<IASTComment>>();
|
protected final Map<IASTNode, List<IASTComment>> freestandingMap = new HashMap<IASTNode, List<IASTComment>>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a comment to the map with the trailing comments.
|
* Add a comment to the map with the trailing comments.
|
||||||
* @param node The node is the key.
|
* @param node The node is the key.
|
||||||
* @param comment The comment is the value
|
* @param comment The comment is the value
|
||||||
*/
|
*/
|
||||||
public void addTrailingCommentToNode(IASTNode node, IASTComment comment){
|
public void addTrailingCommentToNode(IASTNode node, IASTComment comment) {
|
||||||
ArrayList<IASTComment> comments = trailingMap.get(node);
|
List<IASTComment> comments = trailingMap.get(node);
|
||||||
if(comments == null){
|
if (comments == null) {
|
||||||
comments = new ArrayList<IASTComment>();
|
comments = new ArrayList<IASTComment>();
|
||||||
}
|
}
|
||||||
comments.add(comment);
|
comments.add(comment);
|
||||||
|
@ -44,17 +46,15 @@ public class NodeCommentMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an ArrayList for the given node. This ArrayList contains all the comments
|
* Returns a List for the given node. This List contains all the comments
|
||||||
* which are assigned to this specific node. If no comments are available an empty
|
* which are assigned to this specific node. If no comments are available an empty
|
||||||
* ArrayList is returned.
|
* List is returned.
|
||||||
* @param node The key to fetch the associated comments.
|
* @param node The key to fetch the associated comments.
|
||||||
* @return ArrayList
|
* @return List
|
||||||
*/
|
*/
|
||||||
public ArrayList<IASTComment> getTrailingCommentsForNode(IASTNode node){
|
public List<IASTComment> getTrailingCommentsForNode(IASTNode node) {
|
||||||
if(trailingMap.get(node) == null) {
|
List<IASTComment> list = trailingMap.get(node);
|
||||||
return new ArrayList<IASTComment>();
|
return list != null ? list : new ArrayList<IASTComment>();
|
||||||
}
|
|
||||||
return trailingMap.get(node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,9 +62,9 @@ public class NodeCommentMap {
|
||||||
* @param node The node is the key.
|
* @param node The node is the key.
|
||||||
* @param comment The comment is the value
|
* @param comment The comment is the value
|
||||||
*/
|
*/
|
||||||
public void addLeadingCommentToNode(IASTNode node, IASTComment comment){
|
public void addLeadingCommentToNode(IASTNode node, IASTComment comment) {
|
||||||
ArrayList<IASTComment> comments = leadingMap.get(node);
|
List<IASTComment> comments = leadingMap.get(node);
|
||||||
if(comments == null){
|
if (comments == null) {
|
||||||
comments = new ArrayList<IASTComment>();
|
comments = new ArrayList<IASTComment>();
|
||||||
}
|
}
|
||||||
comments.add(comment);
|
comments.add(comment);
|
||||||
|
@ -72,17 +72,15 @@ public class NodeCommentMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an ArrayList for the given node. This ArrayList contains all the comments
|
* Returns a List for the given node. This List contains all the comments
|
||||||
* which are assigned to this specific node. If no comments are available an empty
|
* which are assigned to this specific node. If no comments are available an empty
|
||||||
* ArrayList is returned.
|
* List is returned.
|
||||||
* @param node The key to fetch the associated comments.
|
* @param node The key to fetch the associated comments.
|
||||||
* @return ArrayList
|
* @return List
|
||||||
*/
|
*/
|
||||||
public ArrayList<IASTComment> getLeadingCommentsForNode(IASTNode node){
|
public List<IASTComment> getLeadingCommentsForNode(IASTNode node) {
|
||||||
if(leadingMap.get(node) == null) {
|
List<IASTComment> list = leadingMap.get(node);
|
||||||
return new ArrayList<IASTComment>();
|
return list != null ? list : new ArrayList<IASTComment>();
|
||||||
}
|
|
||||||
return leadingMap.get(node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,9 +88,9 @@ public class NodeCommentMap {
|
||||||
* @param node The node is the key.
|
* @param node The node is the key.
|
||||||
* @param comment The comment is the value
|
* @param comment The comment is the value
|
||||||
*/
|
*/
|
||||||
public void addFreestandingCommentToNode(IASTNode node, IASTComment comment){
|
public void addFreestandingCommentToNode(IASTNode node, IASTComment comment) {
|
||||||
ArrayList<IASTComment> comments = freestandingMap.get(node);
|
List<IASTComment> comments = freestandingMap.get(node);
|
||||||
if(comments == null){
|
if (comments == null) {
|
||||||
comments = new ArrayList<IASTComment>();
|
comments = new ArrayList<IASTComment>();
|
||||||
}
|
}
|
||||||
comments.add(comment);
|
comments.add(comment);
|
||||||
|
@ -100,51 +98,50 @@ public class NodeCommentMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an ArrayList for the given node. This ArrayList contains all the comments
|
* Returns a List for the given node. This List contains all the comments
|
||||||
* which are assigned to this specific node. If no comments are available an empty
|
* which are assigned to this specific node. If no comments are available an empty
|
||||||
* ArrayList is returned.
|
* List is returned.
|
||||||
* @param node The key to fetch the associated comments.
|
* @param node The key to fetch the associated comments.
|
||||||
* @return ArrayList
|
* @return List
|
||||||
*/
|
*/
|
||||||
public ArrayList<IASTComment> getFreestandingCommentsForNode(IASTNode node){
|
public List<IASTComment> getFreestandingCommentsForNode(IASTNode node) {
|
||||||
if(freestandingMap.get(node) == null) {
|
List<IASTComment> list = freestandingMap.get(node);
|
||||||
return new ArrayList<IASTComment>();
|
return list != null ? list : new ArrayList<IASTComment>();
|
||||||
}
|
}
|
||||||
return freestandingMap.get(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the HashMap with all leading maps. Used only for test purpose
|
* Returns the Map with all leading maps. Used only for test purpose
|
||||||
* @return HashMap of all leading comments
|
* @return Map of all leading comments
|
||||||
*/
|
*/
|
||||||
public HashMap<IASTNode, ArrayList<IASTComment>> getLeadingMap() {
|
public Map<IASTNode, List<IASTComment>> getLeadingMap() {
|
||||||
return leadingMap;
|
return leadingMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the HashMap with all trailing maps. Used only for test purpose
|
* Returns the Map with all trailing maps. Used only for test purpose
|
||||||
* @return HashMap of all trailing comments
|
* @return Map of all trailing comments
|
||||||
*/
|
*/
|
||||||
public HashMap<IASTNode, ArrayList<IASTComment>> getTrailingMap() {
|
public Map<IASTNode, List<IASTComment>> getTrailingMap() {
|
||||||
return trailingMap;
|
return trailingMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the HashMap with all freestanding maps. Used only for test purpose
|
* Returns the Map with all freestanding maps. Used only for test purpose
|
||||||
* @return HashMap of all freestanding comments
|
* @return Map of all freestanding comments
|
||||||
*/
|
*/
|
||||||
public HashMap<IASTNode, ArrayList<IASTComment>> getFreestandingMap() {
|
public Map<IASTNode, List<IASTComment>> getFreestandingMap() {
|
||||||
return freestandingMap;
|
return freestandingMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an ArrayList for the given node. This ArrayList contains all the comments
|
* Returns an List for the given node. This List contains all the comments
|
||||||
* which are assigned to this specific node. If no comments are available an empty
|
* which are assigned to this specific node. If no comments are available an empty
|
||||||
* ArrayList is returned.
|
* List is returned.
|
||||||
* @param node The key to fetch the associated comments.
|
* @param node The key to fetch the associated comments.
|
||||||
* @return ArrayList
|
* @return List
|
||||||
*/
|
*/
|
||||||
public ArrayList<IASTComment> getAllCommentsForNode(IASTNode node) {
|
public List<IASTComment> getAllCommentsForNode(IASTNode node) {
|
||||||
ArrayList<IASTComment> comment = new ArrayList<IASTComment>();
|
List<IASTComment> comment = new ArrayList<IASTComment>();
|
||||||
comment.addAll(getFreestandingCommentsForNode(node));
|
comment.addAll(getFreestandingCommentsForNode(node));
|
||||||
comment.addAll(getLeadingCommentsForNode(node));
|
comment.addAll(getLeadingCommentsForNode(node));
|
||||||
comment.addAll(getTrailingCommentsForNode(node));
|
comment.addAll(getTrailingCommentsForNode(node));
|
||||||
|
|
|
@ -8,19 +8,20 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler;
|
package org.eclipse.cdt.internal.core.dom.rewrite.commenthandler;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
import org.eclipse.cdt.core.dom.ast.IASTComment;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarationStatement;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarationStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExplicitTemplateInstantiation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExplicitTemplateInstantiation;
|
||||||
|
@ -32,32 +33,29 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLinkageSpecification;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSwitchStatement;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSwitchStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateDeclaration;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTWhileStatement;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTWhileStatement;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.util.OffsetHelper;
|
|
||||||
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The NodeCommenter contains all the logic that is needed for the ASTCommentVisitor to assign the comments
|
* The NodeCommenter contains all the logic that is needed for the ASTCommentVisitor to assign
|
||||||
* to the suitable node. Together with the ASTCommenterVisitor it fills all the comments with the correspondent
|
* the comments to the suitable node. Together with the ASTCommenterVisitor it fills all
|
||||||
* node into the NodeCommentMap.
|
* the comments with the correspondent node into the NodeCommentMap.
|
||||||
*
|
*
|
||||||
* Following, a little explanation of the assignment logic. It is only a loose illustration a detailed description
|
* Following, a little explanation of the assignment logic. It is only a loose illustration
|
||||||
* would include a combined explanation of ASTCommenterVisitor and NodeCommenter.<br>
|
* a detailed description would include a combined explanation of ASTCommenterVisitor and
|
||||||
|
* NodeCommenter.<br>
|
||||||
* To understand the logic we define the three types of comments:<br>
|
* To understand the logic we define the three types of comments:<br>
|
||||||
* leading comments - Comments before a statement, declaration, or definition.<br>
|
* leading comments - Comments before a statement, declaration, or definition.<br>
|
||||||
* trailing comments - Comments right after the AST node on the same line.<br>
|
* trailing comments - Comments right after the AST node on the same line.<br>
|
||||||
* freestanding comments - Comments before a closing brace such as they occur in
|
* freestanding comments - Comments before a closing brace such as they occur in
|
||||||
* namespace-, class- and method-definitions or at the end of a file.<br>
|
* namespace-, class- and method-definitions or at the end of a file.<br>
|
||||||
*
|
*
|
||||||
* The first comment is fetched and the position of it is compared to the position of the actual node. If
|
* The first comment is fetched and the position of it is compared to the position of the actual
|
||||||
* the position of the comment is smaller than the comment is added to the node as leading. If it is behind the node
|
* node. If the position of the comment is smaller than the comment is added to the node as leading.
|
||||||
* but on the same line it is added as trailing. If one of these possibilities match the next comment is fetched for
|
* If it is behind the node but on the same line it is added as trailing. If one of these
|
||||||
* the same check. If it doesn't match the same procedure is done for all the child nodes. After checking the sub nodes
|
* possibilities match the next comment is fetched for the same check. If it doesn't match the same
|
||||||
* the actual node is checked again if the comment is trailing. Then there is also the possibility that this comment is
|
* procedure is done for all the child nodes. After checking the sub nodes the actual node is
|
||||||
* freestanding. This is the case when the comment is not added to any child node but the position is smaller den
|
* checked again if the comment is trailing. Then there is also the possibility that this comment is
|
||||||
* the end position of the node.
|
* freestanding. This is the case when the comment is not added to any child node but the position
|
||||||
|
* is smaller than the end position of the node.
|
||||||
*
|
*
|
||||||
* @author Guido Zgraggen IFS
|
* @author Guido Zgraggen IFS
|
||||||
*/
|
*/
|
||||||
|
@ -90,14 +88,14 @@ public class NodeCommenter {
|
||||||
ASTNode com = (ASTNode) comment;
|
ASTNode com = (ASTNode) comment;
|
||||||
|
|
||||||
if (node.getFileLocation() == null) {
|
if (node.getFileLocation() == null) {
|
||||||
//MacroExpansions have no FileLocation
|
// MacroExpansions have no FileLocation
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nodeLineNumber = OffsetHelper.getEndingLineNumber(node);
|
int nodeLineNumber = getEndingLineNumber(node);
|
||||||
int commentLineNumber= OffsetHelper.getStartingLineNumber(comment);
|
int commentLineNumber= getStartingLineNumber(comment);
|
||||||
|
|
||||||
if (OffsetHelper.getNodeEndPoint(com) <= OffsetHelper.getNodeOffset(node)) {
|
if (getNodeEndPoint(com) <= getNodeOffset(node)) {
|
||||||
addLeadingCommentToMap(node, comment);
|
addLeadingCommentToMap(node, comment);
|
||||||
return true;
|
return true;
|
||||||
} else if (isTrailing(node, com, nodeLineNumber, commentLineNumber)) {
|
} else if (isTrailing(node, com, nodeLineNumber, commentLineNumber)) {
|
||||||
|
@ -111,10 +109,10 @@ public class NodeCommenter {
|
||||||
ASTNode com = (ASTNode) comment;
|
ASTNode com = (ASTNode) comment;
|
||||||
|
|
||||||
if (node.getFileLocation() == null) {
|
if (node.getFileLocation() == null) {
|
||||||
//MacroExpansions have no Filelocation
|
// MacroExpansions have no FileLocation
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (OffsetHelper.getNodeEndPoint(com) <= OffsetHelper.getNodeEndPoint(node)) {
|
if (getNodeEndPoint(com) <= getNodeEndPoint(node)) {
|
||||||
addFreestandingCommentToMap(node, comment);
|
addFreestandingCommentToMap(node, comment);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -137,47 +135,23 @@ public class NodeCommenter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTrailing(ASTNode node, ASTNode com, int nodeLineNumber, int commentLineNumber) {
|
private boolean isTrailing(ASTNode node, ASTNode com, int nodeLineNumber, int commentLineNumber) {
|
||||||
if (nodeLineNumber == commentLineNumber
|
if (nodeLineNumber != commentLineNumber ||
|
||||||
&& OffsetHelper.getNodeOffset(com) >= OffsetHelper.getNodeEndPoint(node)
|
getNodeOffset(com) < getNodeEndPoint(node) ||
|
||||||
&& canNotBeAddedToParent(node,com)
|
!canNotBeAddedToParent(node, com) ||
|
||||||
&& !mustBeAddToSubnodes(node)) {
|
mustBeAddedToSubnodes(node)) {
|
||||||
if (OffsetHelper.getNodeOffset(com) < OffsetHelper.getNodeEndPoint(node) + 2) {
|
return false;
|
||||||
|
}
|
||||||
|
if (getNodeOffset(com) < getNodeEndPoint(node) + 2) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
IPath path = new Path(node.getContainingFilename());
|
String code = node.getTranslationUnit().getRawSignature();
|
||||||
IFile file = ResourceLookup.selectFileForLocation(path, null); // NPE thrown below, like original behavior
|
int commentOffset = getNodeOffset(com) - getNodeEndPoint(node) + getNodeEndOffset(node);
|
||||||
|
for (int offset = getNodeEndOffset(node); offset < commentOffset; offset++) {
|
||||||
//XXX HSR Guido: Possible Performance Issue (File access)
|
if (!Character.isWhitespace(code.charAt(offset)))
|
||||||
try {
|
|
||||||
InputStream is = file.getContents();
|
|
||||||
|
|
||||||
int length = OffsetHelper.getNodeOffset(com)-OffsetHelper.getNodeEndPoint(node);
|
|
||||||
byte[] b = new byte[length];
|
|
||||||
|
|
||||||
long count = is.skip(OffsetHelper.getEndOffsetWithoutComments(node));
|
|
||||||
if (count < OffsetHelper.getEndOffsetWithoutComments(node)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (is.read(b, 0, length) == -1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (byte bb : b) {
|
|
||||||
if (!Character.isWhitespace(bb)) {
|
|
||||||
is.close();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
is.close();
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean canNotBeAddedToParent(ASTNode node, ASTNode com) {
|
private boolean canNotBeAddedToParent(ASTNode node, ASTNode com) {
|
||||||
ASTNode parent = (ASTNode) node.getParent();
|
ASTNode parent = (ASTNode) node.getParent();
|
||||||
|
|
||||||
|
@ -192,10 +166,10 @@ public class NodeCommenter {
|
||||||
} else if (parent instanceof ICPPASTBaseSpecifier) {
|
} else if (parent instanceof ICPPASTBaseSpecifier) {
|
||||||
parent = (ASTNode) parent.getParent();
|
parent = (ASTNode) parent.getParent();
|
||||||
}
|
}
|
||||||
return !(OffsetHelper.getNodeOffset(com) >= OffsetHelper.getNodeEndPoint(parent));
|
return getNodeOffset(com) < getNodeEndPoint(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mustBeAddToSubnodes(ASTNode node) {
|
private boolean mustBeAddedToSubnodes(ASTNode node) {
|
||||||
return hasNodeSameEndingAsSubnode(node);
|
return hasNodeSameEndingAsSubnode(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,4 +248,25 @@ public class NodeCommenter {
|
||||||
}
|
}
|
||||||
return !node.getFileLocation().getFileName().equals(comment.getFileLocation().getFileName());
|
return !node.getFileLocation().getFileName().equals(comment.getFileLocation().getFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getNodeEndOffset(IASTNode node) {
|
||||||
|
IASTFileLocation fileLocation = node.getFileLocation();
|
||||||
|
return fileLocation.getNodeOffset() + fileLocation.getNodeLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getNodeOffset(ASTNode node) {
|
||||||
|
return node.getOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getNodeEndPoint(ASTNode node) {
|
||||||
|
return node.getOffset() + node.getLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getStartingLineNumber(IASTNode node) {
|
||||||
|
return node.getFileLocation().getStartingLineNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getEndingLineNumber(IASTNode node) {
|
||||||
|
return node.getFileLocation().getEndingLineNumber();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
|
|
||||||
* Rapperswil, University of applied sciences and others
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* Institute for Software - initial API and implementation
|
|
||||||
******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.util;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Emanuel Graf IFS
|
|
||||||
*/
|
|
||||||
public class FileContentHelper {
|
|
||||||
private static final int BUFFER_SIZE = 2048;
|
|
||||||
|
|
||||||
public static String getContent(IFile file, int start) throws CoreException, IOException {
|
|
||||||
InputStreamReader reader = getReaderForFile(file);
|
|
||||||
skip(start, reader);
|
|
||||||
|
|
||||||
final String rest = readRest(reader);
|
|
||||||
reader.close();
|
|
||||||
return rest;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getContent(IFile file, int start, int length) {
|
|
||||||
try {
|
|
||||||
InputStreamReader r = getReaderForFile(file);
|
|
||||||
char[] chars = new char[length];
|
|
||||||
|
|
||||||
skip(start, r);
|
|
||||||
|
|
||||||
read(length, r, chars);
|
|
||||||
r.close();
|
|
||||||
return new String(chars);
|
|
||||||
} catch (IOException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
return ""; //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
private static InputStreamReader getReaderForFile(IFile file)
|
|
||||||
throws CoreException, UnsupportedEncodingException {
|
|
||||||
InputStream contents = file.getContents();
|
|
||||||
return new InputStreamReader(contents, file.getCharset());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String readRest(InputStreamReader reader) throws IOException {
|
|
||||||
StringBuilder content = new StringBuilder();
|
|
||||||
char[] buffer = new char[BUFFER_SIZE];
|
|
||||||
int bytesRead = 0;
|
|
||||||
while ((bytesRead = reader.read(buffer)) >= 0) {
|
|
||||||
content.append(buffer, 0, bytesRead);
|
|
||||||
}
|
|
||||||
|
|
||||||
return content.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void read(int length, InputStreamReader r, char[] bytes) throws IOException {
|
|
||||||
int bufferOffset = 0;
|
|
||||||
int charactersRead = 0;
|
|
||||||
while (charactersRead >= 0 && length > 0) {
|
|
||||||
charactersRead = r.read(bytes, bufferOffset, length);
|
|
||||||
if (charactersRead > 0) {
|
|
||||||
bufferOffset += charactersRead;
|
|
||||||
length -= charactersRead;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void skip(int start, InputStreamReader r) throws IOException {
|
|
||||||
long skipped = 0;
|
|
||||||
while (skipped >= 0 && start > 0 && r.ready()) {
|
|
||||||
skipped = r.skip(start);
|
|
||||||
if (skipped > 0) {
|
|
||||||
start -= skipped;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,21 +11,12 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.util;
|
package org.eclipse.cdt.internal.core.dom.rewrite.util;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.ProjectScope;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
|
||||||
import org.eclipse.jface.text.TextUtilities;
|
import org.eclipse.jface.text.TextUtilities;
|
||||||
|
|
||||||
public class FileHelper {
|
public class FileHelper {
|
||||||
|
@ -36,36 +27,13 @@ public class FileHelper {
|
||||||
return ResourceLookup.selectFileForLocation(implPath, null);
|
return ResourceLookup.selectFileForLocation(implPath, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFirstWithinSecondLocation(IASTFileLocation loc1, IASTFileLocation loc2) {
|
public static String determineLineDelimiter(String text) {
|
||||||
boolean isEquals = true;
|
|
||||||
|
|
||||||
isEquals &= loc1.getFileName().equals(loc2.getFileName());
|
|
||||||
isEquals &= loc1.getNodeOffset() >= loc2.getNodeOffset();
|
|
||||||
isEquals &= loc1.getNodeOffset() + loc1.getNodeLength() <= loc2.getNodeOffset()
|
|
||||||
+ loc2.getNodeLength();
|
|
||||||
|
|
||||||
return isEquals;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String determineLineDelimiter(IFile file) {
|
|
||||||
String fileContent = ""; //$NON-NLS-1$
|
|
||||||
|
|
||||||
try {
|
|
||||||
fileContent = FileContentHelper.getContent(file, 0);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject();
|
|
||||||
IScopeContext[] scopeContext;
|
|
||||||
if (project != null) {
|
|
||||||
scopeContext = new IScopeContext[] { new ProjectScope(project) };
|
|
||||||
} else {
|
|
||||||
scopeContext = new IScopeContext[] { InstanceScope.INSTANCE };
|
|
||||||
}
|
|
||||||
String platformDefaultLineDelimiter = System.getProperty("line.separator", DEFAULT_LINE_DELIMITTER); //$NON-NLS-1$
|
String platformDefaultLineDelimiter = System.getProperty("line.separator", DEFAULT_LINE_DELIMITTER); //$NON-NLS-1$
|
||||||
String defaultLineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME,
|
String defaultLineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME,
|
||||||
Platform.PREF_LINE_SEPARATOR, platformDefaultLineDelimiter, scopeContext);
|
Platform.PREF_LINE_SEPARATOR, platformDefaultLineDelimiter, null);
|
||||||
return TextUtilities.determineLineDelimiter(fileContent.toString(), defaultLineDelimiter);
|
if (text.isEmpty()) {
|
||||||
|
return defaultLineDelimiter;
|
||||||
|
}
|
||||||
|
return TextUtilities.determineLineDelimiter(text, defaultLineDelimiter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
|
|
||||||
* Rapperswil, University of applied sciences and others
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* Institute for Software - initial API and implementation
|
|
||||||
******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.util;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Emanuel Graf IFS
|
|
||||||
*/
|
|
||||||
public class OffsetHelper {
|
|
||||||
|
|
||||||
public static int getOffsetIncludingComment(IASTNode node) {
|
|
||||||
int nodeStart = Integer.MAX_VALUE;
|
|
||||||
IASTNodeLocation[] nodeLocations = node.getNodeLocations();
|
|
||||||
if (nodeLocations.length != 1) {
|
|
||||||
int offset;
|
|
||||||
for (IASTNodeLocation location : nodeLocations) {
|
|
||||||
if (location instanceof IASTMacroExpansionLocation) {
|
|
||||||
IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) location;
|
|
||||||
offset = macroLoc.asFileLocation().getNodeOffset();
|
|
||||||
} else {
|
|
||||||
offset = location.asFileLocation().getNodeOffset();
|
|
||||||
}
|
|
||||||
if (offset < nodeStart)
|
|
||||||
nodeStart = offset;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
nodeStart = node.getFileLocation().getNodeOffset();
|
|
||||||
}
|
|
||||||
|
|
||||||
return nodeStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getEndOffsetIncludingComments(IASTNode node) {
|
|
||||||
int fileOffset = 0;
|
|
||||||
int length = 0;
|
|
||||||
|
|
||||||
IASTNodeLocation[] nodeLocations = node.getNodeLocations();
|
|
||||||
if (nodeLocations.length != 1) {
|
|
||||||
for (IASTNodeLocation location : nodeLocations) {
|
|
||||||
if (location instanceof IASTMacroExpansionLocation) {
|
|
||||||
IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) location;
|
|
||||||
fileOffset = macroLoc.asFileLocation().getNodeOffset();
|
|
||||||
length = macroLoc.asFileLocation().getNodeLength();
|
|
||||||
} else {
|
|
||||||
fileOffset = location.asFileLocation().getNodeOffset();
|
|
||||||
length = location.asFileLocation().getNodeLength();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
IASTFileLocation loc = node.getFileLocation();
|
|
||||||
fileOffset = loc.getNodeOffset();
|
|
||||||
length = loc.getNodeLength();
|
|
||||||
}
|
|
||||||
return fileOffset + length;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getEndOffsetWithoutComments(IASTNode node) {
|
|
||||||
return node.getFileLocation().getNodeOffset() + node.getFileLocation().getNodeLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getLengthIncludingComment(IASTNode node) {
|
|
||||||
return getEndOffsetIncludingComments(node) - getOffsetIncludingComment(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getNodeOffset(ASTNode node) {
|
|
||||||
return node.getOffset();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getNodeEndPoint(ASTNode node) {
|
|
||||||
return node.getOffset() + node.getLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getStartingLineNumber(IASTNode node) {
|
|
||||||
return node.getFileLocation().getStartingLineNumber();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getEndingLineNumber(IASTNode node) {
|
|
||||||
return node.getFileLocation().getEndingLineNumber();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -68,6 +68,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
fLexerOptions= lexOptions;
|
fLexerOptions= lexOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LexerOptions getLexerOptions() {
|
public LexerOptions getLexerOptions() {
|
||||||
return fLexerOptions;
|
return fLexerOptions;
|
||||||
}
|
}
|
||||||
|
@ -382,6 +383,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
addMacroReference(undef.getMacroName());
|
addMacroReference(undef.getMacroName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setRootNode(IASTTranslationUnit root) {
|
public void setRootNode(IASTTranslationUnit root) {
|
||||||
fTranslationUnit= root;
|
fTranslationUnit= root;
|
||||||
if (fTranslationUnit instanceof ISkippedIndexedFilesListener) {
|
if (fTranslationUnit instanceof ISkippedIndexedFilesListener) {
|
||||||
|
@ -389,6 +391,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getTranslationUnitPath() {
|
public String getTranslationUnitPath() {
|
||||||
return fTranslationUnitPath;
|
return fTranslationUnitPath;
|
||||||
}
|
}
|
||||||
|
@ -418,11 +421,13 @@ public class LocationMap implements ILocationResolver {
|
||||||
return fCurrentContext.getSequenceNumberForOffset(offset, offset < fLastChildInsertionOffset);
|
return fCurrentContext.getSequenceNumberForOffset(offset, offset < fLastChildInsertionOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getContainingFilePath(int sequenceNumber) {
|
public String getContainingFilePath(int sequenceNumber) {
|
||||||
LocationCtx ctx= fRootContext.findSurroundingContext(sequenceNumber, 1);
|
LocationCtx ctx= fRootContext.findSurroundingContext(sequenceNumber, 1);
|
||||||
return new String(ctx.getFilePath());
|
return new String(ctx.getFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPartOfSourceFile(int sequenceNumber) {
|
public boolean isPartOfSourceFile(int sequenceNumber) {
|
||||||
LocationCtx ctx= fRootContext.findSurroundingContext(sequenceNumber, 1);
|
LocationCtx ctx= fRootContext.findSurroundingContext(sequenceNumber, 1);
|
||||||
if (ctx == fRootContext && fTranslationUnit != null)
|
if (ctx == fRootContext && fTranslationUnit != null)
|
||||||
|
@ -431,14 +436,17 @@ public class LocationMap implements ILocationResolver {
|
||||||
return ctx.isSourceFile();
|
return ctx.isSourceFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ASTFileLocation getMappedFileLocation(int sequenceNumber, int length) {
|
public ASTFileLocation getMappedFileLocation(int sequenceNumber, int length) {
|
||||||
return fRootContext.findMappedFileLocation(sequenceNumber, length);
|
return fRootContext.findMappedFileLocation(sequenceNumber, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int convertToSequenceEndNumber(int sequenceNumber) {
|
public int convertToSequenceEndNumber(int sequenceNumber) {
|
||||||
return fRootContext.convertToSequenceEndNumber(sequenceNumber);
|
return fRootContext.convertToSequenceEndNumber(sequenceNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public char[] getUnpreprocessedSignature(IASTFileLocation loc) {
|
public char[] getUnpreprocessedSignature(IASTFileLocation loc) {
|
||||||
ASTFileLocation floc= convertFileLocation(loc);
|
ASTFileLocation floc= convertFileLocation(loc);
|
||||||
if (floc == null) {
|
if (floc == null) {
|
||||||
|
@ -447,6 +455,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
return floc.getSource();
|
return floc.getSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTPreprocessorMacroExpansion[] getMacroExpansions(IASTFileLocation loc) {
|
public IASTPreprocessorMacroExpansion[] getMacroExpansions(IASTFileLocation loc) {
|
||||||
ASTFileLocation floc= convertFileLocation(loc);
|
ASTFileLocation floc= convertFileLocation(loc);
|
||||||
if (floc == null) {
|
if (floc == null) {
|
||||||
|
@ -485,17 +494,19 @@ public class LocationMap implements ILocationResolver {
|
||||||
return getMappedFileLocation(sequenceNumber, length);
|
return getMappedFileLocation(sequenceNumber, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNodeLocation[] getLocations(int sequenceNumber, int length) {
|
public IASTNodeLocation[] getLocations(int sequenceNumber, int length) {
|
||||||
ArrayList<IASTNodeLocation> result= new ArrayList<IASTNodeLocation>();
|
ArrayList<IASTNodeLocation> result= new ArrayList<IASTNodeLocation>();
|
||||||
fRootContext.collectLocations(sequenceNumber, length, result);
|
fRootContext.collectLocations(sequenceNumber, length, result);
|
||||||
return result.toArray(new IASTNodeLocation[result.size()]);
|
return result.toArray(new IASTNodeLocation[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPartOfTranslationUnitFile(int sequenceNumber) {
|
public boolean isPartOfTranslationUnitFile(int sequenceNumber) {
|
||||||
return fRootContext.isThisFile(sequenceNumber);
|
return fRootContext.isThisFile(sequenceNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTImageLocation getImageLocation(int sequenceNumber, int length) {
|
public IASTImageLocation getImageLocation(int sequenceNumber, int length) {
|
||||||
ArrayList<IASTNodeLocation> result= new ArrayList<IASTNodeLocation>();
|
ArrayList<IASTNodeLocation> result= new ArrayList<IASTNodeLocation>();
|
||||||
fRootContext.collectLocations(sequenceNumber, length, result);
|
fRootContext.collectLocations(sequenceNumber, length, result);
|
||||||
|
@ -515,6 +526,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void findPreprocessorNode(ASTNodeSpecification<?> nodeSpec) {
|
public void findPreprocessorNode(ASTNodeSpecification<?> nodeSpec) {
|
||||||
final int sequenceStart= nodeSpec.getSequenceStart();
|
final int sequenceStart= nodeSpec.getSequenceStart();
|
||||||
final int sequenceEnd= nodeSpec.getSequenceEnd();
|
final int sequenceEnd= nodeSpec.getSequenceEnd();
|
||||||
|
@ -600,6 +612,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
return lower;
|
return lower;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getSequenceNumberForFileOffset(String filePath, int fileOffset) {
|
public int getSequenceNumberForFileOffset(String filePath, int fileOffset) {
|
||||||
LocationCtx ctx= fRootContext;
|
LocationCtx ctx= fRootContext;
|
||||||
if (filePath != null) {
|
if (filePath != null) {
|
||||||
|
@ -624,6 +637,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTFileLocation flattenLocations(IASTNodeLocation[] locations) {
|
public IASTFileLocation flattenLocations(IASTNodeLocation[] locations) {
|
||||||
if (locations.length == 0) {
|
if (locations.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -643,7 +657,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTPreprocessorMacroDefinition[] getMacroDefinitions() {
|
public IASTPreprocessorMacroDefinition[] getMacroDefinitions() {
|
||||||
ArrayList<Object> result= new ArrayList<Object>();
|
ArrayList<Object> result= new ArrayList<Object>();
|
||||||
for (Iterator<ASTPreprocessorNode> iterator = fDirectives.iterator(); iterator.hasNext();) {
|
for (Iterator<ASTPreprocessorNode> iterator = fDirectives.iterator(); iterator.hasNext();) {
|
||||||
|
@ -655,6 +669,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
return result.toArray(new IASTPreprocessorMacroDefinition[result.size()]);
|
return result.toArray(new IASTPreprocessorMacroDefinition[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTPreprocessorIncludeStatement[] getIncludeDirectives() {
|
public IASTPreprocessorIncludeStatement[] getIncludeDirectives() {
|
||||||
ArrayList<Object> result= new ArrayList<Object>();
|
ArrayList<Object> result= new ArrayList<Object>();
|
||||||
for (Iterator<ASTPreprocessorNode> iterator = fDirectives.iterator(); iterator.hasNext();) {
|
for (Iterator<ASTPreprocessorNode> iterator = fDirectives.iterator(); iterator.hasNext();) {
|
||||||
|
@ -666,26 +681,32 @@ public class LocationMap implements ILocationResolver {
|
||||||
return result.toArray(new IASTPreprocessorIncludeStatement[result.size()]);
|
return result.toArray(new IASTPreprocessorIncludeStatement[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTComment[] getComments() {
|
public IASTComment[] getComments() {
|
||||||
return fComments.toArray(new IASTComment[fComments.size()]);
|
return fComments.toArray(new IASTComment[fComments.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTPreprocessorStatement[] getAllPreprocessorStatements() {
|
public IASTPreprocessorStatement[] getAllPreprocessorStatements() {
|
||||||
return fDirectives.toArray(new IASTPreprocessorStatement[fDirectives.size()]);
|
return fDirectives.toArray(new IASTPreprocessorStatement[fDirectives.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() {
|
public IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() {
|
||||||
return fBuiltinMacros.toArray(new IASTPreprocessorMacroDefinition[fBuiltinMacros.size()]);
|
return fBuiltinMacros.toArray(new IASTPreprocessorMacroDefinition[fBuiltinMacros.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTProblem[] getScannerProblems() {
|
public IASTProblem[] getScannerProblems() {
|
||||||
return fProblems.toArray(new IASTProblem[fProblems.size()]);
|
return fProblems.toArray(new IASTProblem[fProblems.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getScannerProblemsCount() {
|
public int getScannerProblemsCount() {
|
||||||
return fProblems.size();
|
return fProblems.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTName[] getDeclarations(IMacroBinding binding) {
|
public IASTName[] getDeclarations(IMacroBinding binding) {
|
||||||
IASTPreprocessorMacroDefinition def = getMacroDefinition(binding);
|
IASTPreprocessorMacroDefinition def = getMacroDefinition(binding);
|
||||||
return def == null ? IASTName.EMPTY_NAME_ARRAY: new IASTName[] { def.getName() };
|
return def == null ? IASTName.EMPTY_NAME_ARRAY: new IASTName[] { def.getName() };
|
||||||
|
@ -712,6 +733,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
return fMacroDefinitionMap.get(binding);
|
return fMacroDefinitionMap.get(binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTName[] getReferences(IMacroBinding binding) {
|
public IASTName[] getReferences(IMacroBinding binding) {
|
||||||
List<IASTName> result= new ArrayList<IASTName>();
|
List<IASTName> result= new ArrayList<IASTName>();
|
||||||
for (IASTName name : fMacroReferences) {
|
for (IASTName name : fMacroReferences) {
|
||||||
|
@ -737,6 +759,7 @@ public class LocationMap implements ILocationResolver {
|
||||||
return result.toArray(new ASTPreprocessorName[result.size()]);
|
return result.toArray(new ASTPreprocessorName[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IDependencyTree getDependencyTree() {
|
public IDependencyTree getDependencyTree() {
|
||||||
return new DependencyTree(fRootContext);
|
return new DependencyTree(fRootContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -525,26 +525,41 @@
|
||||||
</content-type>
|
</content-type>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<!-- the reserved filenames by the C++ standard -->
|
<!-- The reserved filenames by the C++ standard (cinttypes is G++ specific) -->
|
||||||
<extension point="org.eclipse.core.contenttype.contentTypes">
|
<extension point="org.eclipse.core.contenttype.contentTypes">
|
||||||
<file-association
|
<file-association
|
||||||
content-type="org.eclipse.cdt.core.cxxHeader"
|
content-type="org.eclipse.cdt.core.cxxHeader"
|
||||||
file-names="algorithm,bitset,cassert,cctype,cerrno,cfloat,ciso646,climits,clocale,cmath,complex,csetjmp,csignal"/>
|
file-names="algorithm,array,atomic,bitset,cassert,ccomplex,cctype,cerrno,cfenv,cfloat,chrono,cinttypes"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension point="org.eclipse.core.contenttype.contentTypes">
|
<extension point="org.eclipse.core.contenttype.contentTypes">
|
||||||
<file-association
|
<file-association
|
||||||
content-type="org.eclipse.cdt.core.cxxHeader"
|
content-type="org.eclipse.cdt.core.cxxHeader"
|
||||||
file-names="cstdarg,cstddef,cstdio,cstdlib,cstring,ctime,cwchar,cwctype,deque,exception,fstream,functional"/>
|
file-names="ciso646,climits,clocale,cmath,codecvt,complex,csetjmp,csignal,cstdarg,cstdbool,cstddef"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension point="org.eclipse.core.contenttype.contentTypes">
|
<extension point="org.eclipse.core.contenttype.contentTypes">
|
||||||
<file-association
|
<file-association
|
||||||
content-type="org.eclipse.cdt.core.cxxHeader"
|
content-type="org.eclipse.cdt.core.cxxHeader"
|
||||||
file-names="hash_map,hash_set,iomanip,ios,iosfwd,iostream,istream,iterator,limits,list,locale,map,memory"/>
|
file-names="cstdint,cstdio,cstdlib,cstring,ctime,cwchar,cwctype,deque,exception,forward_list,fstream"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension point="org.eclipse.core.contenttype.contentTypes">
|
<extension point="org.eclipse.core.contenttype.contentTypes">
|
||||||
<file-association
|
<file-association
|
||||||
content-type="org.eclipse.cdt.core.cxxHeader"
|
content-type="org.eclipse.cdt.core.cxxHeader"
|
||||||
file-names="new,numeric,ostream,queue,set,sstream,stack,stdexcept,streambuf,string,strstream,typeinfo,utility,valarray,vector"/>
|
file-names="functional,future,hash_map,hash_set,initializer_list,iomanip,ios,iosfwd,iostream,istream"/>
|
||||||
|
</extension>
|
||||||
|
<extension point="org.eclipse.core.contenttype.contentTypes">
|
||||||
|
<file-association
|
||||||
|
content-type="org.eclipse.cdt.core.cxxHeader"
|
||||||
|
file-names="iterator,limits,list,locale,map,memory,mutex,new,numeric,ostream,queue,random,ratio,regex"/>
|
||||||
|
</extension>
|
||||||
|
<extension point="org.eclipse.core.contenttype.contentTypes">
|
||||||
|
<file-association
|
||||||
|
content-type="org.eclipse.cdt.core.cxxHeader"
|
||||||
|
file-names="set,sstream,stack,stdexcept,streambuf,string,strstream,system_error,thread,tuple"/>
|
||||||
|
</extension>
|
||||||
|
<extension point="org.eclipse.core.contenttype.contentTypes">
|
||||||
|
<file-association
|
||||||
|
content-type="org.eclipse.cdt.core.cxxHeader"
|
||||||
|
file-names="typeindex,typeinfo,type_traits,unordered_map,unordered_set,utility,valarray,vector"/>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core;
|
package org.eclipse.cdt.core;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -49,19 +48,19 @@ public class ToolFactory {
|
||||||
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, extID);
|
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, extID);
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
IExtension[] extensions = extension.getExtensions();
|
IExtension[] extensions = extension.getExtensions();
|
||||||
for(int i = 0; i < extensions.length; i++){
|
for (int i = 0; i < extensions.length; i++){
|
||||||
IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
|
IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
|
||||||
for(int j = 0; j < configElements.length; j++){
|
for (int j = 0; j < configElements.length; j++){
|
||||||
String initializerID = configElements[j].getAttribute("id"); //$NON-NLS-1$
|
String initializerID = configElements[j].getAttribute("id"); //$NON-NLS-1$
|
||||||
if (initializerID != null && initializerID.equals(formatterID)){
|
if (initializerID != null && initializerID.equals(formatterID)){
|
||||||
try {
|
try {
|
||||||
Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
|
Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
|
||||||
if (execExt instanceof CodeFormatter){
|
if (execExt instanceof CodeFormatter){
|
||||||
CodeFormatter formatter = (CodeFormatter)execExt;
|
CodeFormatter formatter = (CodeFormatter) execExt;
|
||||||
formatter.setOptions(options);
|
formatter.setOptions(options);
|
||||||
return formatter;
|
return formatter;
|
||||||
}
|
}
|
||||||
} catch(CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e.getStatus());
|
CCorePlugin.log(e.getStatus());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -530,6 +530,7 @@ public class DefaultCodeFormatterConstants {
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
public final static String FORMATTER_COMMENT_MIN_DISTANCE_BETWEEN_CODE_AND_LINE_COMMENT = CCorePlugin.PLUGIN_ID + ".formatter.comment.min_distance_between_code_and_line_comment"; //$NON-NLS-1$
|
public final static String FORMATTER_COMMENT_MIN_DISTANCE_BETWEEN_CODE_AND_LINE_COMMENT = CCorePlugin.PLUGIN_ID + ".formatter.comment.min_distance_between_code_and_line_comment"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* FORMATTER / Option to control whether the white space between code and line comments should be preserved or replaced with a single space
|
* FORMATTER / Option to control whether the white space between code and line comments should be preserved or replaced with a single space
|
||||||
|
@ -541,9 +542,21 @@ public class DefaultCodeFormatterConstants {
|
||||||
* @see #FALSE
|
* @see #FALSE
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public final static String FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT = CCorePlugin.PLUGIN_ID + ".formatter.comment.preserve_white_space_between_code_and_line_comments"; //$NON-NLS-1$
|
public final static String FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT = CCorePlugin.PLUGIN_ID + ".formatter.comment.preserve_white_space_between_code_and_line_comments"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* FORMATTER / Option to control whether comments starting from the beginning of line should stay that way and never be indented.
|
||||||
|
* - option id: "org.eclipse.cdt.core.formatter.comment.never_indent_line_comments_on_first_column"
|
||||||
|
* - possible values: { TRUE, FALSE }
|
||||||
|
* - default: TRUE
|
||||||
|
* </pre>
|
||||||
|
* @see #TRUE
|
||||||
|
* @see #FALSE
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public final static String FORMATTER_COMMENT_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN = CCorePlugin.PLUGIN_ID + ".formatter.comment.never_indent_line_comments_on_first_column"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* FORMATTER / Option to compact else/if
|
* FORMATTER / Option to compact else/if
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class DefaultCodeFormatterOptions {
|
||||||
// public int comment_line_length;
|
// public int comment_line_length;
|
||||||
public int comment_min_distance_between_code_and_line_comment;
|
public int comment_min_distance_between_code_and_line_comment;
|
||||||
public boolean comment_preserve_white_space_between_code_and_line_comment;
|
public boolean comment_preserve_white_space_between_code_and_line_comment;
|
||||||
public boolean never_indent_line_comments_on_first_column = true;
|
public boolean never_indent_line_comments_on_first_column;
|
||||||
|
|
||||||
public int continuation_indentation;
|
public int continuation_indentation;
|
||||||
public int continuation_indentation_for_initializer_list;
|
public int continuation_indentation_for_initializer_list;
|
||||||
|
@ -314,6 +314,7 @@ public class DefaultCodeFormatterOptions {
|
||||||
// options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, Integer.toString(this.comment_line_length));
|
// options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, Integer.toString(this.comment_line_length));
|
||||||
options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_MIN_DISTANCE_BETWEEN_CODE_AND_LINE_COMMENT, Integer.toString(this.comment_min_distance_between_code_and_line_comment));
|
options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_MIN_DISTANCE_BETWEEN_CODE_AND_LINE_COMMENT, Integer.toString(this.comment_min_distance_between_code_and_line_comment));
|
||||||
options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, this.comment_preserve_white_space_between_code_and_line_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
|
options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, this.comment_preserve_white_space_between_code_and_line_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
|
||||||
|
options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, this.never_indent_line_comments_on_first_column ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
|
||||||
options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, Integer.toString(this.continuation_indentation));
|
options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, Integer.toString(this.continuation_indentation));
|
||||||
options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_INITIALIZER_LIST, Integer.toString(this.continuation_indentation_for_initializer_list));
|
options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_INITIALIZER_LIST, Integer.toString(this.continuation_indentation_for_initializer_list));
|
||||||
options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, this.indent_statements_compare_to_block ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
|
options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, this.indent_statements_compare_to_block ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
|
||||||
|
@ -847,6 +848,10 @@ public class DefaultCodeFormatterOptions {
|
||||||
if (commentPreserveWhiteSpaceBetweenCodeAndLineCommentOption != null) {
|
if (commentPreserveWhiteSpaceBetweenCodeAndLineCommentOption != null) {
|
||||||
this.comment_preserve_white_space_between_code_and_line_comment = DefaultCodeFormatterConstants.TRUE.equals(commentPreserveWhiteSpaceBetweenCodeAndLineCommentOption);
|
this.comment_preserve_white_space_between_code_and_line_comment = DefaultCodeFormatterConstants.TRUE.equals(commentPreserveWhiteSpaceBetweenCodeAndLineCommentOption);
|
||||||
}
|
}
|
||||||
|
final Object neverIndentLineCommentsOnFirstColumn = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN);
|
||||||
|
if (neverIndentLineCommentsOnFirstColumn != null) {
|
||||||
|
this.never_indent_line_comments_on_first_column = DefaultCodeFormatterConstants.TRUE.equals(neverIndentLineCommentsOnFirstColumn);
|
||||||
|
}
|
||||||
final Object continuationIndentationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
|
final Object continuationIndentationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
|
||||||
if (continuationIndentationOption != null) {
|
if (continuationIndentationOption != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -1525,7 +1530,8 @@ public class DefaultCodeFormatterOptions {
|
||||||
this.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE;
|
this.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE;
|
||||||
this.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
|
this.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
|
||||||
this.comment_min_distance_between_code_and_line_comment = 1;
|
this.comment_min_distance_between_code_and_line_comment = 1;
|
||||||
this.comment_preserve_white_space_between_code_and_line_comment = false;
|
this.comment_preserve_white_space_between_code_and_line_comment = true;
|
||||||
|
this.never_indent_line_comments_on_first_column = true;
|
||||||
// this.comment_clear_blank_lines = false;
|
// this.comment_clear_blank_lines = false;
|
||||||
// this.comment_format = true;
|
// this.comment_format = true;
|
||||||
// this.comment_format_header = false;
|
// this.comment_format_header = false;
|
||||||
|
|
|
@ -13,8 +13,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#ifndef A_H_
|
#ifndef A_H_
|
||||||
#define A_H_
|
#define A_H_
|
||||||
|
@ -25,12 +23,11 @@ public:
|
||||||
virtual ~A();
|
virtual ~A();
|
||||||
int foo();
|
int foo();
|
||||||
void bar();
|
void bar();
|
||||||
|
|
||||||
static const int theAnswer = 42;
|
static const int theAnswer = 42;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
|
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -48,7 +45,6 @@ void A::bar() {
|
||||||
int a = 42;
|
int a = 42;
|
||||||
int b = 42;
|
int b = 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -66,7 +62,6 @@ void A::bar() {
|
||||||
int a = theAnswer;
|
int a = theAnswer;
|
||||||
int b = theAnswer;
|
int b = theAnswer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!ExtractConstantInt 2
|
//!ExtractConstantInt 2
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
|
||||||
//@A.h
|
//@A.h
|
||||||
|
@ -82,8 +77,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#ifndef A_H_
|
#ifndef A_H_
|
||||||
#define A_H_
|
#define A_H_
|
||||||
|
@ -94,12 +87,11 @@ public:
|
||||||
virtual ~A();
|
virtual ~A();
|
||||||
int foo();
|
int foo();
|
||||||
void bar();
|
void bar();
|
||||||
|
|
||||||
static const int theAnswer = 42;
|
static const int theAnswer = 42;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
|
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -118,7 +110,6 @@ void A::bar() {
|
||||||
int a = 42;
|
int a = 42;
|
||||||
int b = 42;
|
int b = 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -137,7 +128,6 @@ void A::bar() {
|
||||||
int a = theAnswer;
|
int a = theAnswer;
|
||||||
int b = theAnswer;
|
int b = theAnswer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!ExtractConstantFloat
|
//!ExtractConstantFloat
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
|
||||||
//@A.h
|
//@A.h
|
||||||
|
@ -153,8 +143,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#ifndef A_H_
|
#ifndef A_H_
|
||||||
#define A_H_
|
#define A_H_
|
||||||
|
@ -165,12 +153,11 @@ public:
|
||||||
virtual ~A();
|
virtual ~A();
|
||||||
float foo();
|
float foo();
|
||||||
void bar();
|
void bar();
|
||||||
|
|
||||||
static const float theAnswer = 42.0f;
|
static const float theAnswer = 42.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
|
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -188,7 +175,6 @@ void A::bar() {
|
||||||
float a = 42.0f;
|
float a = 42.0f;
|
||||||
float b = 42.0f;
|
float b = 42.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -206,7 +192,6 @@ void A::bar() {
|
||||||
float a = theAnswer;
|
float a = theAnswer;
|
||||||
float b = theAnswer;
|
float b = theAnswer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!ExtractConstantDouble
|
//!ExtractConstantDouble
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
|
||||||
//@A.h
|
//@A.h
|
||||||
|
@ -222,8 +207,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#ifndef A_H_
|
#ifndef A_H_
|
||||||
#define A_H_
|
#define A_H_
|
||||||
|
@ -234,12 +217,11 @@ public:
|
||||||
virtual ~A();
|
virtual ~A();
|
||||||
double foo();
|
double foo();
|
||||||
void bar();
|
void bar();
|
||||||
|
|
||||||
static const double theAnswer = 42.0;
|
static const double theAnswer = 42.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
|
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -257,7 +239,6 @@ void A::bar() {
|
||||||
double a = 42.0;
|
double a = 42.0;
|
||||||
double b = 42.0;
|
double b = 42.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -275,7 +256,6 @@ void A::bar() {
|
||||||
double a = theAnswer;
|
double a = theAnswer;
|
||||||
double b = theAnswer;
|
double b = theAnswer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!ExtractConstantStaticInt
|
//!ExtractConstantStaticInt
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
|
||||||
//@A.h
|
//@A.h
|
||||||
|
@ -291,7 +271,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#ifndef A_H_
|
#ifndef A_H_
|
||||||
#define A_H_
|
#define A_H_
|
||||||
|
@ -305,7 +284,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -322,7 +300,6 @@ int A::foo() {
|
||||||
int bar() {
|
int bar() {
|
||||||
return /*$*/42/*$$*/;
|
return /*$*/42/*$$*/;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -345,7 +322,6 @@ int A::foo() {
|
||||||
int bar() {
|
int bar() {
|
||||||
return theAnswer;
|
return theAnswer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!replaceNumberProtected
|
//!replaceNumberProtected
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
|
||||||
//@.config
|
//@.config
|
||||||
|
|
|
@ -13,7 +13,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#ifndef A_H_
|
#ifndef A_H_
|
||||||
#define A_H_
|
#define A_H_
|
||||||
|
@ -24,11 +23,11 @@ public:
|
||||||
virtual ~A();
|
virtual ~A();
|
||||||
int foo();
|
int foo();
|
||||||
void bar();
|
void bar();
|
||||||
|
|
||||||
static const int theAnswer = 42;
|
static const int theAnswer = 42;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -46,7 +45,6 @@ void A::bar() {
|
||||||
int a = 42;
|
int a = 42;
|
||||||
int b = 42;
|
int b = 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -64,7 +62,6 @@ void A::bar() {
|
||||||
int a = theAnswer;
|
int a = theAnswer;
|
||||||
int b = theAnswer;
|
int b = theAnswer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@refScript.xml
|
//@refScript.xml
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<session version="1.0">
|
<session version="1.0">
|
||||||
|
@ -89,7 +86,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#ifndef A_H_
|
#ifndef A_H_
|
||||||
#define A_H_
|
#define A_H_
|
||||||
|
@ -105,7 +101,6 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -118,7 +113,6 @@ A::~A() {
|
||||||
int A::foo() {
|
int A::foo() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -131,7 +125,6 @@ A::~A() {
|
||||||
int A::foo() {
|
int A::foo() {
|
||||||
return theAnswer;
|
return theAnswer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@refScript.xml
|
//@refScript.xml
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<session version="1.0">
|
<session version="1.0">
|
||||||
|
@ -155,7 +148,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#ifndef A_H_
|
#ifndef A_H_
|
||||||
#define A_H_
|
#define A_H_
|
||||||
|
@ -171,7 +163,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -184,7 +175,6 @@ A::~A() {
|
||||||
int A::foo() {
|
int A::foo() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -197,7 +187,6 @@ A::~A() {
|
||||||
int A::foo() {
|
int A::foo() {
|
||||||
return theAnswer;
|
return theAnswer;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@refScript.xml
|
//@refScript.xml
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<session version="1.0">
|
<session version="1.0">
|
||||||
|
|
|
@ -615,175 +615,22 @@ void Test::test() {
|
||||||
bool b = invalid();
|
bool b = invalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
//!Extract int constant
|
//!Extract expression with typedef Bug 331985
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
|
|
||||||
//@.config
|
|
||||||
filename=test.cpp
|
|
||||||
methodname=size
|
|
||||||
|
|
||||||
//@test.h
|
|
||||||
class Test {
|
|
||||||
void test();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//=
|
|
||||||
class Test {
|
|
||||||
void test();
|
|
||||||
int size();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//@test.cpp
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
void Test::test() {
|
|
||||||
int i = /*$*/42/*$$*/;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
int Test::size() {
|
|
||||||
return 42;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Test::test() {
|
|
||||||
int i = size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//!Extract char constant
|
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
|
||||||
|
|
||||||
//@.config
|
|
||||||
filename=test.cpp
|
|
||||||
methodname=newline
|
|
||||||
|
|
||||||
//@test.h
|
|
||||||
class Test {
|
|
||||||
void test();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//=
|
|
||||||
class Test {
|
|
||||||
void test();
|
|
||||||
char newline();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//@test.cpp
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
void Test::test() {
|
|
||||||
char nl = /*$*/'\n'/*$$*/;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
char Test::newline() {
|
|
||||||
return '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
void Test::test() {
|
|
||||||
char nl = newline();
|
|
||||||
}
|
|
||||||
|
|
||||||
//!Extract boolean true constant
|
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
|
||||||
|
|
||||||
//@.config
|
|
||||||
filename=test.cpp
|
|
||||||
methodname=valid
|
|
||||||
|
|
||||||
//@test.h
|
|
||||||
class Test {
|
|
||||||
void test();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//=
|
|
||||||
class Test {
|
|
||||||
void test();
|
|
||||||
bool valid();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//@test.cpp
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
void Test::test() {
|
|
||||||
bool b = /*$*/true/*$$*/;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
bool Test::valid() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Test::test() {
|
|
||||||
bool b = valid();
|
|
||||||
}
|
|
||||||
|
|
||||||
//!Extract boolean false constant
|
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
|
||||||
|
|
||||||
//@.config
|
|
||||||
filename=test.cpp
|
|
||||||
methodname=invalid
|
|
||||||
|
|
||||||
//@test.h
|
|
||||||
class Test {
|
|
||||||
void test();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//=
|
|
||||||
class Test {
|
|
||||||
void test();
|
|
||||||
bool invalid();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//@test.cpp
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
void Test::test() {
|
|
||||||
bool b = /*$*/false/*$$*/;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
bool Test::invalid() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Test::test() {
|
|
||||||
bool b = invalid();
|
|
||||||
}
|
|
||||||
|
|
||||||
//!Extract expresion with typdef Bug 331985
|
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
|
||||||
|
|
||||||
//@.config
|
//@.config
|
||||||
filename=test.cpp
|
filename=test.cpp
|
||||||
methodname=bar
|
methodname=bar
|
||||||
|
|
||||||
//@test.cpp
|
//@test.cpp
|
||||||
typedef int& foo;
|
typedef int& foo;
|
||||||
|
|
||||||
int test(foo s) {
|
int test(foo s) {
|
||||||
int a = /*$*/s + 1/*$$*/; // type of id-expression 's' is int, not 'foo' or 'int&'
|
int a = /*$*/s + 1/*$$*/; // type of id-expression 's' is int, not 'foo' or 'int&'
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=
|
//=
|
||||||
typedef int& foo;
|
typedef int& foo;
|
||||||
|
|
||||||
int bar(foo s) {
|
int bar(foo s) {
|
||||||
return s + 1;
|
return s + 1;
|
||||||
}
|
}
|
||||||
|
@ -792,8 +639,6 @@ int test(foo s) {
|
||||||
int a = bar(s); // type of id-expression 's' is int, not 'foo' or 'int&'
|
int a = bar(s); // type of id-expression 's' is int, not 'foo' or 'int&'
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//!Bug 260133 Extract function and extract local variable don't handle type promotion
|
//!Bug 260133 Extract function and extract local variable don't handle type promotion
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
|
|
||||||
|
@ -802,14 +647,11 @@ filename=test.cpp
|
||||||
methodname=bar
|
methodname=bar
|
||||||
|
|
||||||
//@test.cpp
|
//@test.cpp
|
||||||
|
|
||||||
void foo() {
|
void foo() {
|
||||||
int x = 3;
|
int x = 3;
|
||||||
double y = /*$*/x + 2.5/*$$*/;
|
double y = /*$*/x + 2.5/*$$*/;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
|
|
||||||
double bar(int x) {
|
double bar(int x) {
|
||||||
return x + 2.5;
|
return x + 2.5;
|
||||||
}
|
}
|
||||||
|
@ -818,7 +660,6 @@ void foo() {
|
||||||
int x = 3;
|
int x = 3;
|
||||||
double y = bar(x);
|
double y = bar(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Extract macro
|
//! Extract macro
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
|
|
||||||
|
@ -836,7 +677,6 @@ int main() {
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#define five 5
|
#define five 5
|
||||||
#define ADD(a, b) a + b
|
#define ADD(a, b) a + b
|
||||||
|
@ -851,37 +691,3 @@ int main() {
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Extract macro
|
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
|
||||||
|
|
||||||
//@.config
|
|
||||||
filename=test.cpp
|
|
||||||
methodname=bar
|
|
||||||
|
|
||||||
//@test.cpp
|
|
||||||
#define five 5
|
|
||||||
#define ADD(a, b) a + b
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
int i = five; //comment3
|
|
||||||
i = /*$*/ADD(i, five)/*$$*/;
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=
|
|
||||||
#define five 5
|
|
||||||
#define ADD(a, b) a + b
|
|
||||||
|
|
||||||
int bar(int& i) {
|
|
||||||
return ADD(i, five);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
int i = five; //comment3
|
|
||||||
i = bar(i);
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
void test() {
|
void test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
int tempFunct() {
|
int tempFunct() {
|
||||||
T i;
|
T i;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -13,7 +13,6 @@ int tempFunct() {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
void test() {
|
void test() {
|
||||||
}
|
}
|
||||||
|
@ -24,22 +23,20 @@ void exp(T i) {
|
||||||
i += 3;
|
i += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
int tempFunct() {
|
int tempFunct() {
|
||||||
T i;
|
T i;
|
||||||
i = 0;
|
i = 0;
|
||||||
exp(i);
|
exp(i);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!Extract template function with template parameter Bug #12
|
//!Extract template function with template parameter Bug #12
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
void test() {
|
void test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
int tempFunct(T p) {
|
int tempFunct(T p) {
|
||||||
/*$*/++p;
|
/*$*/++p;
|
||||||
p + 4;/*$$*/
|
p + 4;/*$$*/
|
||||||
|
@ -56,7 +53,7 @@ void exp(T p) {
|
||||||
p + 4;
|
p + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
int tempFunct(T p) {
|
int tempFunct(T p) {
|
||||||
exp(p);
|
exp(p);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -68,7 +65,7 @@ int tempFunct(T p) {
|
||||||
void test() {
|
void test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
int tempFunct() {
|
int tempFunct() {
|
||||||
/*$*/T p;
|
/*$*/T p;
|
||||||
p = 0;
|
p = 0;
|
||||||
|
@ -76,7 +73,6 @@ int tempFunct() {
|
||||||
p + 2;
|
p + 2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
void test() {
|
void test() {
|
||||||
}
|
}
|
||||||
|
@ -89,10 +85,9 @@ T exp() {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template<typename T>
|
||||||
int tempFunct() {
|
int tempFunct() {
|
||||||
T p = exp();
|
T p = exp();
|
||||||
p + 2;
|
p + 2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#ifndef A_H_
|
#ifndef A_H_
|
||||||
#define A_H_
|
#define A_H_
|
||||||
|
@ -32,7 +31,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -52,7 +50,6 @@ int A::foo() {
|
||||||
int A::help() {
|
int A::help() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -77,7 +74,6 @@ int A::foo() {
|
||||||
int A::help() {
|
int A::help() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!ExtractFunctionRefactoringTest with comment
|
//!ExtractFunctionRefactoringTest with comment
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
//@A.h
|
//@A.h
|
||||||
|
@ -95,7 +91,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#ifndef A_H_
|
#ifndef A_H_
|
||||||
#define A_H_
|
#define A_H_
|
||||||
|
@ -112,7 +107,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -133,7 +127,6 @@ int A::foo() {
|
||||||
int A::help() {
|
int A::help() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -159,7 +152,6 @@ int A::foo() {
|
||||||
int A::help() {
|
int A::help() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@.config
|
//@.config
|
||||||
filename=A.cpp
|
filename=A.cpp
|
||||||
methodname=exp
|
methodname=exp
|
||||||
|
@ -213,7 +205,7 @@ void exp(int& i) {
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int i;
|
int i;
|
||||||
exp(i); // Comment
|
exp(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1739,7 +1731,6 @@ returnparameterindex=0
|
||||||
filename=main.h
|
filename=main.h
|
||||||
methodname=loop
|
methodname=loop
|
||||||
//@main.h
|
//@main.h
|
||||||
|
|
||||||
void method() {
|
void method() {
|
||||||
/*$*/for (int var = 0; var < 100; ++var) {
|
/*$*/for (int var = 0; var < 100; ++var) {
|
||||||
if (var < 50)
|
if (var < 50)
|
||||||
|
@ -1747,7 +1738,6 @@ void method() {
|
||||||
}/*$$*/
|
}/*$$*/
|
||||||
}
|
}
|
||||||
//=
|
//=
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
for (int var = 0; var < 100; ++var) {
|
for (int var = 0; var < 100; ++var) {
|
||||||
if (var < 50)
|
if (var < 50)
|
||||||
|
@ -1764,7 +1754,6 @@ void method() {
|
||||||
filename=main.h
|
filename=main.h
|
||||||
fatalerror=true
|
fatalerror=true
|
||||||
//@main.h
|
//@main.h
|
||||||
|
|
||||||
void method() {
|
void method() {
|
||||||
/*$*/if (true)
|
/*$*/if (true)
|
||||||
return;/*$$*/
|
return;/*$$*/
|
||||||
|
@ -1776,14 +1765,12 @@ void method() {
|
||||||
fatalerror=true
|
fatalerror=true
|
||||||
filename=A.h
|
filename=A.h
|
||||||
//@A.h
|
//@A.h
|
||||||
|
|
||||||
void function() {
|
void function() {
|
||||||
for (int var = 0; var < 100; ++var) {
|
for (int var = 0; var < 100; ++var) {
|
||||||
/*$*/if (var < 50)
|
/*$*/if (var < 50)
|
||||||
continue;/*$$*/
|
continue;/*$$*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Bug #124 Extract Function with a Macro call in selected code "forgets" the macro
|
//! Bug #124 Extract Function with a Macro call in selected code "forgets" the macro
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
//@.config
|
//@.config
|
||||||
|
@ -2220,7 +2207,6 @@ test::string toXML() {
|
||||||
int main() {
|
int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "testString.h"
|
#include "testString.h"
|
||||||
|
|
||||||
|
@ -2237,111 +2223,6 @@ test::string toXML() {
|
||||||
int main() {
|
int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!Bug 248622: Extract function fails to extract several expressions; Selection at the end
|
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
|
||||||
//@.config
|
|
||||||
filename=Test.cpp
|
|
||||||
methodname=endTag
|
|
||||||
//@testString.h
|
|
||||||
|
|
||||||
namespace test {
|
|
||||||
|
|
||||||
class string {
|
|
||||||
public:
|
|
||||||
friend string operator+(const string& lhs, const string& rhs) {
|
|
||||||
return rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
string operator+(const string& rhs) { return rhs; }
|
|
||||||
string(char* cp) {}
|
|
||||||
string() {};
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//@Test.cpp
|
|
||||||
#include "testString.h"
|
|
||||||
|
|
||||||
test::string toXML() {
|
|
||||||
test::string name;
|
|
||||||
name = "hello";
|
|
||||||
return "<" + name + ">" + /*$*/"</" + name + ">"/*$$*/;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=
|
|
||||||
#include "testString.h"
|
|
||||||
|
|
||||||
const char endTag(test::string name) {
|
|
||||||
return "</" + name + ">";
|
|
||||||
}
|
|
||||||
|
|
||||||
test::string toXML() {
|
|
||||||
test::string name;
|
|
||||||
name = "hello";
|
|
||||||
return "<" + name + ">" + endTag(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//!Bug 248622: Extract function fails to extract several expressions; Selection in the middle
|
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
|
||||||
//@.config
|
|
||||||
filename=Test.cpp
|
|
||||||
methodname=exp
|
|
||||||
//@testString.h
|
|
||||||
|
|
||||||
namespace test {
|
|
||||||
|
|
||||||
class string {
|
|
||||||
public:
|
|
||||||
friend string operator+(const string& lhs, const string& rhs) {
|
|
||||||
return rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
string operator+(const string& rhs) { return rhs; }
|
|
||||||
string(char* cp) {}
|
|
||||||
string() {};
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//@Test.cpp
|
|
||||||
#include "testString.h"
|
|
||||||
|
|
||||||
test::string toXML() {
|
|
||||||
test::string name;
|
|
||||||
name = "hello";
|
|
||||||
return "<" + name + /*$*/">" + "</"/*$$*/ + name + ">";
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=
|
|
||||||
#include "testString.h"
|
|
||||||
|
|
||||||
const char exp() {
|
|
||||||
return ">" + "</";
|
|
||||||
}
|
|
||||||
|
|
||||||
test::string toXML() {
|
|
||||||
test::string name;
|
|
||||||
name = "hello";
|
|
||||||
return "<" + name + exp() + name + ">";
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//!Bug#262000 refactoring "extract function" misinterprets artificial blocks
|
//!Bug#262000 refactoring "extract function" misinterprets artificial blocks
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
//@.config
|
//@.config
|
||||||
|
@ -2354,7 +2235,6 @@ int main(int argc, char** argv) {
|
||||||
a++;
|
a++;
|
||||||
}/*$$*/
|
}/*$$*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
void exp() {
|
void exp() {
|
||||||
int a = 0;
|
int a = 0;
|
||||||
|
@ -2366,7 +2246,6 @@ void exp() {
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
exp();
|
exp();
|
||||||
}
|
}
|
||||||
|
|
||||||
//!Bug#264712 Refactor extract function deletes comments in header
|
//!Bug#264712 Refactor extract function deletes comments in header
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
//@.config
|
//@.config
|
||||||
|
@ -2411,7 +2290,6 @@ class Test {
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//=
|
//=
|
||||||
/*
|
/*
|
||||||
* Copyright 2009
|
* Copyright 2009
|
||||||
|
@ -2438,11 +2316,11 @@ class Test {
|
||||||
* Retain a value for something.
|
* Retain a value for something.
|
||||||
*/
|
*/
|
||||||
int m_value;
|
int m_value;
|
||||||
|
|
||||||
int exp();
|
int exp();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//@test.cpp
|
//@test.cpp
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ int A::help() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!ExtractFunctionRefactoringTest dublicate with field
|
//!ExtractFunctionRefactoringTest duplicate with field
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
//@.config
|
//@.config
|
||||||
replaceduplicates=true
|
replaceduplicates=true
|
||||||
|
@ -267,7 +267,7 @@ int A::help() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!ExtractFunctionRefactoringTest dublicate with field in marked scope
|
//!ExtractFunctionRefactoringTest duplicate with field in marked scope
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
//@.config
|
//@.config
|
||||||
replaceduplicates=true
|
replaceduplicates=true
|
||||||
|
@ -289,7 +289,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#ifndef A_H_
|
#ifndef A_H_
|
||||||
#define A_H_
|
#define A_H_
|
||||||
|
@ -308,7 +307,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*A_H_*/
|
#endif /*A_H_*/
|
||||||
|
|
||||||
//@A.cpp
|
//@A.cpp
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -336,7 +334,6 @@ void A::foo() {
|
||||||
int A::help() {
|
int A::help() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=
|
//=
|
||||||
#include "A.h"
|
#include "A.h"
|
||||||
|
|
||||||
|
@ -360,6 +357,7 @@ int A::exp(int j) {
|
||||||
|
|
||||||
void A::foo() {
|
void A::foo() {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
j = exp(j);
|
j = exp(j);
|
||||||
field++;
|
field++;
|
||||||
j++;
|
j++;
|
||||||
|
@ -368,7 +366,6 @@ void A::foo() {
|
||||||
int A::help() {
|
int A::help() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!ExtractFunctionRefactoringTest duplicates with different Names and return type
|
//!ExtractFunctionRefactoringTest duplicates with different Names and return type
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
//@.config
|
//@.config
|
||||||
|
@ -561,7 +558,7 @@ int A::help() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
//!ExtractFunctionRefactoringTest with duplicates name used afterwards in duplicate but not in original selection this is no dublicate
|
//!ExtractFunctionRefactoringTest with duplicate name used afterwards in duplicate but not in original selection this is no duplicate
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest
|
||||||
//@.config
|
//@.config
|
||||||
replaceduplicates=true
|
replaceduplicates=true
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue