diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java index 9435c35632a..6ad7efeff3c 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 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 @@ -87,9 +87,13 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser } if (file!=null) { - String filePath = new Path(fileName).toString(); - String foundLocation = file.getLocation().toString(); - if (!foundLocation.endsWith(filePath)) { + IPath filePath = new Path(fileName); + if(filePath.segment(0).compareTo("..") == 0) { //$NON-NLS-1$ + filePath = filePath.removeFirstSegments(1); + } + + String foundLocation = file.getLocationURI().toString(); + if (!foundLocation.endsWith(filePath.toString())) { file = null; } } diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalc2/test1DepCalc2.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalc2/test1DepCalc2.zip old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalc3/test1DepCalc3.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalc3/test1DepCalc3.zip old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalcPreBuild/test1DepCalcPreBuild.zip b/build/org.eclipse.cdt.managedbuilder.core.tests/resources/depCalcProjects/test1DepCalcPreBuild/test1DepCalcPreBuild.zip old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildDependencyCalculatorTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildDependencyCalculatorTests.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF index aab46161e00..82725b3865c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF @@ -7,16 +7,16 @@ Bundle-Activator: org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin Export-Package: org.eclipse.cdt.build.core.scannerconfig, - org.eclipse.cdt.build.internal.core.scannerconfig;x-internal:=true, - org.eclipse.cdt.build.internal.core.scannerconfig2;x-internal:=true, + org.eclipse.cdt.build.internal.core.scannerconfig;x-friends:="org.eclipse.cdt.managedbuilder.ui", + org.eclipse.cdt.build.internal.core.scannerconfig2;x-friends:="org.eclipse.cdt.managedbuilder.ui", org.eclipse.cdt.managedbuilder.buildmodel, org.eclipse.cdt.managedbuilder.buildproperties, org.eclipse.cdt.managedbuilder.core, org.eclipse.cdt.managedbuilder.envvar, - org.eclipse.cdt.managedbuilder.internal.buildmodel;x-internal:=true, - org.eclipse.cdt.managedbuilder.internal.core;x-internal:=true, + org.eclipse.cdt.managedbuilder.internal.buildmodel;x-friends:="org.eclipse.cdt.managedbuilder.ui", + org.eclipse.cdt.managedbuilder.internal.core;x-friends:="org.eclipse.cdt.managedbuilder.ui", org.eclipse.cdt.managedbuilder.internal.envvar;x-internal:=true, - org.eclipse.cdt.managedbuilder.internal.macros;x-internal:=true, + org.eclipse.cdt.managedbuilder.internal.macros;x-friends:="org.eclipse.cdt.managedbuilder.ui", org.eclipse.cdt.managedbuilder.internal.scannerconfig;x-internal:=true, org.eclipse.cdt.managedbuilder.macros, org.eclipse.cdt.managedbuilder.makegen, @@ -25,7 +25,7 @@ Export-Package: org.eclipse.cdt.build.core.scannerconfig, org.eclipse.cdt.managedbuilder.pdomdepgen, org.eclipse.cdt.managedbuilder.projectconverter, org.eclipse.cdt.managedbuilder.scannerconfig, - org.eclipse.cdt.managedbuilder.tcmodification;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.managedbuilder.ui,org.eclipse.cdt.managedbuilder.core.tests", + org.eclipse.cdt.managedbuilder.tcmodification;x-friends:="org.eclipse.cdt.managedbuilder.ui,org.eclipse.cdt.managedbuilder.core.tests", org.eclipse.cdt.managedbuilder.templateengine, org.eclipse.cdt.managedbuilder.templateengine.processes, org.eclipse.cdt.newmake.core diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCalculator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCalculator.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCommands.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCommands.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGeneratorType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGeneratorType.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyInfo.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyPreBuild.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyPreBuild.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator2Commands.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3Commands.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator3Commands.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculatorPreBuild.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculatorPreBuild.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculatorPreBuildCommands.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculatorPreBuildCommands.java old mode 100755 new mode 100644 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuDependencyGroupInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuDependencyGroupInfo.java old mode 100755 new mode 100644 diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/StatementHasNoEffectCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/StatementHasNoEffectCheckerTest.java index 25596bf9398..3848fedd717 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/StatementHasNoEffectCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/StatementHasNoEffectCheckerTest.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.cdt.codan.core.internal.checkers; -import java.io.File; -import java.io.IOException; - import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.test.CheckerTestCase; import org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectChecker; import org.eclipse.core.resources.IMarker; +import java.io.File; +import java.io.IOException; + /** * Test for {@see StatementHasNoEffectChecker} class * @@ -107,7 +107,7 @@ public class StatementHasNoEffectCheckerTest extends CheckerTestCase { // } /* this test is using two files */ public void test2FilesUnaryExpression() throws IOException { - StringBuffer[] code = getContents(2); + CharSequence[] code = getContents(2); File f1 = loadcode(code[0].toString()); File f2 = loadcode(code[1].toString()); runOnProject(); diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java index 30b2d3e1e4f..fda1349b053 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanFastCxxAstTestCase.java @@ -10,9 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.codan.core.test; -import java.io.IOException; -import java.util.ArrayList; - import junit.framework.TestCase; import org.eclipse.cdt.codan.core.CodanRuntime; @@ -45,6 +42,9 @@ import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser; import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; +import java.io.IOException; +import java.util.ArrayList; + /** * TODO: add description */ @@ -56,7 +56,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase { return getContents(1)[0].toString(); } - protected StringBuffer[] getContents(int sections) { + protected StringBuilder[] getContents(int sections) { try { CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault(); return TestSourceReader.getContentsForTest(plugin == null ? null : plugin.getBundle(), "src", getClass(), getName(), sections); @@ -69,6 +69,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase { public boolean isCpp() { return false; } + private static final NullLogService NULL_LOG = new NullLogService(); /** diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java index 120883430af..76b3397fd6e 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CodanTestCase.java @@ -10,12 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.codan.core.test; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.ArrayList; - import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.CModelException; @@ -36,6 +30,12 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Plugin; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; + /** * TODO: add description */ @@ -64,7 +64,7 @@ public class CodanTestCase extends BaseTestCase { /** * Override for c++ (i.e. at least one c++ test) - * + * * @return is c++ tests */ public boolean isCpp() { @@ -170,9 +170,10 @@ public class CodanTestCase extends BaseTestCase { return getContents(1)[0].toString(); } - protected StringBuffer[] getContents(int sections) { + protected StringBuilder[] getContents(int sections) { try { - return TestSourceReader.getContentsForTest(getPlugin().getBundle(), getSourcePrefix(), getClass(), getName(), sections); + return TestSourceReader.getContentsForTest(getPlugin().getBundle(), getSourcePrefix(), + getClass(), getName(), sections); } catch (IOException e) { fail(e.getMessage()); return null; diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFixTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFixTest.java index 0d47fe67ad6..e06baa2f08e 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFixTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/internal/checkers/ui/quickfix/SuggestedParenthesisQuickFixTest.java @@ -10,16 +10,16 @@ *******************************************************************************/ package org.eclipse.cdt.codan.internal.checkers.ui.quickfix; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; - import org.eclipse.cdt.codan.core.test.TestUtils; import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution; import org.eclipse.cdt.internal.ui.util.EditorUtility; import org.eclipse.core.runtime.CoreException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + /** * Test for quick fix for suggested parenthesis */ @@ -32,7 +32,7 @@ public class SuggestedParenthesisQuickFixTest extends QuickFixTestCase { // main() { // int a=1,b=3; - // if (b+a && a>b || b-a) b--; // error here + // if (b+a && a>b || b-a) b--; // error here // } public void testSimple() throws IOException, CoreException { loadcode(getAboveComment()); @@ -53,7 +53,7 @@ public class SuggestedParenthesisQuickFixTest extends QuickFixTestCase { * quick fix is not called */ public void test2FilesExample() throws FileNotFoundException, IOException { - StringBuffer[] code = getContents(2); + CharSequence[] code = getContents(2); File f1 = loadcode(code[0].toString()); File f2 = loadcode(code[1].toString()); // lets pretend marker is found in main.c but fixes go in both files, diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib old mode 100755 new mode 100644 diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib old mode 100755 new mode 100644 diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java index 8fe04b57bb4..26185fccbc2 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java @@ -473,7 +473,7 @@ public class AST2BaseTest extends BaseTestCase { return getContents(1)[0].toString(); } - protected StringBuffer[] getContents(int sections) throws IOException { + protected CharSequence[] getContents(int sections) throws IOException { CTestPlugin plugin = CTestPlugin.getDefault(); if (plugin == null) throw new AssertionFailedError("This test must be run as a JUnit plugin test"); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index ff63b87b7cd..cca271c32ad 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -8060,7 +8060,7 @@ public class AST2CPPTests extends AST2BaseTest { // } public void testInitOfClassObjectsByRValues_294730() throws Exception { - final StringBuffer[] contents = getContents(3); + final CharSequence[] contents = getContents(3); final String code= contents[0].toString(); final String end= contents[2].toString(); parseAndCheckBindings(code + end, ParserLanguage.CPP); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTest.java index d6f9967f8a7..02698c23363 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2FileBasePluginTest.java @@ -145,7 +145,7 @@ public class AST2FileBasePluginTest extends TestCase { return file; } - protected StringBuffer[] getContents(int sections) throws IOException { + protected StringBuilder[] getContents(int sections) throws IOException { return TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 0f18f070973..9966c5c8390 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -4039,7 +4039,7 @@ public class AST2Tests extends AST2BaseTest { // ASSERT(false);// fine // } public void testBug188855_gccExtensionForVariadicMacros() throws Exception { - StringBuffer[] buffer = getContents(2); + CharSequence[] buffer = getContents(2); final String content1 = buffer[0].toString(); final String content2 = buffer[1].toString(); parse(content1, ParserLanguage.CPP); @@ -4843,7 +4843,7 @@ public class AST2Tests extends AST2BaseTest { // return 0; // } public void testBug228422_noKnrParam() throws Exception { - StringBuffer buffer = getContents(1)[0]; + CharSequence buffer = getContents(1)[0]; parse(buffer.toString(), ParserLanguage.C, false); } @@ -5262,7 +5262,7 @@ public class AST2Tests extends AST2BaseTest { // (typeof a)(t)-a // typeof a,t,a,unary-,cast,cast // (typeof a)(a)-a // typeof a,a,cast,a,- public void testBinaryVsCastAmbiguities_Bug237057() throws Exception { - StringBuffer[] input= getContents(2); + CharSequence[] input= getContents(2); String code= input[0].toString(); String[] samples= input[1].toString().split("\n"); for (ParserLanguage lang : ParserLanguage.values()) { @@ -5302,7 +5302,7 @@ public class AST2Tests extends AST2BaseTest { // (f)(a)+1 // f,a,(),1,+ // (t)(t)+1 // t,t,1,unary+,cast,cast public void testCastVsFunctionCallAmbiguities_Bug237057() throws Exception { - StringBuffer[] input= getContents(2); + CharSequence[] input= getContents(2); String code= input[0].toString(); String[] samples= input[1].toString().split("\n"); for (ParserLanguage lang : ParserLanguage.values()) { @@ -5327,7 +5327,7 @@ public class AST2Tests extends AST2BaseTest { // 0, a= 1 ? 2,3 : b= 4, 5 // 0,a,1,2,3,,,b,4,=,?,=,5,, // 1 ? 2 ? 3 : 4 ? 5 : 6 : 7 // 1,2,3,4,5,6,?,?,7,? public void testBinaryExpressionBinding() throws Exception { - StringBuffer[] input= getContents(2); + CharSequence[] input= getContents(2); String code= input[0].toString(); String[] samples= input[1].toString().split("\n"); for (ParserLanguage lang : ParserLanguage.values()) { @@ -5352,7 +5352,7 @@ public class AST2Tests extends AST2BaseTest { // 1 ? 2,3 : b= 4 // 1,2,3,,,b,4,=,? // 1 ? 2 ? 3 : 4 ? 5 : 6 : 7 // 1,2,3,4,5,6,?,?,7,? public void testConstantExpressionBinding() throws Exception { - StringBuffer[] input= getContents(2); + CharSequence[] input= getContents(2); String code= input[0].toString(); String[] samples= input[1].toString().split("\n"); for (ParserLanguage lang : ParserLanguage.values()) { @@ -5859,7 +5859,7 @@ public class AST2Tests extends AST2BaseTest { public void testScalabilityOfLargeTrivialInitializer_Bug253690() throws Exception { sValidateCopy= false; final int AMOUNT= 250000; - final StringBuffer[] input = getContents(3); + final CharSequence[] input = getContents(3); StringBuilder buf= new StringBuilder(); buf.append(input[0].toString()); final String line= input[1].toString(); @@ -5892,7 +5892,7 @@ public class AST2Tests extends AST2BaseTest { public void testLargeTrivialAggregateInitializer_Bug253690() throws Exception { sValidateCopy= false; final int AMOUNT= 250000; - final StringBuffer[] input = getContents(3); + final CharSequence[] input = getContents(3); StringBuilder buf= new StringBuilder(); buf.append(input[0].toString()); final String line= input[1].toString(); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java index 0cb93433380..b60b13cb03c 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java @@ -201,7 +201,7 @@ public class CommentTests extends AST2BaseTest { // // comment2 // #endif public void testCommentsInInactiveCode_bug183930() throws Exception { - StringBuffer code= getContents(1)[0]; + CharSequence code= getContents(1)[0]; IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true); IASTComment[] comments = tu.getComments(); @@ -212,7 +212,7 @@ public class CommentTests extends AST2BaseTest { // //comment public void testCommentLocation_bug186337() throws Exception{ - StringBuffer code= getContents(1)[0]; + CharSequence code= getContents(1)[0]; IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true); IASTComment[] comments = tu.getComments(); @@ -236,7 +236,7 @@ public class CommentTests extends AST2BaseTest { // // TODO: shows up in task list public void testCommentInDirectives_bug192546() throws Exception { - StringBuffer code= getContents(1)[0]; + CharSequence code= getContents(1)[0]; IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, false); IASTComment[] comments = tu.getComments(); @@ -246,7 +246,7 @@ public class CommentTests extends AST2BaseTest { for (IASTComment comment : comments) { IASTFileLocation loc= comment.getFileLocation(); int idx= loc.getNodeOffset() + comment.getRawSignature().indexOf("TODO"); - assertEquals("TODO", code.substring(idx, idx+4)); + assertEquals("TODO", code.subSequence(idx, idx + 4)); } } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java index 6b9be5bf38a..325fc03f6dd 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMPreprocessorInformationTest.java @@ -190,7 +190,7 @@ public class DOMPreprocessorInformationTest extends AST2BaseTest { // #elif // #endif public void testElifWithoutCondition_bug185324() throws Exception { - StringBuffer code= getContents(1)[0]; + CharSequence code= getContents(1)[0]; IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, false); IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements(); assertEquals(3, st.length); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java index 7e68668203f..1935a184c6b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java @@ -370,5 +370,12 @@ public class BasicCompletionTest extends CompletionTestBase { checkCompletion(code, false, expected); checkCompletion(code, true, expected); } - + + // struct foo { int axx;}; + // struct foo bar = {.a + public void testCompletionInDesignatedInitializor_353281() throws Exception { + String code = getAboveComment(); + String[] expected= {"axx"}; + checkCompletion(code, false, expected); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java index 183f4e15b51..f871735c6fa 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/CompletionTestBase.java @@ -132,7 +132,7 @@ public class CompletionTestBase extends BaseTestCase { return getContents(1)[0].toString(); } - protected StringBuffer[] getContents(int sections) throws IOException { + protected StringBuilder[] getContents(int sections) throws IOException { CTestPlugin plugin = CTestPlugin.getDefault(); if (plugin == null) throw new AssertionFailedError("This test must be run as a JUnit plugin test"); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ExpansionExplorerTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ExpansionExplorerTests.java index 3f517a50945..c2aa283b43d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ExpansionExplorerTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/ExpansionExplorerTests.java @@ -36,11 +36,11 @@ public class ExpansionExplorerTests extends BaseTestCase { } private void performTest(int steps) throws Exception { - StringBuffer[] bufs= TestSourceReader.getContentsForTest( + CharSequence[] bufs= TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), steps+2); String[] input= new String[steps+2]; int i= -1; - for (StringBuffer buf : bufs) { + for (CharSequence buf : bufs) { input[++i]= buf.toString().trim(); } final MacroExpander expander= createExpander(input[0]); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java index 0790a6fdad5..7b8fccea0d1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java @@ -113,7 +113,7 @@ public class LocationMapTests extends BaseTestCase { super.tearDown(); } - protected StringBuffer[] getContents(int sections) throws IOException { + protected StringBuilder[] getContents(int sections) throws IOException { return TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java index c688c1defd2..550e1a84020 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java @@ -95,10 +95,9 @@ public abstract class PreprocessorTestsBase extends BaseTestCase { initializeScanner(getAboveComment()); } - protected StringBuffer[] getTestContent(int sections) throws IOException { - StringBuffer[] input= TestSourceReader.getContentsForTest( + protected StringBuilder[] getTestContent(int sections) throws IOException { + return TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections); - return input; } protected String getAboveComment() throws IOException { @@ -110,8 +109,7 @@ public abstract class PreprocessorTestsBase extends BaseTestCase { for(;;) { IToken t= fScanner.nextToken(); } - } - catch ( EndOfFileException e){ + } catch ( EndOfFileException e){ } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java index 46d2e40f8da..54bf1201d2f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java @@ -211,7 +211,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { void setUp() throws Exception; void tearDown() throws Exception; public IASTTranslationUnit getAst(); - public StringBuffer[] getTestData(); + public StringBuilder[] getTestData(); public ICProject getCProject(); public boolean isCompositeIndex(); } @@ -242,7 +242,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { class SinglePDOMTestFirstASTStrategy implements ITestStrategy { private IIndex index; private ICProject cproject; - private StringBuffer[] testData; + private StringBuilder[] testData; private IASTTranslationUnit ast; private boolean cpp; @@ -254,7 +254,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { return cproject; } - public StringBuffer[] getTestData() { + public StringBuilder[] getTestData() { return testData; } @@ -308,7 +308,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { class SinglePDOMTestStrategy implements ITestStrategy { private IIndex index; private ICProject cproject; - private StringBuffer[] testData; + private StringBuilder[] testData; private IASTTranslationUnit ast; private boolean cpp; @@ -319,8 +319,8 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { public ICProject getCProject() { return cproject; } - - public StringBuffer[] getTestData() { + + public StringBuilder[] getTestData() { return testData; } @@ -373,7 +373,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { class ReferencedProject implements ITestStrategy { private IIndex index; private ICProject cproject, referenced; - private StringBuffer[] testData; + private StringBuilder[] testData; private IASTTranslationUnit ast; private boolean cpp; @@ -453,7 +453,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { return index; } - public StringBuffer[] getTestData() { + public StringBuilder[] getTestData() { return testData; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java index 3ae8ffda9f6..e4bc6555ffc 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java @@ -275,11 +275,11 @@ public class IndexBugsTests extends BaseTestCase { } protected String[] getContentsForTest(int blocks) throws IOException { - StringBuffer[] help= TestSourceReader.getContentsForTest( + CharSequence[] help= TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks); String[] result= new String[help.length]; int i= 0; - for (StringBuffer buf : help) { + for (CharSequence buf : help) { result[i++]= buf.toString(); } return result; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java index 1e593ef4541..23c90e04059 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCompositeTests.java @@ -63,7 +63,7 @@ public class IndexCompositeTests extends BaseTestCase { IIndex index; - protected StringBuffer[] getContentsForTest(int blocks) throws IOException { + protected StringBuilder[] getContentsForTest(int blocks) throws IOException { return TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks); } @@ -72,7 +72,7 @@ public class IndexCompositeTests extends BaseTestCase { // class B {}; public void testPairDisjointContent() throws Exception { - StringBuffer[] contents = getContentsForTest(2); + CharSequence[] contents = getContentsForTest(2); List projects = new ArrayList(); try { @@ -117,7 +117,7 @@ public class IndexCompositeTests extends BaseTestCase { // void foo(X::B2 c) {} // namespace X { class A2 {}; B2 b; C2 c; } public void testTripleLinear() throws Exception { - StringBuffer[] contents = getContentsForTest(3); + CharSequence[] contents = getContentsForTest(3); List projects = new ArrayList(); try { @@ -224,7 +224,7 @@ public class IndexCompositeTests extends BaseTestCase { // namespace X { class A2 {}; } // B1 ab; public void testTripleUpwardV() throws Exception { - StringBuffer[] contents = getContentsForTest(3); + CharSequence[] contents = getContentsForTest(3); List projects = new ArrayList(); @@ -313,7 +313,7 @@ public class IndexCompositeTests extends BaseTestCase { // void foo(A1 a, A1 b) {} // namespace X { class A2 {}; } public void testTripleDownwardV() throws Exception { - StringBuffer[] contents = getContentsForTest(3); + CharSequence[] contents = getContentsForTest(3); List projects = new ArrayList(); try { @@ -450,7 +450,7 @@ class ProjectBuilder { return this; } - ProjectBuilder addFile(String relativePath, StringBuffer content) { + ProjectBuilder addFile(String relativePath, CharSequence content) { path2content.put(relativePath, content.toString()); return this; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java index d4048f2fcac..e9acad9167f 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexIncludeTest.java @@ -285,7 +285,7 @@ public class IndexIncludeTest extends IndexTestBase { // #include "header1.h" // #include "header2.h" public void testParsingInContext_bug220358() throws Exception { - StringBuffer[] sources= getContentsForTest(4); + CharSequence[] sources= getContentsForTest(4); IFile h1= TestSourceReader.createFile(fProject.getProject(), "header1.h", sources[0].toString()); IFile h2= TestSourceReader.createFile(fProject.getProject(), "header2.h", sources[1].toString()); IFile s1= TestSourceReader.createFile(fProject.getProject(), "s1.cpp", sources[3].toString()); @@ -405,7 +405,7 @@ public class IndexIncludeTest extends IndexTestBase { public void testUpdateIncludes() throws Exception { waitForIndexer(); TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()}; - StringBuffer[] source= getContentsForTest(4); + CharSequence[] source= getContentsForTest(4); IFile header= TestSourceReader.createFile(fProject.getProject(), "resolved20070427.h", ""); IFile s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp", source[0].toString() + "\nint a20070427;"); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java index eb7232c9195..ac54b275678 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexLocationTest.java @@ -90,7 +90,7 @@ public class IndexLocationTest extends BaseTestCase { try { Bundle b = CTestPlugin.getDefault().getBundle(); - StringBuffer[] testData = TestSourceReader.getContentsForTest(b, "parser", getClass(), getName(), 3); + CharSequence[] testData = TestSourceReader.getContentsForTest(b, "parser", getClass(), getName(), 3); IFile file1 = TestSourceReader.createFile(cproject.getProject(), "header.h", testData[0].toString()); createExternalFile(externalHeader, testData[1].toString()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java index 144a5cf0ccd..c85dbceaff4 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexTestBase.java @@ -59,7 +59,7 @@ public class IndexTestBase extends BaseTestCase { return TestSourceReader.readTaggedComment(CTestPlugin.getDefault().getBundle(), "parser", getClass(), tag); } - protected StringBuffer[] getContentsForTest(int blocks) throws IOException { + protected StringBuilder[] getContentsForTest(int blocks) throws IOException { return TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java index 37d3b1fcc02..d7792c838ec 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexUpdateTests.java @@ -85,7 +85,7 @@ public class IndexUpdateTests extends IndexTestBase { private ICProject fCppProject= null; private ICProject fCProject= null; private IIndex fIndex= null; - private StringBuffer[] fContents; + private CharSequence[] fContents; private IFile fFile; private IFile fHeader; private int fContentUsed; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java index 51c6d0e5dd1..808169ddf87 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPClassTemplateTests.java @@ -59,9 +59,9 @@ public class CPPClassTemplateTests extends PDOMTestBase { } protected void setUpSections(int sections) throws Exception { - StringBuffer[] contents= TestSourceReader.getContentsForTest( + CharSequence[] contents= TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections); - for (StringBuffer content : contents) { + for (CharSequence content : contents) { IFile file= TestSourceReader.createFile(cproject.getProject(), new Path("refs.cpp"), content.toString()); } IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER); @@ -76,7 +76,7 @@ public class CPPClassTemplateTests extends PDOMTestBase { @Override protected void tearDown() throws Exception { - if(pdom!=null) { + if(pdom != null) { pdom.releaseReadLock(); } pdom= null; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTemplateTests.java index 0cc9dff9478..cdb7fdd4eb8 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTemplateTests.java @@ -43,9 +43,9 @@ public class CPPFunctionTemplateTests extends PDOMTestBase { } protected void setUpSections(int sections) throws Exception { - StringBuffer[] contents= TestSourceReader.getContentsForTest( + StringBuilder[] contents= TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections); - for (StringBuffer content : contents) { + for (StringBuilder content : contents) { IFile file= TestSourceReader.createFile(cproject.getProject(), new Path("refs.cpp"), content.toString()); } IndexerPreferences.set(cproject.getProject(), IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java index 48690e7846a..2b082fa568e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMCBugsTest.java @@ -53,7 +53,8 @@ public class PDOMCBugsTest extends BaseTestCase { protected void setUp() throws Exception { cproject= CProjectHelper.createCProject("PDOMCBugsTest"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER); Bundle b = CTestPlugin.getDefault().getBundle(); - StringBuffer[] testData = TestSourceReader.getContentsForTest(b, "parser", PDOMCBugsTest.this.getClass(), getName(), 1); + CharSequence[] testData = TestSourceReader.getContentsForTest(b, "parser", + PDOMCBugsTest.this.getClass(), getName(), 1); IFile file = TestSourceReader.createFile(cproject.getProject(), new Path("header.h"), testData[0].toString()); CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java index a3fe4b3e802..a6f3912954b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java @@ -44,7 +44,7 @@ public class PDOMLocationTests extends BaseTestCase { cproject= CProjectHelper.createCCProject("PDOMLocationTests"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER); Bundle b = CTestPlugin.getDefault().getBundle(); - StringBuffer[] testData = TestSourceReader.getContentsForTest(b, "parser", getClass(), getName(), 3); + CharSequence[] testData = TestSourceReader.getContentsForTest(b, "parser", getClass(), getName(), 3); super.setUp(); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMPrettyPrinter.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMPrettyPrinter.java index 1ad3bffb014..97d37860af1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMPrettyPrinter.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMPrettyPrinter.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Symbian - Initial implementation + * Symbian - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.pdom.tests; @@ -28,7 +28,7 @@ import org.eclipse.core.runtime.CoreException; * a lo-fidelity debugging tool) */ public class PDOMPrettyPrinter implements IPDOMVisitor { - StringBuffer indent = new StringBuffer(); + StringBuilder indent = new StringBuilder(); final String step = " "; //$NON-NLS-1$ public void leave(IPDOMNode node) throws CoreException { diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java index 140d2c3b8a2..ce685b82fae 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java @@ -57,18 +57,19 @@ import org.osgi.framework.Bundle; public class TestSourceReader { /** - * Returns an array of StringBuffer objects for each comment section found preceding the named + * Returns an array of StringBuilder objects for each comment section found preceding the named * test in the source code. - * @param bundle the bundle containing the source, if null can try to load using classpath (source folder has to be in the classpath for this to work) + * @param bundle the bundle containing the source, if null can try to load using classpath + * (source folder has to be in the classpath for this to work) * @param srcRoot the directory inside the bundle containing the packages * @param clazz the name of the class containing the test * @param testName the name of the test * @param sections the number of comment sections preceding the named test to return - * @return an array of StringBuffer objects for each comment section found preceding the named + * @return an array of StringBuilder objects for each comment section found preceding the named * test in the source code. * @throws IOException */ - public static StringBuffer[] getContentsForTest(Bundle bundle, String srcRoot, Class clazz, final String testName, int sections) throws IOException { + public static StringBuilder[] getContentsForTest(Bundle bundle, String srcRoot, Class clazz, final String testName, int sections) throws IOException { String fqn = clazz.getName().replace('.', '/'); fqn = fqn.indexOf("$")==-1 ? fqn : fqn.substring(0,fqn.indexOf("$")); String classFile = fqn + ".java"; @@ -91,7 +92,7 @@ public class TestSourceReader { BufferedReader br = new BufferedReader(new InputStreamReader(in)); List contents = new ArrayList(); - StringBuffer content = new StringBuffer(); + StringBuilder content = new StringBuilder(); for(String line = br.readLine(); line!=null; line = br.readLine()) { line = line.replaceFirst("^\\s*", ""); // replace leading whitespace, preserve trailing if(line.startsWith("//")) { @@ -101,11 +102,11 @@ public class TestSourceReader { contents.add(content); if(contents.size()==sections+1) contents.remove(0); - content = new StringBuffer(); + content = new StringBuilder(); } int idx= line.indexOf(testName); if( idx != -1 && !Character.isJavaIdentifierPart(line.charAt(idx+testName.length()))) { - return (StringBuffer[]) contents.toArray(new StringBuffer[contents.size()]); + return (StringBuilder[]) contents.toArray(new StringBuilder[contents.size()]); } } } @@ -132,7 +133,7 @@ public class TestSourceReader { try { int c= 0; int offset= 0; - StringBuffer buf= new StringBuffer(); + StringBuilder buf= new StringBuilder(); while ((c = reader.read()) >= 0) { buf.append((char) c); if (c == '\n') { @@ -182,7 +183,7 @@ public class TestSourceReader { InputStream in= FileLocator.openStream(bundle, filePath, false); LineNumberReader reader= new LineNumberReader(new InputStreamReader(in)); boolean found= false; - final StringBuffer content= new StringBuffer(); + final StringBuilder content= new StringBuilder(); try { String line= reader.readLine(); while (line != null) { @@ -222,7 +223,6 @@ public class TestSourceReader { * @param contents the content for the file * @return a file object. * @throws CoreException - * @throws Exception * @since 4.0 */ public static IFile createFile(final IContainer container, final IPath filePath, final String contents) throws CoreException { @@ -264,10 +264,7 @@ public class TestSourceReader { * @param container a container to create the file in * @param filePath the path relative to the container to create the file at * @param contents the content for the file - * @return * @return a file object. - * @throws Exception - * @throws Exception * @since 4.0 */ public static IFile createFile(IContainer container, String filePath, String contents) throws CoreException { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java index c6acb69f186..6f0b6dea97f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/LanguageManager.java @@ -19,8 +19,8 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.Map.Entry; +import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ILinkage; @@ -573,7 +573,14 @@ public class LanguageManager { IProject project = file.getProject(); if (contentTypeId == null) { - IContentType contentType= CContentTypes.getContentType(project, file.getLocation().toString()); + IPath location = file.getLocation(); + String filename; + if (location != null) { + filename = location.toString(); + } else { + filename = file.getName(); + } + IContentType contentType= CContentTypes.getContentType(project, filename); if (contentType == null) { return null; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java index 7232158faf2..06ecc55e5a2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ASTStringUtil.java @@ -77,17 +77,15 @@ import org.eclipse.cdt.core.parser.Keywords; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; - /** * This is a utility class to help convert AST elements to Strings. * * @see org.eclipse.cdt.core.dom.ast.ASTTypeUtil */ - public class ASTStringUtil { private static final String SPACE= " "; //$NON-NLS-1$ private static final String COMMA_SPACE= ", "; //$NON-NLS-1$ - private static final String[] EMPTY_STRING_ARRAY= new String[0]; + private static final String[] EMPTY_STRING_ARRAY= {}; /** * Return the qualified name if the given IASTName diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java index f7d7e7008b3..aa73b84f7e6 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Intel Corporation and others. + * Copyright (c) 2007, 2011 Intel 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 @@ -7,6 +7,7 @@ * * Contributors: * Intel Corporation - Initial API and implementation + * IBM Corporation *******************************************************************************/ package org.eclipse.cdt.internal.core.settings.model; @@ -35,6 +36,7 @@ import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsLogger; +import org.eclipse.cdt.utils.EFSExtensionManager; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; @@ -243,10 +245,11 @@ public class DescriptionScannerInfoProvider implements IScannerInfoProvider, ICP IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource rc = root.findMember(path); if(rc != null){ - path = rc.getLocation(); + path = new Path(EFSExtensionManager.getDefault().getPathFromURI(rc.getLocationURI())); } } else if (!path.isAbsolute()) { - IPath projLocation = fProject != null ? fProject.getLocation() : null; + IPath projLocation = fProject != null ? new Path(EFSExtensionManager.getDefault() + .getPathFromURI(fProject.getLocationURI())) : null; if(projLocation != null) path = projLocation.append(path); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorMacroDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorMacroDefinition.java index ba51cd823d7..64ab382c073 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorMacroDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorMacroDefinition.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -17,9 +17,7 @@ package org.eclipse.cdt.core.dom.ast; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface IASTPreprocessorMacroDefinition extends - IASTPreprocessorStatement, IASTNameOwner { - +public interface IASTPreprocessorMacroDefinition extends IASTPreprocessorStatement, IASTNameOwner { /** * MACRO_NAME describes the relationship between a macro * definition and it's name. @@ -43,7 +41,6 @@ public interface IASTPreprocessorMacroDefinition extends * @since 5.0 */ public IASTFileLocation getExpansionLocation(); - /** * Returns whether this macro definition occurs in active code. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/ASTRewrite.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/ASTRewrite.java index d4e6affabbf..ec1ee98719e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/ASTRewrite.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/rewrite/ASTRewrite.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.rewrite; @@ -29,31 +29,30 @@ import org.eclipse.text.edits.TextEditGroup; /** * Infrastructure for modifying code by describing changes to AST nodes. The AST rewriter collects - * descriptions of modifications to nodes and translates these descriptions into text edits that can then be - * applied to the original source. This is all done without actually modifying the original AST. The rewrite - * infrastructure tries to generate minimal text changes, preserve existing comments and indentation, and - * follow code formatter settings. A {@link IASTComment} can be removed from or added to a node. + * descriptions of modifications to nodes and translates these descriptions into text edits that can + * then be applied to the original source. This is all done without actually modifying the original + * AST. The rewrite infrastructure tries to generate minimal text changes, preserve existing + * comments and indentation, and follow code formatter settings. A {@link IASTComment} can be + * removed from or added to a node. *

- * The initial implementation does not support nodes that implement {@link IASTPreprocessorStatement} or - * {@link IASTProblem}. + * The initial implementation does not support nodes that implement + * {@link IASTPreprocessorStatement} or {@link IASTProblem}. *

- * EXPERIMENTAL. This class or interface has been added as part of a work in progress. There - * is no guarantee that this API will work or that it will remain the same. Please do not use this API without - * consulting with the CDT team. + * EXPERIMENTAL. This class or interface has been added as part of a work in + * progress. There is no guarantee that this API will work or that it will remain the same. + * Please do not use this API without consulting with the CDT team. *

* * @since 5.0 * @noinstantiate This class is not intended to be instantiated by clients. */ public final class ASTRewrite { - /** * Defines the positions of the comment. * * @since 5.3 */ - public enum CommentPosition{ - + public enum CommentPosition { /** * Comments before a statement, declaration, or definition */ @@ -63,8 +62,8 @@ public final class ASTRewrite { */ trailing, /** - * Comments before a closing brace such as they occur in namespace-, class- and method-definitions or - * at the end of a file + * Comments before a closing brace such as they occur in namespace-, class- and + * method-definitions or at the end of a file */ freestanding } @@ -82,13 +81,14 @@ public final class ASTRewrite { private final ASTModification fParentMod; private final NodeCommentMap fCommentMap; - private enum Operation{ + private enum Operation { insertBefore, replace, remove } - private ASTRewrite(IASTNode root, ASTModificationStore modStore, ASTModification parentMod, NodeCommentMap commentMap) { + private ASTRewrite(IASTNode root, ASTModificationStore modStore, ASTModification parentMod, + NodeCommentMap commentMap) { fRoot= root; fModificationStore= modStore; fParentMod= parentMod; @@ -115,9 +115,9 @@ public final class ASTRewrite { * * @param node the node being removed * @param editGroup the edit group in which to collect the corresponding - * text edits, or null + * text edits, or null * @throws IllegalArgumentException if the node is null, the node is not - * part of this rewriter's AST. + * part of this rewriter's AST. */ public final void remove(IASTNode node, TextEditGroup editGroup) { checkBelongsToAST(node); @@ -134,11 +134,11 @@ public final class ASTRewrite { * * @param node the node being replaced * @param replacement the node replacing the given one - * @param editGroup the edit group in which to collect the corresponding - * text edits, or null + * @param editGroup the edit group in which to collect the corresponding text edits, + * or null * @return a rewriter for further rewriting the replacement node. - * @throws IllegalArgumentException if the node or the replacement is null, or if the node is not - * part of this rewriter's AST + * @throws IllegalArgumentException if the node or the replacement is null, or if the node is + * not part of this rewriter's AST */ public final ASTRewrite replace(IASTNode node, IASTNode replacement, TextEditGroup editGroup) { if (replacement == null) { @@ -158,15 +158,17 @@ public final class ASTRewrite { * The new node can be part of a translation-unit or it is a synthetic * (newly created) node. * @param parent the parent the new node is added to. - * @param insertionPoint the node before which the insertion shall be done, or null for inserting after the last child. + * @param insertionPoint the node before which the insertion shall be done, or null + * for inserting after the last child. * @param newNode the node being inserted * @param editGroup the edit group in which to collect the corresponding - * text edits, or null + * text edits, or null * @return a rewriter for further rewriting the inserted node. - * @throws IllegalArgumentException if the parent or the newNode is null, or if the parent is not - * part of this rewriter's AST, or the insertionPoint is not a child of the parent. + * @throws IllegalArgumentException if the parent or the newNode is null, or if the parent is + * not part of this rewriter's AST, or the insertionPoint is not a child of the parent. */ - public final ASTRewrite insertBefore(IASTNode parent, IASTNode insertionPoint, IASTNode newNode, TextEditGroup editGroup) { + public final ASTRewrite insertBefore(IASTNode parent, IASTNode insertionPoint, IASTNode newNode, + TextEditGroup editGroup) { if (parent != fRoot) { checkBelongsToAST(parent); } @@ -180,8 +182,7 @@ public final class ASTRewrite { ASTModification mod; if (insertionPoint == null) { mod= new ASTModification(ModificationKind.APPEND_CHILD, parent, newNode, editGroup); - } - else { + } else { if (insertionPoint.getParent() != parent) { throw new IllegalArgumentException(); } @@ -192,12 +193,13 @@ public final class ASTRewrite { } /** - * Converts all modifications recorded by this rewriter into the change object required by the - * refactoring framework. + * Converts all modifications recorded by this rewriter into the change object required by + * the refactoring framework. *

* Calling this methods does not discard the modifications on record. Subsequence modifications * are added to the ones already on record. If this method is called again later, - * the resulting text edit object will accurately reflect the net cumulative affect of all those changes. + * the resulting text edit object will accurately reflect the net cumulative affect of all those + * changes. *

* * @return Change object describing the changes to the @@ -223,7 +225,7 @@ public final class ASTRewrite { private void checkSupportedNode(IASTNode node, Operation op) { if (node instanceof IASTComment) { - if(op != Operation.remove) { + if (op != Operation.remove) { throw new IllegalArgumentException("Rewriting comments is not yet supported"); //$NON-NLS-1$ } } @@ -235,13 +237,12 @@ public final class ASTRewrite { } } - /** * Assigns the comment to the node. * - * @param node - * @param comment - * @param pos + * @param node the node. + * @param comment the comment to be attached to the node at the given position. + * @param pos the position of the comment. * @since 5.3 */ public void addComment(IASTNode node, IASTComment comment, CommentPosition pos) { @@ -258,13 +259,10 @@ public final class ASTRewrite { } } - - /** + /** * - * @param node - * the node - * @param pos - * the position + * @param node the node + * @param pos the position * @return All comments assigned to the node at this position * @since 5.3 */ @@ -276,7 +274,6 @@ public final class ASTRewrite { return fCommentMap.getTrailingCommentsForNode(node); case freestanding: return fCommentMap.getFreestandingCommentsForNode(node); - } return fCommentMap.getLeadingCommentsForNode(node); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java index cb6f18fc722..a1cf9c71ee4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexFile.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation - * Andrew Ferguson (Symbian) + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) *******************************************************************************/ package org.eclipse.cdt.core.index; @@ -90,7 +90,7 @@ public interface IIndexFile { IIndexName[] findNames(int offset, int length) throws CoreException; /** - * Returns the include that was used to parse this file, may be null. + * Returns the include that was used to parse this file, may be null. */ IIndexInclude getParsedInContext() throws CoreException; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java index 6f3fa1bc4bf..d2725a244c4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.core.index; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; @@ -23,7 +22,6 @@ import org.eclipse.core.runtime.CoreException; * @noimplement This interface is not intended to be implemented by clients. */ public interface IIndexMacro extends IMacroBinding, IIndexBinding { - IIndexMacro[] EMPTY_INDEX_MACRO_ARRAY = new IIndexMacro[0]; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacroContainer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacroContainer.java index b974ac1e948..1704ba50a59 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacroContainer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacroContainer.java @@ -6,18 +6,17 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.index; /** - * Represents a binding for all macros with the same name. When you try to adapt a macro binding in an index - * you'll get the container as a result. + * Represents a binding for all macros with the same name. When you try to adapt a macro binding + * in an index you'll get the container as a result. * @since 5.0 * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IIndexMacroContainer extends IIndexBinding { - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java index 2e74509505f..567324b2ab7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTFieldDesignator.java @@ -13,14 +13,16 @@ package org.eclipse.cdt.internal.core.dom.parser.c; import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.IASTCompletionContext; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * Implementation of field designators */ -public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator { +public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator, IASTCompletionContext { private IASTName name; @@ -74,4 +76,8 @@ public class CASTFieldDesignator extends ASTNode implements ICASTFieldDesignator return true; } + + public IBinding[] findBindings(IASTName n, boolean isPrefix) { + return CVisitor.findBindingsForContentAssist(n, isPrefix); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java index 920ae596fd9..c3fb65a4489 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java @@ -607,25 +607,30 @@ public class CVisitor extends ASTQueries { } if (type != null && type instanceof ICompositeType) { + final ICompositeType ct = (ICompositeType) type; if (type instanceof IIndexBinding) { - type= ((CASTTranslationUnit) fieldReference.getTranslationUnit()).mapToASTType((ICompositeType) type); + type= ((CASTTranslationUnit) fieldReference.getTranslationUnit()).mapToASTType(ct); } if (prefix) { - IBinding[] result = null; char[] p = fieldReference.getFieldName().toCharArray(); - IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher(p); - IField[] fields = ((ICompositeType) type).getFields(); - for (IField field : fields) { - if (matcher.match(field.getNameCharArray())) { - result = (IBinding[]) ArrayUtil.append(IBinding.class, result, field); - } - } - return ArrayUtil.trim(IBinding.class, result); + return findFieldsByPrefix(ct, p); } - return ((ICompositeType) type).findField(fieldReference.getFieldName().toString()); + return ct.findField(fieldReference.getFieldName().toString()); } return null; } + + public static IBinding[] findFieldsByPrefix(final ICompositeType ct, char[] p) { + IBinding[] result = null; + IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher(p); + IField[] fields = ct.getFields(); + for (IField field : fields) { + if (matcher.match(field.getNameCharArray())) { + result = (IBinding[]) ArrayUtil.append(IBinding.class, result, field); + } + } + return (IBinding[]) ArrayUtil.trim(IBinding.class, result); + } static IType getPtrDiffType(IASTBinaryExpression expr) { IScope scope = getContainingScope(expr); @@ -1463,6 +1468,8 @@ public class CVisitor extends ASTQueries { if (prop == IASTFieldReference.FIELD_NAME) { result = (IBinding[]) findBinding((IASTFieldReference) name.getParent(), isPrefix); + } else if (prop == ICASTFieldDesignator.FIELD_NAME) { + result = findBindingForContentAssist((ICASTFieldDesignator) name.getParent(), isPrefix); } else { IScope scope= getContainingScope(name); try { @@ -1477,7 +1484,35 @@ public class CVisitor extends ASTQueries { return (IBinding[]) ArrayUtil.trim(IBinding.class, result); } - public static IBinding[] findBindings(IScope scope, String name) { + private static IBinding[] findBindingForContentAssist(ICASTFieldDesignator fd, boolean isPrefix) { + IASTNode blockItem = getContainingBlockItem(fd); + + IASTNode parent= blockItem; + while (parent != null && !(parent instanceof IASTSimpleDeclaration)) + parent= parent.getParent(); + + if (parent instanceof IASTSimpleDeclaration) { + IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) parent; + IBinding struct= null; + if (simpleDecl.getDeclSpecifier() instanceof IASTNamedTypeSpecifier) { + struct = ((IASTNamedTypeSpecifier) simpleDecl.getDeclSpecifier()).getName().resolveBinding(); + } else if (simpleDecl.getDeclSpecifier() instanceof IASTElaboratedTypeSpecifier) { + struct = ((IASTElaboratedTypeSpecifier) simpleDecl.getDeclSpecifier()).getName().resolveBinding(); + } else if (simpleDecl.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier) { + struct = ((IASTCompositeTypeSpecifier) simpleDecl.getDeclSpecifier()).getName().resolveBinding(); + } + if (struct instanceof IType) { + IType t= unwrapTypedefs((IType) struct); + + if (t instanceof ICompositeType) { + return findFieldsByPrefix((ICompositeType) t, fd.getName().toCharArray()); + } + } + } + return null; + } + + public static IBinding[] findBindings(IScope scope, String name) { CASTName astName = new CASTName(name.toCharArray()); // normal names diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java index 19c901da95a..cb269070476 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java @@ -177,18 +177,21 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { // in any way add the initializer such that the actual size can be tracked. result.addClause(clause); } else { - // Gnu extension: the assign operator is optional - if (LT(1) == IToken.tASSIGN) - consume(IToken.tASSIGN); - - IASTInitializerClause clause= initClause(false); - ICASTDesignatedInitializer desigInitializer = nodeFactory.newDesignatedInitializer(clause); + ICASTDesignatedInitializer desigInitializer = nodeFactory.newDesignatedInitializer((IASTInitializerClause) null); setRange(desigInitializer, designator.get(0)); - adjustLength(desigInitializer, clause); - for (ICASTDesignator d : designator) { desigInitializer.addDesignator(d); } + + if (LT(1) != IToken.tEOC) { + // Gnu extension: the assign operator is optional + if (LT(1) == IToken.tASSIGN) + consume(IToken.tASSIGN); + + IASTInitializerClause clause= initClause(false); + desigInitializer.setOperand(clause); + adjustLength(desigInitializer, clause); + } result.addClause(desigInitializer); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTModificationMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTModificationMap.java index 6085c977fad..ea35926d435 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTModificationMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTModificationMap.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite; @@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKind; /** - * 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 * in separate modification maps. I.e. a modification map represents one level of * modifications. @@ -28,51 +28,51 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification.ModificationKin * @since 5.0 */ public class ASTModificationMap { - - private HashMap> fModifications= new HashMap>(); + private HashMap> fModifications= new HashMap>(); /** * Adds a modification to this modification map. */ public void addModification(ASTModification mod) { - final IASTNode targetNode = mod.getKind()==ASTModification.ModificationKind.INSERT_BEFORE ? mod.getTargetNode().getParent() :mod.getTargetNode(); + final IASTNode targetNode = mod.getKind() == ASTModification.ModificationKind.INSERT_BEFORE ? + mod.getTargetNode().getParent() : mod.getTargetNode(); List mods= fModifications.get(targetNode); if (mods == null || mods.isEmpty()) { mods= new ArrayList(); mods.add(mod); fModifications.put(targetNode, mods); - } - else { + } else { switch (mod.getKind()) { case REPLACE: - if (mods.get(mods.size()-1).getKind() != ModificationKind.INSERT_BEFORE ) { + if (mods.get(mods.size() - 1).getKind() != ModificationKind.INSERT_BEFORE) { throw new IllegalArgumentException("Attempt to replace a node that has been modified"); //$NON-NLS-1$ } mods.add(mod); break; case APPEND_CHILD: - if (mods.get(mods.size()-1).getKind() == ModificationKind.REPLACE) { + if (mods.get(mods.size() - 1).getKind() == ModificationKind.REPLACE) { throw new IllegalArgumentException("Attempt to modify a node that has been replaced"); //$NON-NLS-1$ } mods.add(mod); break; case INSERT_BEFORE: int i; - for (i=mods.size()-1; i>=0; i--) { + for (i= mods.size(); --i >= 0;) { if (mods.get(i).getKind() == ModificationKind.INSERT_BEFORE) { break; } } - mods.add(i+1, mod); + mods.add(i + 1, mod); break; } } } /** - * Returns the list of modifications for a given node. The list can contain different modifications. - * It is guaranteed that INSERT_BEFORE modifications appear first. Furthermore, if there is a - * REPLACE modification the list will not contain any other REPLACE or APPEND_CHILD modifications. + * Returns the list of modifications for a given node. The list can contain different + * modifications. It is guaranteed that INSERT_BEFORE modifications appear first. Furthermore, + * if there is a REPLACE modification the list will not contain any other REPLACE or + * APPEND_CHILD modifications. * @return the modification list, which may be empty. */ public List getModificationsForNode(IASTNode node) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java index 700ccad2ee8..05ac5681685 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java @@ -195,8 +195,9 @@ public class ChangeGenerator extends ASTVisitor { createChange(synthNode, synthSource); - int newOffset = synthNode.getFileLocation().getNodeOffset() + synthNode.getFileLocation().getNodeLength(); - sourceOffsets.put(synthNode.getFileLocation().getFileName(), Integer.valueOf(newOffset)); + IASTFileLocation fileLocation = synthNode.getFileLocation(); + int newOffset = fileLocation.getNodeOffset() + fileLocation.getNodeLength(); + sourceOffsets.put(fileLocation.getFileName(), Integer.valueOf(newOffset)); } private void synthTreatment(IASTTranslationUnit synthTU) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java index 7a7a0b5b9bd..b08259e370c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java @@ -6,11 +6,11 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Andrew Ferguson (Symbian) - * Anton Leherbauer (Wind River Systems) - * IBM Corporation + * QNX - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) + * Anton Leherbauer (Wind River Systems) + * IBM Corporation *******************************************************************************/ package org.eclipse.cdt.internal.core.index; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/FileEncodingRegistry.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/FileEncodingRegistry.java index f5dbb40b252..5bb71551283 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/FileEncodingRegistry.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/indexer/FileEncodingRegistry.java @@ -39,11 +39,6 @@ public class FileEncodingRegistry implements Serializable { defaultEncoding = newDefaultEncoding; } - - public String getDefaultEncoding() { - return defaultEncoding; - } - public void registerFileEncoding(String filename, String encoding) { if(defaultEncoding.equals(encoding)){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java index 4687ae8fa83..a832728cba2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java @@ -6,10 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Anton Leherbauer (Wind River Systems) - * Markus Schorn (Wind River Systems) - * Sergey Prigogin (Google) + * IBM - Initial API and implementation + * Anton Leherbauer (Wind River Systems) + * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; @@ -63,11 +63,11 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { public static final String PROP_VALUE = "CPreprocessor"; //$NON-NLS-1$ public static final int tDEFINED= IToken.FIRST_RESERVED_PREPROCESSOR; - public static final int tEXPANDED_IDENTIFIER= IToken.FIRST_RESERVED_PREPROCESSOR+1; - public static final int tSCOPE_MARKER= IToken.FIRST_RESERVED_PREPROCESSOR+2; - public static final int tSPACE= IToken.FIRST_RESERVED_PREPROCESSOR+3; - public static final int tNOSPACE= IToken.FIRST_RESERVED_PREPROCESSOR+4; - public static final int tMACRO_PARAMETER= IToken.FIRST_RESERVED_PREPROCESSOR+5; + public static final int tEXPANDED_IDENTIFIER= IToken.FIRST_RESERVED_PREPROCESSOR + 1; + public static final int tSCOPE_MARKER= IToken.FIRST_RESERVED_PREPROCESSOR + 2; + public static final int tSPACE= IToken.FIRST_RESERVED_PREPROCESSOR + 3; + public static final int tNOSPACE= IToken.FIRST_RESERVED_PREPROCESSOR + 4; + public static final int tMACRO_PARAMETER= IToken.FIRST_RESERVED_PREPROCESSOR + 5; private static final int ORIGIN_PREPROCESSOR_DIRECTIVE = OffsetLimitReachedException.ORIGIN_PREPROCESSOR_DIRECTIVE; private static final int ORIGIN_INACTIVE_CODE = OffsetLimitReachedException.ORIGIN_INACTIVE_CODE; @@ -81,7 +81,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { private static final ObjectStyleMacro __cplusplus = new ObjectStyleMacro("__cplusplus".toCharArray(), ONE); //$NON-NLS-1$ private static final ObjectStyleMacro __STDC__ = new ObjectStyleMacro("__STDC__".toCharArray(), ONE); //$NON-NLS-1$ private static final ObjectStyleMacro __STDC_HOSTED__ = new ObjectStyleMacro("__STDC_HOSTED__".toCharArray(), ONE); //$NON-NLS-1$ - private static final ObjectStyleMacro __STDC_VERSION__ = new ObjectStyleMacro("__STDC_VERSION__".toCharArray(), "199901L".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$ + private static final ObjectStyleMacro __STDC_VERSION__ = + new ObjectStyleMacro("__STDC_VERSION__".toCharArray(), "199901L".toCharArray()); //$NON-NLS-1$ //$NON-NLS-2$ private static final DynamicMacro __FILE__= new FileMacro("__FILE__".toCharArray()); //$NON-NLS-1$ private static final DynamicMacro __DATE__= new DateMacro("__DATE__".toCharArray()); //$NON-NLS-1$ @@ -108,7 +109,11 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } }; - private static class IncludeResolution {String fLocation; boolean fHeuristic;} + private static class IncludeResolution { + String fLocation; + boolean fHeuristic; + } + final private IIncludeFileTester createPathTester= new IIncludeFileTester() { public IncludeResolution checkFile(String path, boolean isHeuristicMatch, IncludeSearchPathElement onPath) { if (fFileContentProvider.getInclusionExists(path)) { @@ -123,9 +128,11 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { private final class TokenSequence implements ITokenSequence { private final boolean fStopAtNewline; + TokenSequence(boolean stopAtNewline) { fStopAtNewline= stopAtNewline; } + public Token nextToken() throws OffsetLimitReachedException { final Lexer lexer= fCurrentContext.getLexer(); Token t= lexer.nextToken(); @@ -138,9 +145,11 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { return t; } + public int getLastEndOffset() { return fCurrentContext.getLexer().getLastEndOffset(); } + public Token currentToken() { Token t= fCurrentContext.currentLexerToken(); if (fStopAtNewline && t.getType() == Lexer.tNEWLINE) @@ -149,6 +158,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { return t; } } + TokenSequence fInputToMacroExpansion= new TokenSequence(false); TokenSequence fLineInputToMacroExpansion= new TokenSequence(true); @@ -191,9 +201,9 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { private InternalFileContent fRootContent; - - public CPreprocessor(FileContent fileContent, IScannerInfo info, ParserLanguage language, IParserLogService log, - IScannerExtensionConfiguration configuration, IncludeFileContentProvider readerFactory) { + public CPreprocessor(FileContent fileContent, IScannerInfo info, ParserLanguage language, + IParserLogService log, IScannerExtensionConfiguration configuration, + IncludeFileContentProvider readerFactory) { if (readerFactory instanceof InternalFileContentProvider) { fFileContentProvider= (InternalFileContentProvider) readerFactory; } else if (readerFactory == null) { @@ -320,7 +330,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { return ScannerUtility.createReconciledPath(directory.getAbsolutePath(), inlcudePath); } - private void setupMacroDictionary(IScannerExtensionConfiguration config, IScannerInfo info, ParserLanguage lang) { + private void setupMacroDictionary(IScannerExtensionConfiguration config, IScannerInfo info, + ParserLanguage lang) { // built in macros fMacroDictionary.put(__CDT_PARSER__.getNameCharArray(), __CDT_PARSER__); fMacroDictionary.put(__STDC__.getNameCharArray(), __STDC__); @@ -530,7 +541,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { Token t4= fetchToken(); end= t4.getEndOffset(); if (t4.getType() == IToken.tRPAREN) { - fLocationMap.encounterPragmaOperator(t1.getOffset(), t3.getOffset(), t3.getEndOffset(), t4.getEndOffset()); + fLocationMap.encounterPragmaOperator(t1.getOffset(), t3.getOffset(), + t3.getEndOffset(), t4.getEndOffset()); return; } else { end= t3.getEndOffset(); @@ -549,7 +561,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { end= t1.getEndOffset(); pushbackToken(t2); } - fLocationMap.encounterProblem(IProblem.PREPROCESSOR_INVALID_DIRECTIVE, t1.getCharImage(), t1.getOffset(), end); + fLocationMap.encounterProblem(IProblem.PREPROCESSOR_INVALID_DIRECTIVE, t1.getCharImage(), + t1.getOffset(), end); } /** @@ -591,7 +604,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { case IToken.tUTF32STRING: StringType st = StringType.fromToken(tt1); Token t2; - StringBuffer buf= null; + StringBuilder buf= null; int endOffset= 0; loop: while (true) { t2= fetchToken(); @@ -603,7 +616,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { case IToken.tUTF32STRING: st = StringType.max(st, StringType.fromToken(tt2)); if (buf == null) { - buf= new StringBuffer(); + buf= new StringBuilder(); appendStringContent(buf, t1); } appendStringContent(buf, t2); @@ -671,7 +684,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { return fCurrentContext.getCodeBranchNesting(); } - private void appendStringContent(StringBuffer buf, Token t1) { + private void appendStringContent(StringBuilder buf, Token t1) { final char[] image= t1.getCharImage(); final int length= image.length; int start = 1; @@ -689,7 +702,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } } - Token internalFetchToken(final ScannerContext uptoEndOfCtx, int options, boolean withinExpansion) throws OffsetLimitReachedException { + Token internalFetchToken(final ScannerContext uptoEndOfCtx, int options, boolean withinExpansion) + throws OffsetLimitReachedException { Token ppToken= fCurrentContext.currentLexerToken(); while (true) { switch (ppToken.getType()) { @@ -890,7 +904,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { continue loop; } } - for (int i=0; i', nameOffsets); condEndOffset= lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); break; - + case Lexer.tQUOTE_HEADER_NAME: headerName = extractHeaderName(header.getCharImage(), '"', '"', nameOffsets); condEndOffset= lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); @@ -1194,7 +1215,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { case IToken.tCOMPLETION: throw new OffsetLimitReachedException(ORIGIN_PREPROCESSOR_DIRECTIVE, header); - + case IToken.tIDENTIFIER: TokenList tl= new TokenList(); condEndOffset= nameOffsets[1]= getTokensWithinPPDirective(false, tl, false); @@ -1207,7 +1228,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { case IToken.tLT: userInclude= false; boolean complete= false; - StringBuffer buf= new StringBuffer(); + StringBuilder buf= new StringBuilder(); t= (Token) t.getNext(); while (t != null) { if (t.getType() == IToken.tGT) { @@ -1224,11 +1245,12 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } } break; - + default: condEndOffset= lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); break; } + if (headerName == null || headerName.length == 0) { if (active) { handleProblem(IProblem.PREPROCESSOR_INVALID_DIRECTIVE, @@ -1267,8 +1289,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { fAllIncludedFiles.add(path); ILocationCtx ctx= fLocationMap.pushInclusion(poundOffset, nameOffsets[0], nameOffsets[1], condEndOffset, source, path, headerName, userInclude, isHeuristic, fi.isSource()); - ScannerContext fctx= new ScannerContext(ctx, fCurrentContext, new Lexer(source, - fLexOptions, this, this)); + ScannerContext fctx= new ScannerContext(ctx, fCurrentContext, + new Lexer(source, fLexOptions, this, this)); fctx.setFoundOnPath(fi.getFoundOnPath(), includeDirective); fCurrentContext= fctx; } @@ -1292,7 +1314,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } if (!reported) { - fLocationMap.encounterPoundInclude(poundOffset, nameOffsets[0], nameOffsets[1], condEndOffset, headerName, path, userInclude, active, isHeuristic); + fLocationMap.encounterPoundInclude(poundOffset, nameOffsets[0], nameOffsets[1], + condEndOffset, headerName, path, userInclude, active, isHeuristic); } } @@ -1304,7 +1327,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { fLocationMap.skippedFile(fLocationMap.getSequenceNumberForOffset(offset), fi); } - private char[] extractHeaderName(final char[] image, final char startDelim, final char endDelim, int[] offsets) { + private char[] extractHeaderName(final char[] image, final char startDelim, final char endDelim, + int[] offsets) { char[] headerName; int start= 0; int length= image.length; @@ -1334,7 +1358,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } - private void executeDefine(final Lexer lexer, int startOffset, boolean isActive) throws OffsetLimitReachedException { + private void executeDefine(final Lexer lexer, int startOffset, boolean isActive) + throws OffsetLimitReachedException { try { ObjectStyleMacro macrodef = fMacroDefinitionParser.parseMacroDefinition(lexer, this); if (isActive) @@ -1349,7 +1374,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } } - private void executeUndefine(Lexer lexer, int startOffset, boolean isActive) throws OffsetLimitReachedException { + private void executeUndefine(Lexer lexer, int startOffset, boolean isActive) + throws OffsetLimitReachedException { final Token name= lexer.nextToken(); final int tt= name.getType(); if (tt != IToken.tIDENTIFIER) { @@ -1357,7 +1383,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { throw new OffsetLimitReachedException(ORIGIN_PREPROCESSOR_DIRECTIVE, name); } lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); - handleProblem(IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, name.getCharImage(), startOffset, name.getEndOffset()); + handleProblem(IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, name.getCharImage(), startOffset, + name.getEndOffset()); return; } lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); @@ -1369,10 +1396,12 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } else { definition= fMacroDictionary.get(namechars); } - fLocationMap.encounterPoundUndef(definition, startOffset, name.getOffset(), name.getEndOffset(), endOffset, namechars, isActive); + fLocationMap.encounterPoundUndef(definition, startOffset, name.getOffset(), + name.getEndOffset(), endOffset, namechars, isActive); } - private CodeState executeIfdef(Lexer lexer, int offset, boolean isIfndef, boolean withinExpansion) throws OffsetLimitReachedException { + private CodeState executeIfdef(Lexer lexer, int offset, boolean isIfndef, + boolean withinExpansion) throws OffsetLimitReachedException { final Token name= lexer.nextToken(); lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); final int tt= name.getType(); @@ -1413,7 +1442,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { return fCurrentContext.setBranchState(conditional, isTaken, withinExpansion, offset); } - private CodeState executeIf(Lexer lexer, int startOffset, boolean isElif, boolean withinExpansion) throws OffsetLimitReachedException { + private CodeState executeIf(Lexer lexer, int startOffset, boolean isElif, + boolean withinExpansion) throws OffsetLimitReachedException { Conditional cond= fCurrentContext.newBranch(isElif ? BranchKind.eElif : BranchKind.eIf, withinExpansion); if (cond == null) { char[] name= lexer.currentToken().getCharImage(); @@ -1476,7 +1506,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { return fCurrentContext.setBranchState(cond, isTaken, withinExpansion, startOffset); } - private CodeState executeEndif(Lexer lexer, int startOffset, boolean withinExpansion) throws OffsetLimitReachedException { + private CodeState executeEndif(Lexer lexer, int startOffset, boolean withinExpansion) + throws OffsetLimitReachedException { final int endOffset= lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); final Conditional cond= fCurrentContext.newBranch(BranchKind.eEnd, withinExpansion); if (cond == null) { @@ -1496,7 +1527,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { * converted to the defined-token and its argument is not macro expanded. * Returns the end-offset of the last token that was consumed. */ - private int getTokensWithinPPDirective(boolean isCondition, TokenList result, boolean withinExpansion) throws OffsetLimitReachedException { + private int getTokensWithinPPDirective(boolean isCondition, TokenList result, + boolean withinExpansion) throws OffsetLimitReachedException { final ScannerContext scannerCtx= fCurrentContext; scannerCtx.clearInactiveCodeMarkerToken(); int options= STOP_AT_NL; @@ -1530,14 +1562,16 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { return scannerCtx.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); } - private void skipOverConditionalCode(final Lexer lexer, boolean withinExpansion) throws OffsetLimitReachedException { + private void skipOverConditionalCode(final Lexer lexer, boolean withinExpansion) + throws OffsetLimitReachedException { CodeState state= CodeState.eSkipInactive; while (state == CodeState.eSkipInactive) { state= skipBranch(lexer, withinExpansion); } } - private CodeState skipBranch(final Lexer lexer, boolean withinExpansion) throws OffsetLimitReachedException { + private CodeState skipBranch(final Lexer lexer, boolean withinExpansion) + throws OffsetLimitReachedException { while (true) { final Token pound = lexer.nextDirective(); int tt = pound.getType(); @@ -1603,7 +1637,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { * @param isPPCondition whether the expansion is inside of a preprocessor condition. This * implies a specific handling for the defined token. */ - private boolean expandMacro(final Token identifier, Lexer lexer, int options, boolean withinExpansion) throws OffsetLimitReachedException { + private boolean expandMacro(final Token identifier, Lexer lexer, int options, + boolean withinExpansion) throws OffsetLimitReachedException { final char[] name= identifier.getCharImage(); PreprocessorMacro macro= fMacroDictionary.get(name); if (macro == null) { @@ -1625,13 +1660,15 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { final ITokenSequence input= stopAtNewline ? fLineInputToMacroExpansion : fInputToMacroExpansion; final MacroExpander expander = withinExpansion ? new MacroExpander(this, fMacroDictionary, fLocationMap, fLexOptions) : fMacroExpander; - TokenList replacement= expander.expand(input, (options & PROTECT_DEFINED) != 0, macro, identifier, contentAssist); + TokenList replacement= expander.expand(input, (options & PROTECT_DEFINED) != 0, macro, + identifier, contentAssist); final IASTName[] expansions= expander.clearImplicitExpansions(); final ImageLocationInfo[] ili= expander.clearImageLocationInfos(); final Token last= replacement.last(); final int length= last == null ? 0 : last.getEndOffset(); ILocationCtx ctx= fLocationMap.pushMacroExpansion( - identifier.getOffset(), identifier.getEndOffset(), lexer.getLastEndOffset(), length, macro, expansions, ili); + identifier.getOffset(), identifier.getEndOffset(), lexer.getLastEndOffset(), length, + macro, expansions, ili); fCurrentContext= new ScannerContext(ctx, fCurrentContext, replacement); return true; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java index c28dc01eb15..17c9e046bd3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; @@ -21,7 +21,6 @@ import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.Inclusio * Internal implementation of the file content providers */ public abstract class InternalFileContentProvider extends IncludeFileContentProvider { - private IIncludeFileResolutionHeuristics fIncludeResolutionHeuristics; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java index 63d82f34602..b032956b7d8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; @@ -22,14 +22,17 @@ import org.eclipse.cdt.core.parser.OffsetLimitReachedException; final class ScannerContext { enum BranchKind {eIf, eElif, eElse, eEnd} enum CodeState {eActive, eParseInactive, eSkipInactive} + final static class Conditional { private final CodeState fInitialState; private BranchKind fLast; private boolean fTakeElse= true; + Conditional(CodeState state) { fInitialState= state; fLast= BranchKind.eIf; } + boolean canHaveActiveBranch(boolean withinExpansion) { return fTakeElse && isActive(withinExpansion); } @@ -174,12 +177,12 @@ final class ScannerContext { private int getOldNestingLevel(BranchKind kind, int nesting) { switch (kind) { case eIf: - return nesting-1; + return nesting - 1; case eElif: case eElse: return nesting; case eEnd: - return nesting+1; + return nesting + 1; } return nesting; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java index fc09ec08f72..ebf5eda9383 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java @@ -26,7 +26,6 @@ import org.eclipse.core.runtime.CoreException; * @author Doug Schaefer */ public class LongString implements IString { - private final Database db; private final long record; private int hash; @@ -370,7 +369,7 @@ public class LongString implements IString { public String getString() throws CoreException { int length = db.getInt(record + LENGTH); - final StringBuffer buffer = new StringBuffer(length); + final StringBuilder buffer = new StringBuilder(length); readChars(length, new IReader() { public void appendChar(char c) { buffer.append(c); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java index 40c4f3a2fb9..b07ec958d12 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java @@ -10,7 +10,6 @@ * Andrew Ferguson (Symbian) * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.core.pdom.db; import org.eclipse.cdt.core.CCorePlugin; @@ -22,7 +21,6 @@ import org.eclipse.core.runtime.CoreException; * @author Doug Schaefer */ public class ShortString implements IString { - private final Database db; private final long record; private int hash; @@ -77,7 +75,7 @@ public class ShortString implements IString { Chunk chunk = db.getChunk(record); int length = chunk.getInt(record + LENGTH); char[] chars = new char[length]; - chunk.getCharArray(record+CHARS, chars); + chunk.getCharArray(record + CHARS, chars); return chars; } @@ -89,13 +87,13 @@ public class ShortString implements IString { public boolean equals(Object obj) { if (obj == this) return true; - + try { if (obj instanceof ShortString) { ShortString string = (ShortString)obj; if (db == string.db && record == string.record) return true; - + Chunk chunk1 = db.getChunk(record); Chunk chunk2 = string.db.getChunk(string.record); @@ -185,7 +183,7 @@ public class ShortString implements IString { while (i1 < n1 && i2 < n2) { int cmp= compareChars(chunk.getChar(i1), other[i2], caseSensitive); - if(cmp!=0) + if (cmp != 0) return cmp; i1 += 2; @@ -220,7 +218,7 @@ public class ShortString implements IString { while (i1 < n1 && i2 < n2) { int cmp= compareChars(chunk1.getChar(i1), chunk2.getChar(i2), caseSensitive); - if(cmp!=0) + if (cmp != 0) return cmp; i1 += 2; @@ -245,7 +243,7 @@ public class ShortString implements IString { while (i1 < n1 && i2 < n2) { int cmp= compareChars(chunk.getChar(i1), other.charAt(i2), caseSensitive); - if(cmp!=0) + if (cmp != 0) return cmp; i1 += 2; @@ -259,7 +257,6 @@ public class ShortString implements IString { else return 0; } - public int compareCompatibleWithIgnoreCase(IString string) throws CoreException { if (string instanceof ShortString) @@ -269,7 +266,6 @@ public class ShortString implements IString { else throw new IllegalArgumentException(); } - public int compareCompatibleWithIgnoreCase(ShortString other) throws CoreException { Chunk chunk1 = db.getChunk(record); @@ -285,7 +281,7 @@ public class ShortString implements IString { final char c2= chunk2.getChar(i2); if (c1 != c2) { int cmp= compareChars(c1, c2, false); // insensitive - if(cmp!=0) + if (cmp != 0) return cmp; if (sensitiveCmp == 0) { @@ -323,7 +319,7 @@ public class ShortString implements IString { final char c2= chars[i2]; if (c1 != c2) { int cmp= compareChars(c1, c2, false); // insensitive - if(cmp!=0) + if (cmp != 0) return cmp; if (sensitiveCmp == 0) { @@ -358,7 +354,7 @@ public class ShortString implements IString { while (i1 < n1 && i2 < n2) { int cmp= compareChars(chunk.getChar(i1), other[i2], caseSensitive); - if(cmp!=0) + if (cmp != 0) return cmp; i1 += 2; @@ -372,7 +368,7 @@ public class ShortString implements IString { } public char charAt(int i) throws CoreException { - long ptr = record + CHARS + (i*2); + long ptr = record + CHARS + (i * 2); return db.getChar(ptr); } @@ -395,7 +391,7 @@ public class ShortString implements IString { * */ public static int compareChars(char a, char b, boolean caseSensitive) { - if(caseSensitive) { + if (caseSensitive) { if (a < b) return -1; if (a > b) @@ -417,7 +413,7 @@ public class ShortString implements IString { * benchmark first. * * public static int compareChars(char a, char b, boolean caseSensitive) { - if(caseSensitive) { + if (caseSensitive) { if (a < b) return -1; if (a > b) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java index e02713c5426..f8368489476 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMFile.java @@ -6,10 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Andrew Ferguson (Symbian) - * Sergey Prigogin (Google) + * QNX - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom; @@ -607,8 +607,8 @@ public class PDOMFile implements IIndexFragmentFile { if (nameOffset + name.getNodeLength() <= offset + length) { result.add(name); } else if (name.isReference()) { - // names are ordered, but callers are inserted before - // their references + // Names are ordered, but callers are inserted before + // their references. break; } } @@ -640,23 +640,22 @@ public class PDOMFile implements IIndexFragmentFile { return result.toArray(new IIndexName[result.size()]); } - public static PDOMFile findFile(PDOMLinkage linkage, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy) - throws CoreException { + public static PDOMFile findFile(PDOMLinkage linkage, BTree btree, IIndexFileLocation location, + IIndexLocationConverter strategy) throws CoreException { String internalRepresentation= strategy.toInternalFormat(location); - long record= 0; if (internalRepresentation != null) { Finder finder = new Finder(linkage.getDB(), internalRepresentation, linkage.getLinkageID()); btree.accept(finder); - record= finder.getRecord(); - } - if (record != 0) { - return new PDOMFile(linkage, record); + long record= finder.getRecord(); + if (record != 0) { + return new PDOMFile(linkage, record); + } } return null; } - public static IIndexFragmentFile[] findFiles(PDOM pdom, BTree btree, IIndexFileLocation location, IIndexLocationConverter strategy) - throws CoreException { + public static IIndexFragmentFile[] findFiles(PDOM pdom, BTree btree, IIndexFileLocation location, + IIndexLocationConverter strategy) throws CoreException { String internalRepresentation= strategy.toInternalFormat(location); if (internalRepresentation != null) { Finder finder = new Finder(pdom.getDB(), internalRepresentation, -1); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java index c9d7444f1d7..1a13e1a13e5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java @@ -6,10 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * QNX - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Andrew Ferguson (Symbian) - * Sergey Prigogin (Google) + * QNX - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom; @@ -138,7 +138,6 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation { if (nextName != null) nextName.setPrevInContainer(prevName); - final IString expansion = getExpansionInDB(); if (expansion != null) { expansion.delete(); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java index f1d0fa7e9a5..9e1125e38c6 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 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 @@ -564,9 +564,19 @@ outer: */ public void generateExternalMarker(IResource file, int lineNumber, String desc, int severity, String varName, IPath externalPath) { ProblemMarkerInfo problemMarkerInfo = new ProblemMarkerInfo(file, lineNumber, desc, severity, varName, externalPath); + this.addProblemMarker(problemMarkerInfo); + } + + /** + * Add the given marker to the list of error markers. + * + * @param problemMarkerInfo - The marker to be added. + * @since 5.4 + */ + public void addProblemMarker(ProblemMarkerInfo problemMarkerInfo){ fErrors.add(problemMarkerInfo); fMarkerGenerator.addMarker(problemMarkerInfo); - if (severity == IMarkerGenerator.SEVERITY_ERROR_RESOURCE) + if (problemMarkerInfo.severity == IMarkerGenerator.SEVERITY_ERROR_RESOURCE) hasErrors = true; } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ProblemMarkerInfo.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ProblemMarkerInfo.java index e89a04aa958..b33287aac0f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ProblemMarkerInfo.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ProblemMarkerInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Siemens AG. + * Copyright (c) 2006, 2011 Siemens AG and others. * All rights reserved. This content 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 @@ -7,14 +7,27 @@ * * Contributors: * Norbert Ploett - Initial implementation + * Sami Wagiaalla (Red Hat) - Bug 352166: Added attributes and type API + * and improved documentation. *******************************************************************************/ package org.eclipse.cdt.core; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.cdt.core.resources.ACBuilder; +import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; /** + * {@code ProblemMarkerInfo} is an object used to pass error properties to {@link ErrorParserManager}. + * The information stored in this object will later be used to create an {@link IMarker} by {@link ACBuilder} + * @see ErrorParserManager#addProblemMarker(ProblemMarkerInfo) + * @see ErrorParserManager#generateMarker(IResource, int, String, int, String) + * @see ErrorParserManager#generateExternalMarker(IResource, int, String, int, String, IPath) + * * @noextend This class is not intended to be subclassed by clients. */ public class ProblemMarkerInfo { @@ -25,25 +38,98 @@ public class ProblemMarkerInfo { public int severity; public String variableName; public IPath externalPath ; + private Map attributes; + private String type; - public ProblemMarkerInfo(IResource file, int lineNumber, String desciption, int severity, String variableName) { - this.file = file; - this.lineNumber = lineNumber; - this.description = desciption; - this.severity = severity; - this.variableName = variableName; - this.externalPath = null ; - } - - - public ProblemMarkerInfo(IResource file, int lineNumber, String description, int severity, String variableName, IPath externalPath) { - super(); + /** + * Create a new {@link ProblemMarkerInfo} object. + * + * @param file - the file where the problem has occurred. + * @param lineNumber - the line number of the problem. + * @param description - a description of the problem. + * @param severity - the severity of the problem, see {@link IMarkerGenerator} + * for acceptable severity values. + * @param variableName - the name of the variable involved in the error if any. + */ + public ProblemMarkerInfo(IResource file, int lineNumber, String description, int severity, String variableName) { this.file = file; this.lineNumber = lineNumber; this.description = description; this.severity = severity; this.variableName = variableName; + this.externalPath = null ; + this.type = null; + this.attributes = new HashMap(); + } + + /** + * Create a new {@link ProblemMarkerInfo} object. + * + * @param file - the file where the problem has occurred. + * @param lineNumber - the line number of the problem. + * @param description - a description of the problem. + * @param severity - the severity of the problem, see {@link IMarkerGenerator} + * for acceptable severity values + * @param variableName - the name of the variable involved in the error if any. + * @param externalPath - if this error involves a file outside the workspace this parameter should + * contain the path to that file. + */ + public ProblemMarkerInfo(IResource file, int lineNumber, String description, int severity, String variableName, IPath externalPath) { + this(file, lineNumber, description, severity, variableName); this.externalPath = externalPath; } + /** + * Get the attribute map. + * @return Map of attributes and their values. + * @since 5.4 + */ + public Map getAttributes(){ + return this.attributes; + } + + /** + * Return the value of the attribute with the given key, + * or null if no such attribute exists. + * + * @param key - attribute key. + * @return attribute value + * @since 5.4 + */ + public String getAttribute(String key){ + return this.attributes.get(key); + } + + /** + * Set the value of the attribute with the given key + * to the given value, or add one if one does not already + * exist. + * + * @param key - attribute key. + * @param value - new attribute value. + * @since 5.4 + */ + public void setAttribute(String key, String value){ + this.attributes.put(key, value); + } + + /** + * Return the type of this problem marker or null + * if type was not set. + * @return the type. + * @since 5.4 + */ + public String getType() { + return this.type; + } + + /** + * Set the type of this problem marker. + * + * @param type - the new type. + * @since 5.4 + */ + public void setType(String type){ + this.type = type; + } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java index d7569f64213..48e34fbf771 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/ACBuilder.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.core.resources; import java.net.URI; import java.util.Map; +import java.util.Map.Entry; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePreferenceConstants; @@ -85,7 +86,11 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa } } - IMarker marker = markerResource.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER); + String type = problemMarkerInfo.getType(); + if (type == null) + type = ICModelMarker.C_MODEL_PROBLEM_MARKER; + + IMarker marker = markerResource.createMarker(type); marker.setAttribute(IMarker.MESSAGE, problemMarkerInfo.description); marker.setAttribute(IMarker.SEVERITY, mapMarkerSeverity(problemMarkerInfo.severity)); marker.setAttribute(IMarker.LINE_NUMBER, problemMarkerInfo.lineNumber); @@ -105,6 +110,14 @@ public abstract class ACBuilder extends IncrementalProjectBuilder implements IMa } else if (problemMarkerInfo.lineNumber==0){ marker.setAttribute(IMarker.LOCATION, " "); //$NON-NLS-1$ } + + // Add all other client defined attributes. + Map attributes = problemMarkerInfo.getAttributes(); + if (attributes != null){ + for (Entry entry : attributes.entrySet()) { + marker.setAttribute(entry.getKey(), entry.getValue()); + } + } } catch (CoreException e) { CCorePlugin.log(e.getStatus()); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java index a06323d54d5..12a08dbb697 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 QNX Software Systems and others. + * Copyright (c) 2000, 2011 QNX Software Systems 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 @@ -178,6 +178,10 @@ public class CCodeFormatter extends CodeFormatter { ParserUtil.getParserLogService()); CodeFormatterVisitor codeFormatter = new CodeFormatterVisitor(preferences, offset, length); edit= codeFormatter.format(source, ast); + IStatus status= codeFormatter.getStatus(); + if (!status.isOK()) { + CCorePlugin.log(status); + } } catch (CoreException e) { throw new AbortFormatting(e); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index 376a6137c40..e93c0e53547 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -1603,8 +1603,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, private int visit(IASTArrayDeclarator node) { IASTArrayModifier[] arrayModifiers= node.getArrayModifiers(); if (arrayModifiers != null) { - for (IASTArrayModifier arrayModifier2 : arrayModifiers) { - IASTArrayModifier arrayModifier = arrayModifier2; + for (IASTArrayModifier arrayModifier : arrayModifiers) { scribe.printNextToken(Token.tLBRACKET, preferences.insert_space_before_opening_bracket); boolean emptyBrackets= arrayModifier.getConstantExpression() == null && !(arrayModifier instanceof ICASTArrayModifier); @@ -1625,10 +1624,13 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, scribe.space(); } } + Runnable tailFormatter = scribe.takeTailFormatter(); try { arrayModifier.accept(this); } catch (ASTProblemException e) { scribe.skipToToken(Token.tRBRACKET); + } finally { + scribe.setTailFormatter(tailFormatter); } boolean insertSpace= emptyBrackets ? preferences.insert_space_between_empty_brackets : @@ -1772,7 +1774,9 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, // Consider macro expansion if (withinMacroExpansion(node, scribe.scanner.getCurrentPosition())) { + scribe.printNextToken(peekNextToken()); continueNode(node); + if (scribe.printComment()) scribe.space(); } switch (node.getKey()) { @@ -1823,7 +1827,9 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, // Consider macro expansion if (withinMacroExpansion(node, scribe.scanner.getCurrentPosition())) { + scribe.printNextToken(peekNextToken()); continueNode(node); + if (scribe.printComment()) scribe.space(); } switch (node.getKey()) { @@ -2078,7 +2084,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, int i; for (i = 0; i < elementsLength; i++) { final IASTNode node= elements.get(i); - if (i < alignment.fragmentCount - 1) { + if (i < elementsLength - 1) { scribe.setTailFormatter( new TrailingTokenFormatter(options.fSeparatorToken, options.fSpaceBeforeSeparator, @@ -2093,7 +2099,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } else { node.accept(this); } - if (i < alignment.fragmentCount - 1) { + if (i < elementsLength - 1) { scribe.runTailFormatter(); } } @@ -2366,7 +2372,12 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, if (preferences.insert_space_after_opening_paren_in_method_invocation) { scribe.space(); } - node.getOperand().accept(this); + Runnable tailFormatter = scribe.takeTailFormatter(); + try { + node.getOperand().accept(this); + } finally { + scribe.setTailFormatter(tailFormatter); + } scribe.printNextToken(Token.tRPAREN, preferences.insert_space_before_closing_paren_in_method_invocation); break; default: @@ -2595,7 +2606,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, return formatOverloadedLeftShiftChain(node); } - Runnable tailFormatter = scribe.takeTailFormatter(); + Runnable tailFormatter = endsWithMacroExpansion(node) ? null : scribe.takeTailFormatter(); Alignment expressionAlignment= scribe.createAlignment( Alignment.BINARY_EXPRESSION, @@ -3132,11 +3143,18 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, formatLeftCurlyBrace(line, preferences.brace_position_for_block); if (startNode(body)) { try { + final boolean braceOnSameLine = DefaultCodeFormatterConstants.END_OF_LINE.equals(preferences.brace_position_for_block); + if (!braceOnSameLine) { + ok = true; + scribe.exitAlignment(alignment, true); + } formatBlockOpening((IASTCompoundStatement) body, preferences.brace_position_for_block, preferences.insert_space_before_opening_brace_in_block); - ok = true; - scribe.exitAlignment(alignment, true); + if (braceOnSameLine) { + ok = true; + scribe.exitAlignment(alignment, true); + } formatOpenedBlock((IASTCompoundStatement) body, preferences.brace_position_for_block, preferences.indent_statements_compare_to_block); @@ -3300,7 +3318,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } - if (elseStatement instanceof IASTCompoundStatement) { + if (elseStatement instanceof IASTCompoundStatement && !enclosedInMacroExpansion(elseStatement)) { elseStatement.accept(this); } else if (elseStatement instanceof IASTIfStatement) { if (!preferences.compact_else_if) { @@ -3805,8 +3823,13 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, if (preferences.insert_space_after_opening_paren_in_parenthesized_expression ) { scribe.space(); } - if (operand != null) { - operand.accept(this); + Runnable tailFormatter = scribe.takeTailFormatter(); + try { + if (operand != null) { + operand.accept(this); + } + } finally { + scribe.setTailFormatter(tailFormatter); } if (peekNextToken() != Token.tRPAREN) { if (!enclosedInMacroExpansion(operand)) { @@ -3883,22 +3906,22 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } private static boolean withinMacroExpansion(IASTNode node, int offset) { + IASTFileLocation loc = node.getFileLocation(); + if (loc == null || offset < loc.getNodeOffset() || offset >= loc.getNodeOffset() + loc.getNodeLength()) { + return false; + } IASTNodeLocation[] locations= node.getNodeLocations(); for (IASTNodeLocation location : locations) { - if (location instanceof IASTMacroExpansionLocation) { - IASTFileLocation fileLocation = location.asFileLocation(); - if (fileLocation != null) { - final int nodeOffset = fileLocation.getNodeOffset(); - final int endOffset = nodeOffset + fileLocation.getNodeLength(); - if (offset >= nodeOffset && offset < endOffset) { - return true; - } else if (offset < nodeOffset) { - return false; - } + IASTFileLocation fileLocation = location.asFileLocation(); + if (fileLocation != null) { + final int nodeOffset = fileLocation.getNodeOffset(); + final int endOffset = nodeOffset + fileLocation.getNodeLength(); + if (offset >= nodeOffset && offset < endOffset) { + return location instanceof IASTMacroExpansionLocation; } } } - return false; + return true; } private static boolean doNodeLocationsOverlap(IASTNode node1, IASTNode node2) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java index 05ee63739b6..e536b53d38f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 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 @@ -800,7 +800,7 @@ public class SimpleScanner { private void getRestOfPreprocessorLine() { int c = getChar(); while (true) { - while ((c != '\n') && (c != '\r') && (c != '/') && (c != EOFCHAR)) { + while ((c != '\n') && (c != '\r') && (c != '/') && (c != '"') && (c != EOFCHAR)) { c = getChar(); } if (c == '/') { @@ -823,6 +823,9 @@ public class SimpleScanner { c = next; continue; } + } else if (c == '"') { + matchStringLiteral(); + c = getChar(); } else { ungetChar(c); break; diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java index 60fc7e4b295..f996e5e26c3 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/XmlUtil.java @@ -16,7 +16,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.net.URI; import javax.xml.parsers.DocumentBuilder; @@ -266,8 +265,6 @@ public class XmlUtil { if (!storeFile.exists()) { storeFile.createNewFile(); } - OutputStream fileStream = new FileOutputStream(storeFile); - TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ @@ -279,7 +276,7 @@ public class XmlUtil { StreamResult result = new StreamResult(new FileOutputStream(storeFile)); transformer.transform(source, result); - fileStream.close(); + result.getOutputStream().close(); ResourcesUtil.refreshWorkspaceFiles(uriLocation); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java index db6c06fa122..56a7a7f0349 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java @@ -101,8 +101,9 @@ public class BaseUITestCase extends BaseTestCase { * Reads multiple sections in comments from the source of the given class. * @since 4.0 */ - public StringBuffer[] getContentsForTest(int sections) throws IOException { - return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "ui", getClass(), getName(), sections); + public StringBuilder[] getContentsForTest(int sections) throws IOException { + return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "ui", + getClass(), getName(), sections); } public String getAboveComment() throws IOException { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java index 978c7845f92..63e62bd3661 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/BasicCallHierarchyTest.java @@ -551,7 +551,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { // sf(); // } public void testStaticFunctionsC() throws Exception { - StringBuffer[] sbs= getContentsForTest(2); + StringBuilder[] sbs= getContentsForTest(2); String content2= sbs[0].toString(); String content1= content2 + sbs[1].toString(); IFile file1= createFile(getProject(), "staticFunc1.c", content1); @@ -620,7 +620,7 @@ public class BasicCallHierarchyTest extends CallHierarchyBaseTest { // sf(); // } public void testStaticFunctionsCpp() throws Exception { - StringBuffer[] sbs= getContentsForTest(2); + StringBuilder[] sbs= getContentsForTest(2); String content2= sbs[0].toString(); String content1= content2 + sbs[1].toString(); IFile file1= createFile(getProject(), "staticFunc1.cpp", content1); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java index 3239e634aac..fc4e9f8c776 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyAcrossProjectsTest.java @@ -82,7 +82,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { // n->inline_method(); // r3 // } public void testMethods() throws Exception { - StringBuffer[] content= getContentsForTest(2); + StringBuilder[] content= getContentsForTest(2); String header= content[0].toString(); String source = content[1].toString(); IFile headerFile= createFile(fCProject.getProject(), "testMethods.h", header); @@ -155,7 +155,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { // method3(); // } public void testMethodsInMultipleFiles() throws Exception { - StringBuffer[] content= getContentsForTest(3); + StringBuilder[] content= getContentsForTest(3); String header= content[0].toString(); String source1 = content[1].toString(); String source2 = content[2].toString(); @@ -205,7 +205,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { // method3(); // } public void testMultipleImplsForMethod() throws Exception { - StringBuffer[] content= getContentsForTest(3); + StringBuilder[] content= getContentsForTest(3); String header= content[0].toString(); String source1 = content[1].toString(); String source2 = content[2].toString(); @@ -266,7 +266,7 @@ public class CallHierarchyAcrossProjectsTest extends CallHierarchyBaseTest { // mc.method1(); // } public void testReverseMultipleImplsForMethod() throws Exception { - StringBuffer[] content= getContentsForTest(3); + StringBuilder[] content= getContentsForTest(3); String header= content[0].toString(); String source1 = content[1].toString(); String source2 = content[2].toString(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java index c05f12fd540..9e760ff2735 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java @@ -54,7 +54,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { // field= 1; // } public void testCallHierarchyFromOutlineView_183941() throws Exception { - StringBuffer[] contents = getContentsForTest(2); + StringBuilder[] contents = getContentsForTest(2); IFile file1= createFile(getProject(), "SomeClass.h", contents[0].toString()); IFile file2= createFile(getProject(), "SomeClass.cpp", contents[1].toString()); waitForIndexer(fIndex, file2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); @@ -95,7 +95,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { // ref2= 0; // } public void testCallHierarchyFromOutlineViewAmbiguous_183941() throws Exception { - StringBuffer[] contents = getContentsForTest(2); + StringBuilder[] contents = getContentsForTest(2); IFile file1= createFile(getProject(), "SomeClass.h", contents[0].toString()); IFile file2= createFile(getProject(), "SomeClass.cpp", contents[1].toString()); waitForIndexer(fIndex, file2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); @@ -363,7 +363,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { // shared_func(); // } public void testMultiLanguageWithPrototype_260262() throws Exception { - final StringBuffer[] contents = getContentsForTest(3); + final StringBuilder[] contents = getContentsForTest(3); final String hcontent = contents[0].toString(); final String content_inc = contents[1].toString(); final String content_full = content_inc + contents[2].toString(); @@ -393,7 +393,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { // shared_func(); // } public void testMultiLanguageWithInlinedfunc_260262() throws Exception { - final StringBuffer[] contents = getContentsForTest(3); + final StringBuilder[] contents = getContentsForTest(3); final String hcontent = contents[0].toString(); final String content_inc = contents[1].toString(); final String content_full = content_inc + contents[2].toString(); @@ -425,7 +425,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { // return 0; // } public void testUnnamedNamespace_283679() throws Exception { - final StringBuffer[] contents = getContentsForTest(1); + final StringBuilder[] contents = getContentsForTest(1); final String content = contents[0].toString(); IFile f2= createFile(getProject(), "testUnnamedNamespace_283679.cpp", content); waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); @@ -460,7 +460,7 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { // delete dbPtr; // } public void testCallsToFromVirtualMethod_246064() throws Exception { - final StringBuffer[] contents = getContentsForTest(1); + final StringBuilder[] contents = getContentsForTest(1); final String content = contents[0].toString(); IFile f2= createFile(getProject(), "testCallsToFromVirtualMethod_246064.cpp", content); waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java index 43a8c414ae9..f97fe728d90 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CppCallHierarchyTest.java @@ -57,7 +57,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { // n->inline_method(); // r3 // } public void testMethods() throws Exception { - StringBuffer[] content= getContentsForTest(2); + CharSequence[] content= getContentsForTest(2); String header= content[0].toString(); String source = content[1].toString(); IFile headerFile= createFile(getProject(), "testMethods.h", header); @@ -127,7 +127,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { // method3(); // } public void testMethodsInMultipleFiles() throws Exception { - StringBuffer[] content= getContentsForTest(3); + CharSequence[] content= getContentsForTest(3); String header= content[0].toString(); String source1 = content[1].toString(); String source2 = content[2].toString(); @@ -177,7 +177,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { // method3(); // } public void testMultipleImplsForMethod() throws Exception { - StringBuffer[] content= getContentsForTest(3); + CharSequence[] content= getContentsForTest(3); String header= content[0].toString(); String source1 = content[1].toString(); String source2 = content[2].toString(); @@ -237,7 +237,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { // mc.method1(); // } public void testReverseMultipleImplsForMethod() throws Exception { - StringBuffer[] content= getContentsForTest(3); + CharSequence[] content= getContentsForTest(3); String header= content[0].toString(); String source1 = content[1].toString(); String source2 = content[2].toString(); @@ -294,7 +294,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { // cxcpp(); // } public void testCPPCallsC() throws Exception { - StringBuffer[] content= getContentsForTest(2); + CharSequence[] content= getContentsForTest(2); String cSource= content[0].toString(); String cppSource = content[1].toString(); IFile cFile= createFile(getProject(), "s.c", cSource); @@ -339,7 +339,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { // cppfunc(); // }} public void testCCallsCPP() throws Exception { - StringBuffer[] content= getContentsForTest(2); + CharSequence[] content= getContentsForTest(2); String cSource= content[0].toString(); String cppSource = content[1].toString(); IFile cFile= createFile(getProject(), "s.c", cSource); @@ -411,7 +411,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { // f('1'); // } public void testTemplates() throws Exception { - StringBuffer[] content= getContentsForTest(1); + CharSequence[] content= getContentsForTest(1); String source = content[0].toString(); IFile file= createFile(getProject(), "testTemplates.cpp", source); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); @@ -475,7 +475,7 @@ public class CppCallHierarchyTest extends CallHierarchyBaseTest { // []{c();}(); // } public void testClosures_316307() throws Exception { - StringBuffer[] content= getContentsForTest(1); + CharSequence[] content= getContentsForTest(1); String source = content[0].toString(); IFile file= createFile(getProject(), "testClosures.cpp", source); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java index dfe4dc7eb1b..a4785eddcb2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java @@ -42,7 +42,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest { public void testSimpleInclusion() throws Exception { TestScannerProvider.sIncludes= new String[]{getProject().getProject().getLocation().toOSString()}; - StringBuffer[] contents= getContentsForTest(1); + StringBuilder[] contents= getContentsForTest(1); IProject project= getProject().getProject(); IFile user= createFile(project, "user.h", ""); IFile system= createFile(project, "system.h", ""); @@ -76,7 +76,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest { TestScannerProvider.sIncludes= new String[]{op.getProject().getLocation().toOSString()}; - StringBuffer[] contents= getContentsForTest(1); + StringBuilder[] contents= getContentsForTest(1); IFile user= createFile(op.getProject(), "user.h", ""); IFile system= createFile(op.getProject(), "system.h", ""); IFile source= createFile(getProject().getProject(), "source.cpp", contents[0].toString()); @@ -98,8 +98,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest { checkTreeNode(tree, 0, "system.h"); checkTreeNode(tree, 0, 0, "source.cpp"); - } - finally { + } finally { CProjectHelper.delete(op); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java index 6f32fa976bc..234a9bdec95 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java @@ -95,7 +95,7 @@ public class BasicOutlineTest extends BaseUITestCase { //#define MACRO2() //int main(int argc, char** argv) {} public void testSimpleOutlineContent() throws Exception { - StringBuffer[] contents= getContentsForTest(1); + StringBuilder[] contents= getContentsForTest(1); IProject project= getProject().getProject(); IFile source= createFile(project, "source.cpp", contents[0].toString()); waitForIndexer(project, source); @@ -121,7 +121,7 @@ public class BasicOutlineTest extends BaseUITestCase { //int Foo::field = 5; //void Foo::foo() {} public void testGroupedMembers() throws Exception { - StringBuffer[] contents= getContentsForTest(2); + StringBuilder[] contents= getContentsForTest(2); IProject project= getProject().getProject(); IFile header= createFile(project, "header.h", contents[0].toString()); IFile source= createFile(project, "source.cpp", contents[1].toString()); @@ -162,7 +162,7 @@ public class BasicOutlineTest extends BaseUITestCase { //void Foo::foo() {} //} public void testGroupedMembersInNamespace() throws Exception { - StringBuffer[] contents= getContentsForTest(2); + StringBuilder[] contents= getContentsForTest(2); IProject project= getProject().getProject(); IFile header= createFile(project, "header.h", contents[0].toString()); IFile source= createFile(project, "source.cpp", contents[1].toString()); @@ -208,7 +208,7 @@ public class BasicOutlineTest extends BaseUITestCase { //void Foo::foo() {} //} public void testGroupedNamespaces() throws Exception { - StringBuffer[] contents= getContentsForTest(2); + StringBuilder[] contents= getContentsForTest(2); IProject project= getProject().getProject(); IFile header= createFile(project, "header.h", contents[0].toString()); IFile source= createFile(project, "source.cpp", contents[1].toString()); @@ -252,7 +252,7 @@ public class BasicOutlineTest extends BaseUITestCase { //void Foo::foo() {} //} public void testGroupedMembersInGroupedNamespaces() throws Exception { - StringBuffer[] contents= getContentsForTest(2); + StringBuilder[] contents= getContentsForTest(2); IProject project= getProject().getProject(); IFile header= createFile(project, "header.h", contents[0].toString()); IFile source= createFile(project, "source.cpp", contents[1].toString()); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java index e65daaa9a48..9babe2f4839 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java @@ -58,7 +58,7 @@ import org.eclipse.cdt.internal.ui.search.PDOMSearchViewPage; public class BasicSearchTest extends BaseUITestCase { ICProject fCProject; - StringBuffer[] testData; + CharSequence[] testData; public static TestSuite suite() { return suite(BasicSearchTest.class); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/LinkedNamesFinderTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/LinkedNamesFinderTest.java index 68e20027ad9..efa89496092 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/LinkedNamesFinderTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/LinkedNamesFinderTest.java @@ -52,7 +52,7 @@ public class LinkedNamesFinderTest extends AST2BaseTest { } @Override - protected StringBuffer[] getContents(int sections) throws IOException { + protected CharSequence[] getContents(int sections) throws IOException { CTestPlugin plugin = CTestPlugin.getDefault(); if (plugin == null) throw new AssertionFailedError("This test must be run as a JUnit plugin test"); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractAutoEditTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractAutoEditTest.java index c01483576de..b482e2b7801 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractAutoEditTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AbstractAutoEditTest.java @@ -233,7 +233,7 @@ public class AbstractAutoEditTest extends BaseTestCase { } } - protected StringBuffer[] getTestContents() { + protected CharSequence[] getTestContents() { try { return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "ui", this.getClass(), getName(), 2); } catch(IOException ioe) { @@ -242,7 +242,7 @@ public class AbstractAutoEditTest extends BaseTestCase { return null; } - protected StringBuffer[] getTestContents1() { + protected CharSequence[] getTestContents1() { try { return TestSourceReader.getContentsForTest(CTestPlugin.getDefault().getBundle(), "ui", this.getClass(), getName(), 1); } catch(IOException ioe) { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddBlockCommentTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddBlockCommentTest.java index b896d2be7fd..84b200cc202 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddBlockCommentTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/AddBlockCommentTest.java @@ -99,7 +99,7 @@ public class AddBlockCommentTest extends BaseUITestCase { */ protected void assertFormatterResult(LinePosition startLinePosition, LinePosition endLinePosition) throws Exception { - StringBuffer[] contents= getContentsForTest(2); + StringBuilder[] contents= getContentsForTest(2); String before = contents[0].toString(); String after = contents[1].toString(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java index b0be6d945ef..9bf315743d8 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java @@ -57,7 +57,7 @@ public class CIndenterTest extends BaseUITestCase { protected void assertIndenterResult() throws Exception { CCorePlugin.setOptions(fOptions); - StringBuffer[] contents= getContentsForTest(2); + StringBuilder[] contents= getContentsForTest(2); String before= contents[0].toString(); IDocument document= new Document(before); String expected= contents[1].toString(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java index 4d17fe7922f..12f57841fc3 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java @@ -59,7 +59,7 @@ public class CodeFormatterTest extends BaseUITestCase { } protected void assertFormatterResult() throws Exception { - StringBuffer[] contents= getContentsForTest(2); + CharSequence[] contents= getContentsForTest(2); String before= contents[0].toString(); String expected= contents[1].toString(); assertFormatterResult(before, expected); @@ -2383,4 +2383,198 @@ public class CodeFormatterTest extends BaseUITestCase { public void testDoubleClosingAngleBrackets_Bug333816() throws Exception { assertFormatterResult(); } + + //void foo() { + // int i; + // for (iiiiiiiiiiiiiiiiii = 0; iiiiiiiiiiiiiiiiii < 10; iiiiiiiiiiiiiiiiii++) { + // } + // foo(); + //} + + //void foo() { + // int i; + // for (iiiiiiiiiiiiiiiiii = 0; iiiiiiiiiiiiiiiiii < 10; + // iiiiiiiiiiiiiiiiii++) { + // } + // foo(); + //} + public void testForLoopWrappingAtOpeningBrace() throws Exception { + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "80"); + assertFormatterResult(); + } + + //void foo() { + // int i; + // for (i = 0; i < 10; i++) { + // } + // foo(); + //} + + //void foo() { + // int i; + // for (i = 0; i < 10; i++) { + // } + // foo(); + //} + public void testForLoopKnR_Bug351399() throws Exception { + assertFormatterResult(); + } + + //void foo() { + // int i; + // for (i = 0; i < 10; i++) { + // } + // foo(); + //} + + //void foo() + // { + // int i; + // for (i = 0; i < 10; i++) + // { + // } + // foo(); + // } + public void testForLoopWhitesmiths_Bug351399() throws Exception { + fOptions.putAll(DefaultCodeFormatterOptions.getWhitesmithsSettings().getMap()); + assertFormatterResult(); + } + + //void foo() { + // int i; + // for (i = 0; i < 10; i++) { + // } + // foo(); + //} + + //void + //foo() + //{ + // int i; + // for (i = 0; i < 10; i++) + // { + // } + // foo(); + //} + public void testForLoopGNU_Bug351399() throws Exception { + fOptions.putAll(DefaultCodeFormatterOptions.getGNUSettings().getMap()); + assertFormatterResult(); + } + + //void foo() { + // int i; + // for (i = 0; i < 10; i++) { + // } + // foo(); + //} + + //void foo() + //{ + // int i; + // for (i = 0; i < 10; i++) + // { + // } + // foo(); + //} + public void testForLoopAllman_Bug351399() throws Exception { + fOptions.putAll(DefaultCodeFormatterOptions.getAllmanSettings().getMap()); + assertFormatterResult(); + } + + //void f() { + // int i = static_cast(5+1); + // int j; + //} + + //void f() { + // int i = static_cast(5 + 1); + // int j; + //} + public void testStaticCastInInitializer_Bug353974() throws Exception { + assertFormatterResult(); + } + + //#define A 1 + //#define B 2 + //#define C 4 + //void f(int x, int y) { + // f(A|B|C,5); + // return; + //} + + //#define A 1 + //#define B 2 + //#define C 4 + //void f(int x, int y) { + // f(A | B | C, 5); + // return; + //} + public void testMacroInBinaryExpression_Bug344379() throws Exception { + assertFormatterResult(); + } + + public void testBackslashUInPreprocessorDirective_Bug350433() throws Exception { + String before= "#include \"test\\udp.h\"\n"; + String expected= before; + assertFormatterResult(before, expected); + } + + //#define SIZE 5 + //char s0[5]; + //char s1[1+1]; + //char s2[SIZE]; + //char s3[SIZE+1]; + //char s4[SIZE+SIZE]; + //char s5[1+SIZE]; + + //#define SIZE 5 + //char s0[5]; + //char s1[1 + 1]; + //char s2[SIZE]; + //char s3[SIZE + 1]; + //char s4[SIZE + SIZE]; + //char s5[1 + SIZE]; + public void testExpressionInArrayDeclarator_Bug350816() throws Exception { + assertFormatterResult(); + } + + //void f(int p0 ,... ){} + + //void f(int p0, ...) { + //} + public void testEllipsisInFunctionDefinition_Bug350689() throws Exception { + assertFormatterResult(); + } + + //struct{int n;}* l; + //void f(int p0, int p1) { f((p0 + 2), l->n); } + + //struct { + // int n; + //}* l; + //void f(int p0, int p1) { + // f((p0 + 2), l->n); + //} + public void testParenthesizedExpressionInArgumentList_Bug350689() throws Exception { + assertFormatterResult(); + } + + //#define m(x) { x=1; } + //void f() { + // int i; + // if (1) i=1; + // else m(i); + //} + + //#define m(x) { x=1; } + //void f() { + // int i; + // if (1) + // i = 1; + // else + // m(i); + //} + public void testMacroInElseBranch_Bug350689() throws Exception { + assertFormatterResult(); + } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/DefaultCCommentAutoEditStrategyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/DefaultCCommentAutoEditStrategyTest.java index 87377e8e307..8b7d5590037 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/DefaultCCommentAutoEditStrategyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/DefaultCCommentAutoEditStrategyTest.java @@ -599,7 +599,7 @@ public class DefaultCCommentAutoEditStrategyTest extends AbstractAutoEditTest { IDocument doc = new Document(); textTools.setupCDocument(doc); - StringBuffer[] raw= getTestContents(); + CharSequence[] raw= getTestContents(); String init= raw[0].toString(), expected= raw[1].toString(); int caretInit= init.indexOf('X'); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/RemoveBlockCommentTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/RemoveBlockCommentTest.java index f57c412876f..d278cc32189 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/RemoveBlockCommentTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/RemoveBlockCommentTest.java @@ -81,7 +81,7 @@ public class RemoveBlockCommentTest extends BaseUITestCase { protected void assertFormatterResult( LinePosition startLinePosition, LinePosition endLinePosition) throws Exception { - StringBuffer[] contents= getContentsForTest(2); + CharSequence[] contents= getContentsForTest(2); String before = contents[0].toString(); String after = contents[1].toString(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ShiftActionTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ShiftActionTest.java index c43f2b2e23e..c7b8aac9365 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ShiftActionTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/ShiftActionTest.java @@ -133,7 +133,7 @@ public class ShiftActionTest extends BaseUITestCase { // for(;;) { // } public void testShiftRight() throws Exception { - StringBuffer[] contents= getContentsForTest(2); + CharSequence[] contents= getContentsForTest(2); String before= contents[0].toString(); String after= contents[1].toString(); fDocument.set(before); @@ -150,7 +150,7 @@ public class ShiftActionTest extends BaseUITestCase { // for(;;) { //} public void testShiftLeft() throws Exception { - StringBuffer[] contents= getContentsForTest(2); + CharSequence[] contents= getContentsForTest(2); String before= contents[0].toString(); String after= contents[1].toString(); fDocument.set(before); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SortLinesTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SortLinesTest.java index 33654a027af..661f44609f5 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SortLinesTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SortLinesTest.java @@ -158,7 +158,7 @@ public class SortLinesTest extends BaseUITestCase { // // e.h // #include "e.h" public void testSortLinesMixed() throws Exception { - StringBuffer[] contents= getContentsForTest(2); + CharSequence[] contents= getContentsForTest(2); String before= contents[0].toString(); String after= contents[1].toString(); fDocument.set(before); @@ -179,7 +179,7 @@ public class SortLinesTest extends BaseUITestCase { // * Callisto // */ public void testSortLinesCommentsOnly() throws Exception { - StringBuffer[] contents= getContentsForTest(2); + CharSequence[] contents= getContentsForTest(2); String before= contents[0].toString(); String after= contents[1].toString(); fDocument.set(before); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/TemplateFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/TemplateFormatterTest.java index d3a9483c832..12aad2c23a8 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/TemplateFormatterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/TemplateFormatterTest.java @@ -81,7 +81,7 @@ public class TemplateFormatterTest extends BaseUITestCase { assertFormatterResult(false); } protected void assertFormatterResult(boolean useFormatter) throws Exception { - StringBuffer[] contents= getContentsForTest(2); + CharSequence[] contents= getContentsForTest(2); String before= contents[0].toString().replaceAll("\\r\\n", "\n"); String expected= contents[1].toString(); final Document document = new Document(before); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java index 31f1843c2e9..628e01e7331 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java @@ -192,7 +192,7 @@ public class CompletionTests extends AbstractContentAssistTest { protected IFile setUpProjectContent(IProject project) throws Exception { fProject= project; String headerContent= readTaggedComment(HEADER_FILE_NAME); - StringBuffer sourceContent= getContentsForTest(1)[0]; + StringBuilder sourceContent= getContentsForTest(1)[0]; sourceContent.insert(0, "#include \""+HEADER_FILE_NAME+"\"\n"); fCursorOffset= sourceContent.indexOf(CURSOR_LOCATION_TAG); assertTrue("No cursor location specified", fCursorOffset >= 0); @@ -955,7 +955,7 @@ public class CompletionTests extends AbstractContentAssistTest { // #include "header191315.h" // void xxx() { c_lin/*cursor*/ public void testExternC_bug191315() throws Exception { - StringBuffer[] content= getContentsForTest(3); + CharSequence[] content= getContentsForTest(3); createFile(fProject, "header191315.h", content[0].toString()); createFile(fProject, "source191315.c", content[1].toString()); createFile(fProject, "source191315.cpp", content[1].toString()); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java index d389711fc0f..a5b676b433c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java @@ -173,7 +173,7 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest { protected IFile setUpProjectContent(IProject project) throws Exception { fProject= project; String headerContent= readTaggedComment(HEADER_FILE_NAME); - StringBuffer sourceContent= getContentsForTest(1)[0]; + StringBuilder sourceContent= getContentsForTest(1)[0]; int includeOffset= Math.max(0, sourceContent.indexOf(INCLUDE_LOCATION_TAG)); sourceContent.insert(includeOffset, "#include \""+HEADER_FILE_NAME+"\"\n"); fCursorOffset= sourceContent.indexOf(CURSOR_LOCATION_TAG); @@ -309,7 +309,7 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest { // #include "header191315.h" // void xxx() { c_lin/*cursor*/ public void testExternC_bug191315() throws Exception { - StringBuffer[] content= getContentsForTest(3); + CharSequence[] content= getContentsForTest(3); createFile(fProject, "header191315.h", content[0].toString()); createFile(fProject, "source191315.c", content[1].toString()); createFile(fProject, "source191315.cpp", content[1].toString()); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ParameterHintTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ParameterHintTests.java index 6b0408e943a..f49669149a3 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ParameterHintTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ParameterHintTests.java @@ -55,7 +55,7 @@ public class ParameterHintTests extends AbstractContentAssistTest { @Override protected IFile setUpProjectContent(IProject project) throws Exception { String headerContent= readTaggedComment(HEADER_FILE_NAME); - StringBuffer sourceContent= getContentsForTest(1)[0]; + StringBuilder sourceContent= getContentsForTest(1)[0]; sourceContent.insert(0, "#include \""+HEADER_FILE_NAME+"\"\n"); assertNotNull(createFile(project, HEADER_FILE_NAME, headerContent)); return createFile(project, SOURCE_FILE_NAME, sourceContent.toString()); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ShowCamelCasePreferenceTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ShowCamelCasePreferenceTest.java index c03a7a1a0ca..f61e98b8e2e 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ShowCamelCasePreferenceTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/ShowCamelCasePreferenceTest.java @@ -44,7 +44,7 @@ public class ShowCamelCasePreferenceTest extends AbstractContentAssistTest { @Override protected IFile setUpProjectContent(IProject project) throws Exception { fProject= project; - StringBuffer sourceContent= getContentsForTest(1)[0]; + StringBuilder sourceContent= getContentsForTest(1)[0]; fCursorOffset= sourceContent.indexOf(CURSOR_LOCATION_TAG); assertTrue("No cursor location specified", fCursorOffset >= 0); sourceContent.delete(fCursorOffset, fCursorOffset+CURSOR_LOCATION_TAG.length()); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/doxygen/DoxygenCCommentAutoEditStrategyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/doxygen/DoxygenCCommentAutoEditStrategyTest.java index ed17048129b..124f077eee4 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/doxygen/DoxygenCCommentAutoEditStrategyTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/doxygen/DoxygenCCommentAutoEditStrategyTest.java @@ -673,7 +673,7 @@ public class DoxygenCCommentAutoEditStrategyTest extends DefaultCCommentAutoEdit final IDocument doc = new Document(); textTools.setupCDocument(doc); - StringBuffer[] raw= getTestContents(); + CharSequence[] raw= getTestContents(); String init= raw[0].toString(), expected= raw[1].toString(); int caretInit= init.indexOf('X'); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java index 384cbff3c4c..2f8c8e2f5e7 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsAnyIndexer.java @@ -74,7 +74,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde return cPrj; } - protected StringBuffer[] getContents(int sections) throws IOException { + protected StringBuilder[] getContents(int sections) throws IOException { return TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "ui", CPPSelectionTestsAnyIndexer.class, getName(), sections); } @@ -119,7 +119,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // return (0); // } public void testBug93281() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("test93281.h", hcode); @@ -161,7 +161,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // return EXIT_SUCCESS; // } public void testBug207320() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("test.h", hcode); @@ -187,7 +187,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // a.assign("aaa"); // } public void testTemplateClassMethod_207320() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("test.h", hcode); @@ -218,7 +218,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // class MyClass; // struct MyStruct; public void testBasicDefinition() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("basicDefinition.h", hcode); @@ -299,7 +299,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // #include "testBasicTemplateInstance.h" // N::AAA a; public void testBasicTemplateInstance_207320() throws Exception{ - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBasicTemplateInstance.h", hcode); @@ -333,7 +333,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // X b = f(X(2)); // openDeclarations on X(int) shall find constructor // } public void testBug86829A() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug86829A.h", hcode); @@ -365,7 +365,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // int c = X(a); // OK: a.operator X().operator int() // } public void _testBug86829B() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug86829B.h", hcode); @@ -408,7 +408,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // S s; // Int lhs= s.a+s.b+up+down+anX+0; public void testCPPSpecDeclsDefs() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testCPPSpecDeclsDefs.h", hcode); @@ -559,7 +559,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // using N::d; // declares // int a= d; public void testBug168533() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug168533.h", hcode); @@ -595,7 +595,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // } // } public void testBug95225() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug95225.h", hcode); @@ -637,7 +637,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // return *this; // } public void testBug95202() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug95202.h", hcode); @@ -661,7 +661,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // abc; // } public void testBug101287() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug101287.h", hcode); @@ -687,7 +687,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // void f(RTBindingEnd & end) { // } public void testBug102258() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug102258.h", hcode); @@ -715,7 +715,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // return foo::g(); // } public void testBug103323() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug103323.h", hcode); @@ -745,7 +745,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // return 0; // } public void testBug78354() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug78354.h", hcode); @@ -776,7 +776,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // return x; // } public void testBug103697() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFileWithLink("testBug103697.h", hcode); @@ -803,7 +803,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // return 0; // } public void testBug108202() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug108202.h", hcode); @@ -830,7 +830,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // #include "cpp.h" // void cpp() {} public void testCNavigationInCppProject_bug183973() throws Exception { - StringBuffer[] buffers= getContents(4); + StringBuilder[] buffers= getContents(4); String hccode= buffers[0].toString(); String ccode= buffers[1].toString(); String hcppcode= buffers[2].toString(); @@ -870,7 +870,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // void func(usertype t) { // } public void testFuncWithTypedefForAnonymousStruct_190730() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug190730.h", hcode); @@ -896,7 +896,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // void func(userEnum t) { // } public void testFuncWithTypedefForAnonymousEnum_190730() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug190730_2.h", hcode); @@ -924,7 +924,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // MY_PAR(0); // } public void testMacroNavigation() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("macrodef.h", hcode); @@ -959,7 +959,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // tester= MY_PAR(gvar); // } public void testMacroNavigation_Bug208300() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("macrodef.h", hcode); @@ -988,7 +988,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // #include "aheader.h" public void testIncludeNavigation() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("aheader.h", hcode); @@ -1014,7 +1014,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // cxcpp(); // } public void testNavigationCppCallsC() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String ccode= buffers[0].toString(); String scode= buffers[1].toString(); IFile cfile = importFile("s.c", ccode); @@ -1052,7 +1052,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // cppfunc(); // }} public void testNavigationCCallsCpp() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String ccode= buffers[0].toString(); String scode= buffers[1].toString(); IFile cfile = importFile("s.c", ccode); @@ -1087,7 +1087,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // #endif // } public void testNavigationInDefinedExpression_215906() throws Exception { - StringBuffer[] buffers= getContents(1); + StringBuilder[] buffers= getContents(1); String code= buffers[0].toString(); IFile file = importFile("s.cpp", code); waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME); @@ -1118,7 +1118,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // delete xx; // } public void testNavigationToImplicitNames() throws Exception { - StringBuffer[] buffers= getContents(1); + StringBuilder[] buffers= getContents(1); String code= buffers[0].toString(); IFile file = importFile("in.cpp", code); waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME); @@ -1157,7 +1157,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // a + 2; // } public void testBug272744() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("test.h", hcode); @@ -1203,7 +1203,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // A a3; // }; public void testImplicitConstructorCall_248855() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testImplicitConstructorCall_248855.h", hcode); @@ -1234,7 +1234,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde // #undef MYMACRO public void testUndef_312399() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testUndef_312399.h", hcode); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java index 96a7a4af22d..4dcd44e865c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java @@ -992,7 +992,7 @@ public class CPPSelectionTestsNoIndexer extends BaseUITestCase { // typedef int (functionPointerArray[2])(int); // functionPointerArray fctVariablArray; public void testBug195822() throws Exception { - StringBuffer[] contents= getContentsForTest(2); + StringBuilder[] contents= getContentsForTest(2); String code= contents[0].toString(); String appendCode= contents[1].toString(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java index d6212834905..258264e862a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CSelectionTestsAnyIndexer.java @@ -68,7 +68,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe return cPrj; } - protected StringBuffer[] getContents(int sections) throws IOException { + protected StringBuilder[] getContents(int sections) throws IOException { return TestSourceReader.getContentsForTest( CTestPlugin.getDefault().getBundle(), "ui", CSelectionTestsAnyIndexer.class, getName(), sections); } @@ -94,7 +94,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // void MyFunc(int a) { cout << a << endl; } // struct MyStruct; public void testBasicDefinition() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("basicDefinition.h", hcode); @@ -176,7 +176,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // struct S s; // Int lhs= s.a+s.b+up+down+anX+0; public void testCPPSpecDeclsDefs() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testCPPSpecDeclsDefs.h", hcode); @@ -288,7 +288,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // abc; // } public void testBug101287() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug101287.h", hcode); @@ -312,7 +312,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // return x; // } public void testBug103697() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFileWithLink("testBug103697.h", hcode); @@ -340,7 +340,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // return 0; // } public void testBug78354() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug78354.h", hcode); @@ -373,7 +373,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // void func(usertype t) { // } public void testFuncWithTypedefForAnonymousStruct_190730() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug190730.h", hcode); @@ -399,7 +399,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // void func(userEnum t) { // } public void testFuncWithTypedefForAnonymousEnum_190730() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("testBug190730_2.h", hcode); @@ -427,7 +427,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // MY_PAR(0); // } public void testMacroNavigation() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("macrodef.h", hcode); @@ -460,7 +460,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // int tester = MY_PAR(MY_MACRO); // } public void testMacroNavigation_Bug208300() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("macrodef.h", hcode); @@ -484,7 +484,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // #include "aheader.h" public void testIncludeNavigation() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("aheader.h", hcode); @@ -504,7 +504,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // #define DR_ACCESS_FNS(DR) public void testNavigationInMacroDefinition_Bug102643() throws Exception { - StringBuffer[] buffers= getContents(2); + StringBuilder[] buffers= getContents(2); String hcode= buffers[0].toString(); String scode= buffers[1].toString(); IFile hfile = importFile("aheader.h", hcode); @@ -533,7 +533,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // return myFunc(0); // } public void testKRstyleFunctions_Bug221635() throws Exception { - final StringBuffer[] contents = getContentsForTest(2); + final StringBuilder[] contents = getContentsForTest(2); String hcode= contents[0].toString(); String code= contents[1].toString(); IFile hfile = importFile("aheader.h", hcode); @@ -550,7 +550,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe // int x= __LINE__; public void testBuiltinMacro_Bug293864() throws Exception { - final StringBuffer[] contents = getContentsForTest(1); + final StringBuilder[] contents = getContentsForTest(1); String code= contents[0].toString(); IFile file = importFile("source.c", code); int offset= code.indexOf("__LINE__"); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java index 717fdb4cbf0..3b490ffa356 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/typehierarchy/TypeHierarchyAcrossProjectsTest.java @@ -85,7 +85,7 @@ public class TypeHierarchyAcrossProjectsTest extends TypeHierarchyBaseTest { // int method4(); // }; public void testSimpleInheritanceAcross() throws Exception { - StringBuffer[] content= getContentsForTest(2); + CharSequence[] content= getContentsForTest(2); String header= content[0].toString(); String source = content[1].toString(); IFile headerFile= createFile(fCProject.getProject(), "simpleHeader.h", header); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java index 5db40ae4d7d..20b5e4ad703 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java @@ -81,7 +81,7 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery { // Parse the pattern string List patternList = new ArrayList(); - StringBuffer buff = new StringBuffer(); + StringBuilder buff = new StringBuilder(); int n = patternStr.length(); for (int i = 0; i < n; ++i) { char c = patternStr.charAt(i); @@ -114,7 +114,7 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery { patternList.add(Pattern.compile(buff.toString())); else patternList.add(Pattern.compile(buff.toString(),Pattern.CASE_INSENSITIVE)); - buff = new StringBuffer(); + buff = new StringBuilder(); } break; case '|': case '+': case '^': case '(': case ')': case '[': case ']': diff --git a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/FileListControl.java b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/FileListControl.java index 7e8eeb49b5c..1f9ae4c0d08 100644 --- a/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/FileListControl.java +++ b/core/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/FileListControl.java @@ -593,7 +593,7 @@ public class FileListControl { moveDownItem.setToolTipText(MOVEDOWN_STR); moveDownItem.addSelectionListener(getSelectionListener()); grid3 = new GridData(GridData.FILL_HORIZONTAL - | GridData.HORIZONTAL_ALIGN_END); + | GridData.HORIZONTAL_ALIGN_BEGINNING); buttonPanel.setLayoutData(grid3); // list control list = new ClipboardList(filePanel, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.MULTI); diff --git a/cross/org.eclipse.cdt.build.crossgcc/.classpath b/cross/org.eclipse.cdt.build.crossgcc/.classpath old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/.project b/cross/org.eclipse.cdt.build.crossgcc/.project old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/.settings/org.eclipse.jdt.core.prefs b/cross/org.eclipse.cdt.build.crossgcc/.settings/org.eclipse.jdt.core.prefs old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/META-INF/MANIFEST.MF b/cross/org.eclipse.cdt.build.crossgcc/META-INF/MANIFEST.MF old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/build.properties b/cross/org.eclipse.cdt.build.crossgcc/build.properties old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/build/crossgcc/SetCrossCommandProcess.java b/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/build/crossgcc/SetCrossCommandProcess.java old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/Activator.java b/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/Activator.java old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/CrossCommandLineGenerator.java b/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/CrossCommandLineGenerator.java old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/CrossEnvironmentVariableSupplier.java b/cross/org.eclipse.cdt.build.crossgcc/src/org/eclipse/cdt/internal/build/crossgcc/CrossEnvironmentVariableSupplier.java old mode 100755 new mode 100644 diff --git a/cross/org.eclipse.cdt.build.crossgcc/templates/setCrossCommand/template.xml b/cross/org.eclipse.cdt.build.crossgcc/templates/setCrossCommand/template.xml old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CCommandAdapterFactory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CCommandAdapterFactory.java old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CForEachCommand.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/CForEachCommand.java old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/RestartCommand.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/command/RestartCommand.java old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/obj16/reverse_stepinto.gif b/debug/org.eclipse.cdt.debug.ui/icons/obj16/reverse_stepinto.gif old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/obj16/reverse_stepover.gif b/debug/org.eclipse.cdt.debug.ui/icons/obj16/reverse_stepover.gif old mode 100755 new mode 100644 diff --git a/debug/org.eclipse.cdt.debug.ui/icons/obj16/uncall.gif b/debug/org.eclipse.cdt.debug.ui/icons/obj16/uncall.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/btn_columns.png b/doc/org.eclipse.cdt.doc.user/images/btn_columns.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/btn_import_executables.png b/doc/org.eclipse.cdt.doc.user/images/btn_import_executables.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/btn_restart.png b/doc/org.eclipse.cdt.doc.user/images/btn_restart.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/c_exe_obj.png b/doc/org.eclipse.cdt.doc.user/images/c_exe_obj.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/c_object_file.png b/doc/org.eclipse.cdt.doc.user/images/c_object_file.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_dlg_define_build_var.png b/doc/org.eclipse.cdt.doc.user/images/cdt_dlg_define_build_var.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_dlg_edit_build_var.png b/doc/org.eclipse.cdt.doc.user/images/cdt_dlg_edit_build_var.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_menu_toggle_comments.png b/doc/org.eclipse.cdt.doc.user/images/cdt_menu_toggle_comments.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_pref_build_vars.png b/doc/org.eclipse.cdt.doc.user/images/cdt_pref_build_vars.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_pref_new_task_tag_dlg.png b/doc/org.eclipse.cdt.doc.user/images/cdt_pref_new_task_tag_dlg.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_pref_task_tags.png b/doc/org.eclipse.cdt.doc.user/images/cdt_pref_task_tags.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_w_basic06a.png b/doc/org.eclipse.cdt.doc.user/images/cdt_w_basic06a.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_w_debug_configurations_01.png b/doc/org.eclipse.cdt.doc.user/images/cdt_w_debug_configurations_01.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_w_debug_configurations_02.png b/doc/org.eclipse.cdt.doc.user/images/cdt_w_debug_configurations_02.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/command_link.png b/doc/org.eclipse.cdt.doc.user/images/command_link.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/editor_mark_preferences.png b/doc/org.eclipse.cdt.doc.user/images/editor_mark_preferences.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/editor_save_actions_preferences.png b/doc/org.eclipse.cdt.doc.user/images/editor_save_actions_preferences.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/hierarchy_co.gif b/doc/org.eclipse.cdt.doc.user/images/hierarchy_co.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/history_list.gif b/doc/org.eclipse.cdt.doc.user/images/history_list.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_build_make_target.png b/doc/org.eclipse.cdt.doc.user/images/icon_build_make_target.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_clear_console.png b/doc/org.eclipse.cdt.doc.user/images/icon_clear_console.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_edit_make_target.png b/doc/org.eclipse.cdt.doc.user/images/icon_edit_make_target.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_expand_all.png b/doc/org.eclipse.cdt.doc.user/images/icon_expand_all.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_hide_inactive_includes.png b/doc/org.eclipse.cdt.doc.user/images/icon_hide_inactive_includes.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_hide_make_targets.png b/doc/org.eclipse.cdt.doc.user/images/icon_hide_make_targets.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_hide_sys_includes.png b/doc/org.eclipse.cdt.doc.user/images/icon_hide_sys_includes.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_new_make_target.png b/doc/org.eclipse.cdt.doc.user/images/icon_new_make_target.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_next_error.png b/doc/org.eclipse.cdt.doc.user/images/icon_next_error.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_open_console.png b/doc/org.eclipse.cdt.doc.user/images/icon_open_console.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_pin.png b/doc/org.eclipse.cdt.doc.user/images/icon_pin.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_prev_error.png b/doc/org.eclipse.cdt.doc.user/images/icon_prev_error.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_repeat_search.png b/doc/org.eclipse.cdt.doc.user/images/icon_repeat_search.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_save_output_file.png b/doc/org.eclipse.cdt.doc.user/images/icon_save_output_file.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/icon_show_error.png b/doc/org.eclipse.cdt.doc.user/images/icon_show_error.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/namespace_declared_obj.png b/doc/org.eclipse.cdt.doc.user/images/namespace_declared_obj.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/new_proj_convert_candidate.png b/doc/org.eclipse.cdt.doc.user/images/new_proj_convert_candidate.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/pref_panel_build.png b/doc/org.eclipse.cdt.doc.user/images/pref_panel_build.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/pref_panel_code_templates.png b/doc/org.eclipse.cdt.doc.user/images/pref_panel_code_templates.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/pref_panel_edit_template_dlg.png b/doc/org.eclipse.cdt.doc.user/images/pref_panel_edit_template_dlg.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/pref_traditional_memory_prefs.png b/doc/org.eclipse.cdt.doc.user/images/pref_traditional_memory_prefs.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/progress_stop.gif b/doc/org.eclipse.cdt.doc.user/images/progress_stop.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/refresh_nav.gif b/doc/org.eclipse.cdt.doc.user/images/refresh_nav.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/sub_co.gif b/doc/org.eclipse.cdt.doc.user/images/sub_co.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/super_co.gif b/doc/org.eclipse.cdt.doc.user/images/super_co.gif old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/view_executables.png b/doc/org.eclipse.cdt.doc.user/images/view_executables.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/view_include_browser.png b/doc/org.eclipse.cdt.doc.user/images/view_include_browser.png old mode 100755 new mode 100644 diff --git a/doc/org.eclipse.cdt.doc.user/images/view_table_rendering.png b/doc/org.eclipse.cdt.doc.user/images/view_table_rendering.png old mode 100755 new mode 100644 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/connect.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/connect.gif old mode 100755 new mode 100644 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/reversestepinto.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/reversestepinto.gif old mode 100755 new mode 100644 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/reversestepover.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/reversestepover.gif old mode 100755 new mode 100644 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/stop_visual_trace.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/stop_visual_trace.gif old mode 100755 new mode 100644 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/uncall.gif b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/uncall.gif old mode 100755 new mode 100644 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java index 8ba3c9a68e3..4cf94210bb0 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java @@ -11,6 +11,7 @@ * IBM Corporation * Ericsson - Added support for Mac OS * Ericsson - Added support for post-mortem trace files + * Abeer Bagul (Tensilica) - Allow to better override GdbLaunch (bug 339550) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.launching; @@ -25,6 +26,7 @@ import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; import org.eclipse.cdt.dsf.concurrent.ThreadSafe; import org.eclipse.cdt.dsf.debug.service.IDsfDebugServicesFactory; import org.eclipse.cdt.dsf.debug.sourcelookup.DsfSourceLookupDirector; +import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory; import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactoryNS; @@ -44,6 +46,7 @@ import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.model.ISourceLocator; @@ -57,10 +60,11 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 public final static String GDB_DEBUG_MODEL_ID = "org.eclipse.cdt.dsf.gdb"; //$NON-NLS-1$ private final static String NON_STOP_FIRST_VERSION = "6.8.50"; //$NON-NLS-1$ + + // Can be removed once we remove the deprecated newServiceFactory(String) private boolean fIsNonStopSession = false; private final static String TRACING_FIRST_VERSION = "7.1.50"; //$NON-NLS-1$ - private boolean fIsPostMortemTracingSession; public GdbLaunchDelegate() { // We now fully support project-less debugging @@ -133,18 +137,21 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 monitor.worked( 1 ); + // Must set this here for users that call directly the deprecated newServiceFactory(String) + fIsNonStopSession = LaunchUtils.getIsNonStopMode(config); + String gdbVersion = getGDBVersion(config); // First make sure non-stop is supported, if the user want to use this mode - if (fIsNonStopSession && !isNonStopSupportedInGdbVersion(gdbVersion)) { + if (LaunchUtils.getIsNonStopMode(config) && !isNonStopSupportedInGdbVersion(gdbVersion)) { throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Non-stop mode is only supported starting with GDB " + NON_STOP_FIRST_VERSION, null)); //$NON-NLS-1$ } - if (fIsPostMortemTracingSession && !isPostMortemTracingSupportedInGdbVersion(gdbVersion)) { + if (LaunchUtils.getIsPostMortemTracing(config) && !isPostMortemTracingSupportedInGdbVersion(gdbVersion)) { throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Post-mortem tracing is only supported starting with GDB " + TRACING_FIRST_VERSION, null)); //$NON-NLS-1$ } - launch.setServiceFactory(newServiceFactory(gdbVersion)); + launch.setServiceFactory(newServiceFactory(config, gdbVersion)); // Create and invoke the launch sequence to create the debug control and services IProgressMonitor subMon1 = new SubProgressMonitor(monitor, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); @@ -267,8 +274,21 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 @Override public boolean preLaunchCheck(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException { - // no pre launch check for core file - if (mode.equals(ILaunchManager.DEBUG_MODE) && LaunchUtils.getSessionType(config) == SessionType.CORE) return true; + // Forcibly turn off non-stop for post-mortem sessions. + // Non-stop does not apply to post-mortem sessions. + // Now that we can have non-stop defaulting to enabled, it will prevent + // post-mortem sessions from starting for GDBs <= 6.8 and there is no way to turn it off + // Bug 348091 + if (LaunchUtils.getSessionType(config) == SessionType.CORE) { + if (LaunchUtils.getIsNonStopMode(config)) { + ILaunchConfigurationWorkingCopy wcConfig = config.getWorkingCopy(); + wcConfig.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP, false); + wcConfig.doSave(); + } + + // no further prelaunch check for core files + return true; + } return super.preLaunchCheck(config, mode, monitor); } @@ -280,17 +300,38 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 // the adapters will be created for the whole session, including // the source lookup adapter. - fIsNonStopSession = LaunchUtils.getIsNonStopMode(configuration); - fIsPostMortemTracingSession = LaunchUtils.getIsPostMortemTracing(configuration); - - GdbLaunch launch = new GdbLaunch(configuration, mode, null); + GdbLaunch launch = createGdbLaunch(configuration, mode, null); launch.initialize(); launch.setSourceLocator(getSourceLocator(configuration, launch.getSession())); return launch; } + + /** + * Creates an object of GdbLaunch. + * Subclasses who wish to just replace the GdbLaunch object with a sub-classed GdbLaunch + * should override this method. + * Subclasses who wish to replace the GdbLaunch object as well as change the + * initialization sequence of the launch, should override getLaunch() as well as this method. + * Subclasses who wish to create a launch class which does not subclass GdbLaunch, + * are advised to override getLaunch() directly. + * + * @param configuration The launch configuration + * @param mode The launch mode - "run", "debug", "profile" + * @param locator The source locator. Can be null. + * @return The GdbLaunch object, or a sub-classed object + * @throws CoreException + * @since 4.1 + */ + protected GdbLaunch createGdbLaunch(ILaunchConfiguration configuration, String mode, ISourceLocator locator) throws CoreException { + return new GdbLaunch(configuration, mode, locator); + } - private ISourceLocator getSourceLocator(ILaunchConfiguration configuration, DsfSession session) throws CoreException { - DsfSourceLookupDirector locator = new DsfSourceLookupDirector(session); + /** + * Creates and initializes the source locator for the given launch configuration and dsf session. + * @since 4.1 + */ + protected ISourceLocator getSourceLocator(ILaunchConfiguration configuration, DsfSession session) throws CoreException { + DsfSourceLookupDirector locator = createDsfSourceLocator(configuration, session); String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); if (memento == null) { locator.initializeDefaults(configuration); @@ -299,6 +340,21 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 } return locator; } + + /** + * Creates an object of DsfSourceLookupDirector with the given DsfSession. + * Subclasses who wish to just replace the source locator object with a sub-classed source locator + * should override this method. + * Subclasses who wish to replace the source locator object as well as change the + * initialization sequence of the source locator, should override getSourceLocator() + * as well as this method. + * Subclasses who wish to create a source locator which does not subclass DsfSourceLookupDirector, + * are advised to override getSourceLocator() directly. + * @since 4.1 + */ + protected DsfSourceLookupDirector createDsfSourceLocator(ILaunchConfiguration configuration, DsfSession session) throws CoreException { + return new DsfSourceLookupDirector(session); + } /** * Returns true if the specified version of GDB supports @@ -337,7 +393,10 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 return false; } - // A subclass can override this method and provide its own ServiceFactory. + /** + * @deprecated Replaced by newServiceFactory(ILaunchConfiguration, String) + */ + @Deprecated protected IDsfDebugServicesFactory newServiceFactory(String version) { if (fIsNonStopSession && isNonStopSupportedInGdbVersion(version)) { @@ -356,6 +415,18 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 return new GdbDebugServicesFactory(version); } + /** + * Method called to create the services factory for this debug session. + * A subclass can override this method and provide its own ServiceFactory. + * @since 4.1 + */ + protected IDsfDebugServicesFactory newServiceFactory(ILaunchConfiguration config, String version) { + // Call the deprecated one for now to avoid code duplication. + // Once we get rid of the deprecated one, we can also get rid of fIsNonStopSession + fIsNonStopSession = LaunchUtils.getIsNonStopMode(config); + return newServiceFactory(version); + } + @Override protected String getPluginID() { return GdbPlugin.PLUGIN_ID; diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda/.options b/dsf/org.eclipse.cdt.examples.dsf.pda/.options old mode 100755 new mode 100644 diff --git a/dsf/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/.gitignore b/dsf/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/.gitignore new file mode 100644 index 00000000000..ed1d9f9bb09 --- /dev/null +++ b/dsf/org.eclipse.cdt.examples.dsf/src/org/eclipse/cdt/examples/dsf/.gitignore @@ -0,0 +1,2 @@ +dataviewer +requestmonitor diff --git a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java index 0b2733fc21e..9e9cc09b0ad 100644 --- a/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java +++ b/jtag/org.eclipse.cdt.debug.gdbjtag.core/src/org/eclipse/cdt/debug/gdbjtag/core/GDBJtagDSFLaunchConfigurationDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 - 2010 QNX Software Systems and others. + * Copyright (c) 2007 - 2011 QNX Software Systems 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 @@ -8,6 +8,7 @@ * Contributors: * QNX Software Systems - Initial implementation * Ericsson - Updated for changes in base DSF-GDB launching (Bug 338769) + * Marc Khouzam (Ericsson) - Make sure non-stop is disabled (bug 348091) *******************************************************************************/ package org.eclipse.cdt.debug.gdbjtag.core; @@ -20,8 +21,13 @@ import org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service.GdbJtagDebugServicesFa import org.eclipse.cdt.debug.gdbjtag.core.dsf.gdb.service.macos.MacOSGdbJtagDebugServicesFactory; import org.eclipse.cdt.dsf.concurrent.ThreadSafe; import org.eclipse.cdt.dsf.debug.service.IDsfDebugServicesFactory; +import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate; import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; /** * The launch configuration delegate for the Jtag hardware debugging using @@ -37,8 +43,8 @@ import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils; */ @ThreadSafe public class GDBJtagDSFLaunchConfigurationDelegate extends GdbLaunchDelegate { - - protected IDsfDebugServicesFactory newServiceFactory(String version) { + + protected IDsfDebugServicesFactory newServiceFactory(ILaunchConfiguration config, String version) { if (version.contains(LaunchUtils.MACOS_GDB_MARKER)) { // The version string at this point should look like // 6.3.50-20050815APPLE1346, we extract the gdb version and apple version @@ -50,4 +56,20 @@ public class GDBJtagDSFLaunchConfigurationDelegate extends GdbLaunchDelegate { return new GdbJtagDebugServicesFactory(version); } + + @Override + public boolean preLaunchCheck(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException { + // Forcibly turn off non-stop for hardware sessions. + // Non-stop is not an option we offer for hardware launches. + // Now that we can have non-stop defaulting to enabled, it will prevent + // hardware sessions from starting for GDBs <= 6.8 and there is no way to turn if off + // Bug 348091 + if (LaunchUtils.getIsNonStopMode(config)) { + ILaunchConfigurationWorkingCopy wcConfig = config.getWorkingCopy(); + wcConfig.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP, false); + wcConfig.doSave(); + } + + return super.preLaunchCheck(config, mode, monitor); + } } diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/icons/memorybrowser_view.gif b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/icons/memorybrowser_view.gif old mode 100755 new mode 100644