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

Merge remote-tracking branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2012-05-24 05:35:45 -04:00
commit 11e878448a
243 changed files with 3073 additions and 2698 deletions

View file

@ -2975,6 +2975,9 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
@Override @Override
public ITreeRoot getTreeRoot() throws BuildException { public ITreeRoot getTreeRoot() throws BuildException {
if (getValueType() != TREE) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
if (treeRoot == null) { if (treeRoot == null) {
if (superClass != null) { if (superClass != null) {
return superClass.getTreeRoot(); return superClass.getTreeRoot();
@ -2982,9 +2985,6 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest
return null; return null;
} }
} }
if (getValueType() != TREE) {
throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
}
return treeRoot; return treeRoot;
} }

View file

@ -271,6 +271,29 @@ public class MBSWizardHandler extends CWizardHandler {
return out; return out;
} }
/**
* Get a map from toolchain names to actual toolchains.
* This list should mirror the list displayed in the wizard.
* Bug #363612
*
* @since 8.1
* @return the map
*/
public SortedMap<String, IToolChain> getToolChains() {
Set<String> toolChainNames = this.tc_filter();
SortedMap<String, IToolChain> toolChainMap = new TreeMap<String, IToolChain>();
for (String toolChainName : toolChainNames) {
IToolChain tc = tcs.get(toolChainName);
if (tc == null) {
toolChainMap.put(toolChainName, null);
} else {
toolChainMap.put(tc.getUniqueRealName(), tc);
}
}
return toolChainMap;
}
/** /**
* Checks whether given toolchain can be displayed * Checks whether given toolchain can be displayed
* *
@ -708,6 +731,30 @@ public class MBSWizardHandler extends CWizardHandler {
else else
return entryInfo.tc_filter().size(); return entryInfo.tc_filter().size();
} }
/**
* Get a map from toolchain names to actual toolchains.
* Bug #363612
*
* @since 8.1
* @return the map
*/
public SortedMap<String, IToolChain> getToolChains() {
if (entryInfo == null)
return full_tcs;
else
return entryInfo.getToolChains();
}
/**
* Get the table that is displayed in the left pane.
* This allow for changes after handler creation.
* Bug #363612
*
* @since 8.1
* @return the table
*/
public Table getToolChainsTable() {
return table;
}
public String getPropertyId() { public String getPropertyId() {
return propertyId; return propertyId;
} }

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
@ -43,6 +44,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
@ -171,9 +174,13 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
Set<IField> actualConstructorFields = constructorsStack.peek(); Set<IField> actualConstructorFields = constructorsStack.peek();
if (!actualConstructorFields.isEmpty()) { if (!actualConstructorFields.isEmpty()) {
IBinding binding = name.resolveBinding(); IBinding binding = name.resolveBinding();
if (actualConstructorFields.contains(binding)) { if (binding != null && !(binding instanceof IProblemBinding)) {
if ((CPPVariableReadWriteFlags.getReadWriteFlags(name) & PDOMName.WRITE_ACCESS) != 0) { IField equivalentFieldBinding = getContainedEquivalentBinding(
actualConstructorFields.remove(binding); actualConstructorFields, binding, name.getTranslationUnit().getIndex());
if (equivalentFieldBinding != null) {
if ((CPPVariableReadWriteFlags.getReadWriteFlags(name) & PDOMName.WRITE_ACCESS) != 0) {
actualConstructorFields.remove(equivalentFieldBinding);
}
} }
} }
} }
@ -181,6 +188,36 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }
private IField getContainedEquivalentBinding(Iterable<IField> fields, IBinding binding, IIndex index) {
for (IField field : fields) {
if (areEquivalentBindings(binding, field, index)) {
return field;
}
}
return null;
}
private boolean areEquivalentBindings(IBinding binding1, IBinding binding2, IIndex index) {
if (binding1.equals(binding2)) {
return true;
}
if ((binding1 instanceof IIndexBinding) != (binding2 instanceof IIndexBinding) && index != null) {
if (binding1 instanceof IIndexBinding) {
binding2 = index.adaptBinding(binding2);
} else {
binding1 = index.adaptBinding(binding1);
}
if (binding1 == null || binding2 == null) {
return false;
}
if (binding1.equals(binding2)) {
return true;
}
}
return false;
}
/** Checks whether class member of the specified type should be initialized /** Checks whether class member of the specified type should be initialized
* *
* @param type Type to check * @param type Type to check

View file

@ -543,4 +543,28 @@ public class ClassMembersInitializationCheckerTest extends CheckerTestCase {
loadCodeAndRun(getAboveComment()); loadCodeAndRun(getAboveComment());
checkNoErrors(); checkNoErrors();
} }
//@file:test.h
//template <typename>
//struct B;
//@file:test.cpp
//#include "test.h"
//
//template <typename>
//struct A {
//};
//
//template <typename valueT>
//struct B<A<valueT> > {
// const A<valueT>& obj;
// B(const A<valueT>& o) : obj(o) {}
//};
public void testBug368611_templatePartialSpecialization() throws Exception {
CharSequence[] code = getContents(2);
loadcode(code[0].toString());
loadcode(code[1].toString());
runOnProject();
checkNoErrors();
}
} }

View file

@ -1077,6 +1077,13 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
parse(getAboveComment(), ParserLanguage.CPP, true, 0); parse(getAboveComment(), ParserLanguage.CPP, true, 0);
} }
// thread_local int e;
// static thread_local int f;
// extern thread_local int g;
public void test7_1_1s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// static char* f(); // f() has internal linkage // static char* f(); // f() has internal linkage
// char* f() // f() still has internal linkage // char* f() // f() still has internal linkage
// { // // { //
@ -1184,6 +1191,24 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
assertInstance(d, IASTProblemDeclaration.class); assertInstance(d, IASTProblemDeclaration.class);
} }
// constexpr int square(int x);
// constexpr int bufsz = 1024;
// struct pixel {
// int x;
// int y;
// constexpr pixel(int);
// };
// constexpr pixel::pixel(int a)
// : x(square(a)), y(square(a))
// { }
// constexpr int square(int x) {
// return x * x;
// }
// constexpr pixel large(4);
public void test7_1_5s1() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// int foo() { // int foo() {
// const int ci = 3; // cvqualified (initialized as required) // const int ci = 3; // cvqualified (initialized as required)
// ci = 4; // illformed: attempt to modify const // ci = 4; // illformed: attempt to modify const

View file

@ -45,14 +45,17 @@ import org.eclipse.core.runtime.Path;
/** /**
* Tests the behavior of the IIndex API when dealing with multiple projects * Tests the behavior of the IIndex API when dealing with multiple projects
*/ */
public class IndexCompositeTests extends BaseTestCase { public class IndexCompositeTests extends BaseTestCase {
public static Test suite() { public static Test suite() {
return suite(IndexCompositeTests.class); return suite(IndexCompositeTests.class);
} }
private static final int NONE = 0, REFS = IIndexManager.ADD_DEPENDENCIES; private static final int NONE = 0;
private static final int REFD = IIndexManager.ADD_DEPENDENT, BOTH = REFS | REFD; private static final int REFS = IIndexManager.ADD_DEPENDENCIES;
private static final int REFD = IIndexManager.ADD_DEPENDENT;
private static final int BOTH = REFS | REFD;
private static final IndexFilter FILTER= new IndexFilter() { private static final IndexFilter FILTER= new IndexFilter() {
@Override @Override
public boolean acceptBinding(IBinding binding) throws CoreException { public boolean acceptBinding(IBinding binding) throws CoreException {
@ -75,15 +78,15 @@ public class IndexCompositeTests extends BaseTestCase {
// class B {}; // class B {};
public void testPairDisjointContent() throws Exception { public void testPairDisjointContent() throws Exception {
CharSequence[] contents = getContentsForTest(2); CharSequence[] contents = getContentsForTest(2);
List projects = new ArrayList(); List<ICProject> projects = new ArrayList<ICProject>();
try { try {
ProjectBuilder pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true); ProjectBuilder pb = new ProjectBuilder("projB" + System.currentTimeMillis(), true);
pb.addFile("h1.h", contents[0]); pb.addFile("h1.h", contents[0]);
ICProject cprojB = pb.create(); ICProject cprojB = pb.create();
projects.add(cprojB); projects.add(cprojB);
pb = new ProjectBuilder("projA"+System.currentTimeMillis(), true); pb = new ProjectBuilder("projA" + System.currentTimeMillis(), true);
pb.addFile("h2.h", contents[1]).addDependency(cprojB.getProject()); pb.addFile("h2.h", contents[1]).addDependency(cprojB.getProject());
ICProject cprojA = pb.create(); ICProject cprojA = pb.create();
projects.add(cprojA); projects.add(cprojA);
@ -98,8 +101,8 @@ public class IndexCompositeTests extends BaseTestCase {
setIndex(cprojA, REFD); assertBCount(1, 1); setIndex(cprojA, REFD); assertBCount(1, 1);
setIndex(cprojA, BOTH); assertBCount(2, 2); setIndex(cprojA, BOTH); assertBCount(2, 2);
} finally { } finally {
for (Iterator i = projects.iterator(); i.hasNext();) for (ICProject project : projects)
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor()); project.getProject().delete(true, true, new NullProgressMonitor());
} }
} }
@ -122,20 +125,20 @@ public class IndexCompositeTests extends BaseTestCase {
// namespace X { class A2 {}; B2 b; C2 c; } // namespace X { class A2 {}; B2 b; C2 c; }
public void testTripleLinear() throws Exception { public void testTripleLinear() throws Exception {
CharSequence[] contents = getContentsForTest(3); CharSequence[] contents = getContentsForTest(3);
List projects = new ArrayList(); List<ICProject> projects = new ArrayList<ICProject>();
try { try {
ProjectBuilder pb = new ProjectBuilder("projC"+System.currentTimeMillis(), true); ProjectBuilder pb = new ProjectBuilder("projC" + System.currentTimeMillis(), true);
pb.addFile("h3.h", contents[0]); pb.addFile("h3.h", contents[0]);
ICProject cprojC = pb.create(); ICProject cprojC = pb.create();
projects.add(cprojC); projects.add(cprojC);
pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true); pb = new ProjectBuilder("projB" + System.currentTimeMillis(), true);
pb.addFile("h2.h", contents[1]).addDependency(cprojC.getProject()); pb.addFile("h2.h", contents[1]).addDependency(cprojC.getProject());
ICProject cprojB = pb.create(); ICProject cprojB = pb.create();
projects.add(cprojB); projects.add(cprojB);
pb = new ProjectBuilder("projA"+System.currentTimeMillis(), true); pb = new ProjectBuilder("projA" + System.currentTimeMillis(), true);
pb.addFile("h1.h", contents[2]).addDependency(cprojB.getProject()); pb.addFile("h1.h", contents[2]).addDependency(cprojB.getProject());
ICProject cprojA = pb.create(); ICProject cprojA = pb.create();
projects.add(cprojA); projects.add(cprojA);
@ -150,8 +153,8 @@ public class IndexCompositeTests extends BaseTestCase {
final int gB= 6, aB= gB + 1; final int gB= 6, aB= gB + 1;
final int gA= 3, aA= gA + 3; final int gA= 3, aA= gA + 3;
final int gBC= gB+gC-1, aBC= aB+aC-1; final int gBC= gB + gC - 1, aBC= aB + aC - 1;
final int gABC= gA+gBC-1, aABC= aA+aBC-1; final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
setIndex(cprojC, NONE); setIndex(cprojC, NONE);
assertBCount(gC, aC); assertNamespaceXMemberCount(1); assertBCount(gC, aC); assertNamespaceXMemberCount(1);
@ -214,8 +217,8 @@ public class IndexCompositeTests extends BaseTestCase {
assertNamespaceXMemberCount(5); assertNamespaceXMemberCount(5);
assertFieldCount("C1", 1); assertFieldCount("C1", 1);
} finally { } finally {
for (Iterator i = projects.iterator(); i.hasNext();) for (ICProject project : projects)
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor()); project.getProject().delete(true, true, new NullProgressMonitor());
} }
} }
@ -238,20 +241,20 @@ public class IndexCompositeTests extends BaseTestCase {
// void foo(C1 c) {} // void foo(C1 c) {}
public void testTripleUpwardV() throws Exception { public void testTripleUpwardV() throws Exception {
CharSequence[] contents = getContentsForTest(3); CharSequence[] contents = getContentsForTest(3);
List projects = new ArrayList(); List<ICProject> projects = new ArrayList<ICProject>();
try { try {
ProjectBuilder pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true); ProjectBuilder pb = new ProjectBuilder("projB" + System.currentTimeMillis(), true);
pb.addFile("h2.h", contents[0]); pb.addFile("h2.h", contents[0]);
ICProject cprojB = pb.create(); ICProject cprojB = pb.create();
projects.add(cprojB); projects.add(cprojB);
pb = new ProjectBuilder("projA"+System.currentTimeMillis(), true); pb = new ProjectBuilder("projA" + System.currentTimeMillis(), true);
pb.addFile("h1.h", contents[1]).addDependency(cprojB.getProject()); pb.addFile("h1.h", contents[1]).addDependency(cprojB.getProject());
ICProject cprojA = pb.create(); ICProject cprojA = pb.create();
projects.add(cprojA); projects.add(cprojA);
pb = new ProjectBuilder("projC"+System.currentTimeMillis(), true); pb = new ProjectBuilder("projC" + System.currentTimeMillis(), true);
pb.addFile("h3.h", contents[2]).addDependency(cprojB.getProject()); pb.addFile("h3.h", contents[2]).addDependency(cprojB.getProject());
ICProject cprojC = pb.create(); ICProject cprojC = pb.create();
projects.add(cprojC); projects.add(cprojC);
@ -271,9 +274,9 @@ public class IndexCompositeTests extends BaseTestCase {
final int gB= 4, aB= gB + 1; final int gB= 4, aB= gB + 1;
final int gA= 4, aA= gA + 1; final int gA= 4, aA= gA + 1;
final int gBC= gB+gC-1, aBC= aB+aC-1; final int gBC= gB + gC - 1, aBC= aB + aC - 1;
final int gAB= gA+gB-1, aAB= aA+aB-1; final int gAB= gA + gB - 1, aAB= aA + aB - 1;
final int gABC= gA+gBC-1, aABC= aA+aBC-1; final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
setIndex(cprojC, NONE); setIndex(cprojC, NONE);
@ -315,8 +318,8 @@ public class IndexCompositeTests extends BaseTestCase {
assertBCount(gABC, aABC); assertBCount(gABC, aABC);
assertNamespaceXMemberCount(4); assertNamespaceXMemberCount(4);
} finally { } finally {
for (Iterator i = projects.iterator(); i.hasNext();) for (ICProject project : projects)
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor()); project.getProject().delete(true, true, new NullProgressMonitor());
} }
} }
@ -337,20 +340,20 @@ public class IndexCompositeTests extends BaseTestCase {
// namespace X { class A2 {}; } // namespace X { class A2 {}; }
public void testTripleDownwardV() throws Exception { public void testTripleDownwardV() throws Exception {
CharSequence[] contents = getContentsForTest(3); CharSequence[] contents = getContentsForTest(3);
List projects = new ArrayList(); List<ICProject> projects = new ArrayList<ICProject>();
try { try {
ProjectBuilder pb = new ProjectBuilder("projC"+System.currentTimeMillis(), true); ProjectBuilder pb = new ProjectBuilder("projC" + System.currentTimeMillis(), true);
pb.addFile("h3.h", contents[0]); pb.addFile("h3.h", contents[0]);
ICProject cprojC = pb.create(); ICProject cprojC = pb.create();
projects.add(cprojC); projects.add(cprojC);
pb = new ProjectBuilder("projA"+System.currentTimeMillis(), true); pb = new ProjectBuilder("projA" + System.currentTimeMillis(), true);
pb.addFile("h1.h", contents[2]); pb.addFile("h1.h", contents[2]);
ICProject cprojA = pb.create(); ICProject cprojA = pb.create();
projects.add(cprojA); projects.add(cprojA);
pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true); pb = new ProjectBuilder("projB" + System.currentTimeMillis(), true);
pb.addFile("h2.h", contents[1]).addDependency(cprojC.getProject()).addDependency(cprojA.getProject()); pb.addFile("h2.h", contents[1]).addDependency(cprojC.getProject()).addDependency(cprojA.getProject());
ICProject cprojB = pb.create(); ICProject cprojB = pb.create();
projects.add(cprojB); projects.add(cprojB);
@ -369,9 +372,9 @@ public class IndexCompositeTests extends BaseTestCase {
final int gB= 4, aB= gB + 2; final int gB= 4, aB= gB + 2;
final int gA= 3, aA= gA + 1; final int gA= 3, aA= gA + 1;
final int gBC= gB+gC-1, aBC= aB+aC-1; final int gBC= gB + gC - 1, aBC= aB + aC - 1;
final int gAB= gA+gB-1, aAB= aA+aB-1; final int gAB= gA + gB - 1, aAB= aA + aB - 1;
final int gABC= gA+gBC-1, aABC= aA+aBC-1; final int gABC= gA + gBC - 1, aABC= aA + aBC - 1;
setIndex(cprojC, NONE); setIndex(cprojC, NONE);
assertBCount(gC, aC); assertBCount(gC, aC);
@ -412,8 +415,8 @@ public class IndexCompositeTests extends BaseTestCase {
assertBCount(gABC, aABC); assertBCount(gABC, aABC);
assertNamespaceXMemberCount(4); assertNamespaceXMemberCount(4);
} finally { } finally {
for (Iterator i = projects.iterator(); i.hasNext();) for (ICProject project : projects)
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor()); project.getProject().delete(true, true, new NullProgressMonitor());
} }
} }
@ -465,10 +468,11 @@ public class IndexCompositeTests extends BaseTestCase {
* Convenience class for setting up projects. * Convenience class for setting up projects.
*/ */
class ProjectBuilder { class ProjectBuilder {
private String name; private static final int INDEXER_TIMEOUT_SEC = 5;
private final String name;
private final boolean cpp;
private List dependencies = new ArrayList(); private List dependencies = new ArrayList();
private Map path2content = new HashMap(); private Map path2content = new HashMap();
private boolean cpp;
ProjectBuilder(String name, boolean cpp) { ProjectBuilder(String name, boolean cpp) {
this.name = name; this.name = name;
@ -503,7 +507,7 @@ class ProjectBuilder {
CCorePlugin.getIndexManager().setIndexerId(result, IPDOMManager.ID_FAST_INDEXER); CCorePlugin.getIndexManager().setIndexerId(result, IPDOMManager.ID_FAST_INDEXER);
if (lastFile != null) { if (lastFile != null) {
IIndex index= CCorePlugin.getIndexManager().getIndex(result); IIndex index= CCorePlugin.getIndexManager().getIndex(result);
TestSourceReader.waitUntilFileIsIndexed(index, lastFile, 2000); TestSourceReader.waitUntilFileIsIndexed(index, lastFile, INDEXER_TIMEOUT_SEC * 1000);
} }
BaseTestCase.waitForIndexer(result); BaseTestCase.waitForIndexer(result);
return result; return result;

View file

@ -376,7 +376,6 @@ public class CoreModel {
return null; return null;
} }
/** /**
* Return true if project has C nature. * Return true if project has C nature.
*/ */

View file

@ -198,13 +198,16 @@ public class BinaryRunner {
} }
// check against known content types // check against known content types
// if the file has an extension
String name = proxy.getName(); String name = proxy.getName();
IContentType contentType = CCorePlugin.getContentType(project, name); if (name.contains(".")) {
if (contentType != null && textContentType != null) { IContentType contentType = CCorePlugin.getContentType(project, name);
if (contentType.isKindOf(textContentType)) { if (contentType != null && textContentType != null) {
return true; if (contentType.isKindOf(textContentType)) {
} else if (textContentType.isAssociatedWith(name)) { return true;
return true; } else if (textContentType.isAssociatedWith(name)) {
return true;
}
} }
} }

View file

@ -510,7 +510,24 @@ public class ASTSignatureUtil {
} }
if (declSpec instanceof ICPPASTDeclSpecifier) { if (declSpec instanceof ICPPASTDeclSpecifier) {
if (((ICPPASTDeclSpecifier) declSpec).isExplicit()) { ICPPASTDeclSpecifier cppDeclSpec = (ICPPASTDeclSpecifier) declSpec;
if (cppDeclSpec.isThreadLocal()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.THREAD_LOCAL);
needSpace = true;
}
if (cppDeclSpec.isConstexpr()) {
if (needSpace) {
result.append(SPACE);
needSpace = false;
}
result.append(Keywords.CONSTEXPR);
needSpace = true;
}
if (cppDeclSpec.isExplicit()) {
if (needSpace) { if (needSpace) {
result.append(SPACE); result.append(SPACE);
needSpace = false; needSpace = false;
@ -518,7 +535,7 @@ public class ASTSignatureUtil {
result.append(Keywords.EXPLICIT); result.append(Keywords.EXPLICIT);
needSpace = true; needSpace = true;
} }
if (((ICPPASTDeclSpecifier) declSpec).isFriend()) { if (cppDeclSpec.isFriend()) {
if (needSpace) { if (needSpace) {
result.append(SPACE); result.append(SPACE);
needSpace = false; needSpace = false;
@ -526,7 +543,7 @@ public class ASTSignatureUtil {
result.append(Keywords.FRIEND); result.append(Keywords.FRIEND);
needSpace = true; needSpace = true;
} }
if (((ICPPASTDeclSpecifier) declSpec).isVirtual()) { if (cppDeclSpec.isVirtual()) {
if (needSpace) { if (needSpace) {
result.append(SPACE); result.append(SPACE);
needSpace = false; needSpace = false;

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner, IASTDeclarationListOwner { public interface IASTCompositeTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner, IASTDeclarationListOwner {
/** /**
* <code>TYPE_NAME</code> represents the relationship between an * <code>TYPE_NAME</code> represents the relationship between an
* <code>IASTCompositeTypeSpecifier</code> and its <code>IASTName</code>. * <code>IASTCompositeTypeSpecifier</code> and its <code>IASTName</code>.

View file

@ -27,9 +27,7 @@ public interface IASTDeclSpecifier extends IASTNode {
public static final int sc_static = 3; public static final int sc_static = 3;
public static final int sc_auto = 4; public static final int sc_auto = 4;
public static final int sc_register = 5; public static final int sc_register = 5;
/** /** @since 5.2 */
* @since 5.2
*/
public static final int sc_mutable = 6; public static final int sc_mutable = 6;
/** /**
@ -40,6 +38,7 @@ public interface IASTDeclSpecifier extends IASTNode {
// Type qualifier // Type qualifier
public boolean isConst(); public boolean isConst();
public boolean isVolatile(); public boolean isVolatile();
/** /**
* @since 5.2 * @since 5.2
*/ */

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner { public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner {
/** /**
* Enumeration. * Enumeration.
*/ */
@ -39,17 +38,16 @@ public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTName
public static final int k_last = k_union; public static final int k_last = k_union;
/** /**
* Get the kind. * Returns the kind.
* *
* @return int (kind). * @return int (kind).
*/ */
public int getKind(); public int getKind();
/** /**
* Set the kind. * Sets the kind.
* *
* @param value * @param value int (kind)
* int (kind)
*/ */
public void setKind(int value); public void setKind(int value);
@ -61,14 +59,14 @@ public interface IASTElaboratedTypeSpecifier extends IASTDeclSpecifier, IASTName
"IASTElaboratedTypeSpecifier.TYPE_NAME - IASTName for IASTElaboratedTypeSpecifier"); //$NON-NLS-1$ "IASTElaboratedTypeSpecifier.TYPE_NAME - IASTName for IASTElaboratedTypeSpecifier"); //$NON-NLS-1$
/** /**
* Get the name. * Returns the name.
* *
* @return <code>IASTName</code> * @return <code>IASTName</code>
*/ */
public IASTName getName(); public IASTName getName();
/** /**
* Set the name. * Sets the name.
* *
* @param name * @param name
* <code>IASTName</code> * <code>IASTName</code>

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation * John Camelon (IBM Rational Software) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwner { public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwner {
/** /**
* This interface represents an enumerator member of an enum specifier. * This interface represents an enumerator member of an enum specifier.
* *
@ -59,14 +58,14 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn
"IASTEnumerator.ENUMERATOR_VALUE - IASTExpression (value) for IASTEnumerator"); //$NON-NLS-1$ "IASTEnumerator.ENUMERATOR_VALUE - IASTExpression (value) for IASTEnumerator"); //$NON-NLS-1$
/** /**
* Set enumerator value. * Sets enumerator value.
* *
* @param expression * @param expression
*/ */
public void setValue(IASTExpression expression); public void setValue(IASTExpression expression);
/** /**
* Get enumerator value. * Returns enumerator value.
* *
* @return <code>IASTExpression</code> value * @return <code>IASTExpression</code> value
*/ */
@ -95,7 +94,7 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn
"IASTEnumerationSpecifier.ENUMERATOR - nested IASTEnumerator for IASTEnumerationSpecifier"); //$NON-NLS-1$ "IASTEnumerationSpecifier.ENUMERATOR - nested IASTEnumerator for IASTEnumerationSpecifier"); //$NON-NLS-1$
/** /**
* Add an enumerator. * Adds an enumerator.
* *
* @param enumerator * @param enumerator
* <code>IASTEnumerator</code> * <code>IASTEnumerator</code>
@ -103,7 +102,7 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn
public void addEnumerator(IASTEnumerator enumerator); public void addEnumerator(IASTEnumerator enumerator);
/** /**
* Get enumerators. * Returns enumerators.
* *
* @return <code>IASTEnumerator []</code> array * @return <code>IASTEnumerator []</code> array
*/ */
@ -117,7 +116,7 @@ public interface IASTEnumerationSpecifier extends IASTDeclSpecifier, IASTNameOwn
"IASTEnumerationSpecifier.ENUMERATION_NAME - IASTName for IASTEnumerationSpecifier"); //$NON-NLS-1$ "IASTEnumerationSpecifier.ENUMERATION_NAME - IASTName for IASTEnumerationSpecifier"); //$NON-NLS-1$
/** /**
* Set the enum's name. * Sets the enum's name.
* *
* @param name * @param name
*/ */

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -18,11 +18,9 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTNamedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner { public interface IASTNamedTypeSpecifier extends IASTDeclSpecifier, IASTNameOwner {
/** /**
* <code>NAME</code> describes the relationship between an * <code>NAME</code> describes the relationship between an
* <code>IASTNamedTypeSpecifier</code> and its nested * <code>IASTNamedTypeSpecifier</code> and its nested <code>IASTName</code>.
* <code>IASTName</code>.
*/ */
public static final ASTNodeProperty NAME = new ASTNodeProperty("IASTNamedTypeSpecifier.NAME - IASTName for IASTNamedTypeSpecifier"); //$NON-NLS-1$ public static final ASTNodeProperty NAME = new ASTNodeProperty("IASTNamedTypeSpecifier.NAME - IASTName for IASTNamedTypeSpecifier"); //$NON-NLS-1$

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -27,7 +27,6 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
public static final ASTNodeProperty DECLTYPE_EXPRESSION = new ASTNodeProperty( public static final ASTNodeProperty DECLTYPE_EXPRESSION = new ASTNodeProperty(
"IASTSimpleDeclSpecifier.EXPRESSION [IASTExpression]"); //$NON-NLS-1$ "IASTSimpleDeclSpecifier.EXPRESSION [IASTExpression]"); //$NON-NLS-1$
/** /**
* Used for omitted declaration specifiers. E.g. for declaration of constructors, * Used for omitted declaration specifiers. E.g. for declaration of constructors,
* or in plain c, where this defaults to an integer. * or in plain c, where this defaults to an integer.
@ -109,7 +108,7 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
public IASTSimpleDeclSpecifier copy(); public IASTSimpleDeclSpecifier copy();
/** /**
* This returns the built-in type for the declaration. The type is then * Returns the built-in type for the declaration. The type is then
* refined by qualifiers for signed/unsigned and short/long. The type could * refined by qualifiers for signed/unsigned and short/long. The type could
* also be unspecified which usually means int. * also be unspecified which usually means int.
*/ */
@ -231,5 +230,4 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
*/ */
@Deprecated @Deprecated
public static final int t_last = t_double; // used only in subclasses public static final int t_last = t_double; // used only in subclasses
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.c; package org.eclipse.cdt.core.dom.ast.c;
@ -20,11 +20,9 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICASTDeclSpecifier extends IASTDeclSpecifier { public interface ICASTDeclSpecifier extends IASTDeclSpecifier {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override @Override
public ICASTDeclSpecifier copy(); public ICASTDeclSpecifier copy();
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
@ -19,6 +19,5 @@ import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPASTArrayDeclarator extends IASTArrayDeclarator, ICPPASTDeclarator{ public interface ICPPASTArrayDeclarator extends IASTArrayDeclarator, ICPPASTDeclarator {
} }

View file

@ -1,13 +1,14 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2011 IBM Corporation and others. * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
@ -20,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier { public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
// A declaration in C++ can be a friend declaration // A declaration in C++ can be a friend declaration
/** /**
* Is this a friend declaration? * Is this a friend declaration?
@ -30,10 +30,9 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
public boolean isFriend(); public boolean isFriend();
/** /**
* Set this to be a friend declaration true/false. * Sets this to be a friend declaration true/false.
* *
* @param value * @param value the new value
* boolean
*/ */
public void setFriend(boolean value); public void setFriend(boolean value);
@ -45,10 +44,9 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
public boolean isVirtual(); public boolean isVirtual();
/** /**
* Set this declaration to be virutal. * Sets this declaration to be virtual.
* *
* @param value * @param value the new value
* boolean
*/ */
public void setVirtual(boolean value); public void setVirtual(boolean value);
@ -60,13 +58,44 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
public boolean isExplicit(); public boolean isExplicit();
/** /**
* Set this to be an explicit constructor. * Sets this to be an explicit constructor.
* *
* @param value * @param value the new value
* boolean
*/ */
public void setExplicit(boolean value); public void setExplicit(boolean value);
/**
* Is this a constexpr
*
* @return boolean
* @since 5.4
*/
public boolean isConstexpr();
/**
* Sets this to be constexpr.
*
* @param value the new value
* @since 5.4
*/
public void setConstexpr(boolean value);
/**
* Is this thread_local
*
* @return boolean
* @since 5.4
*/
public boolean isThreadLocal();
/**
* Sets this to be thread_local.
*
* @param value the new value
* @since 5.4
*/
public void setThreadLocal(boolean value);
/** /**
* @since 5.1 * @since 5.1
*/ */

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
@ -21,15 +21,14 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
*/ */
public interface ICPPASTDeclarator extends IASTDeclarator { public interface ICPPASTDeclarator extends IASTDeclarator {
/** /**
* Returns whether the declarator contains an ellipsis, in which case it declares a * Returns whether the declarator contains an ellipsis, in which case it declares
* parameter pack. * a parameter pack.
*/ */
public boolean declaresParameterPack(); public boolean declaresParameterPack();
/** /**
* Set whether the declarator contains an ellipsis, denoting a pack expansion. * Set whether the declarator contains an ellipsis, denoting a pack expansion.
* Not allowed on frozen AST. * Not allowed on a frozen AST.
*/ */
public void setDeclaresParameterPack(boolean val); public void setDeclaresParameterPack(boolean val);
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
@ -18,9 +18,7 @@ import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
@Deprecated @Deprecated
public interface ICPPASTFunctionTryBlockDeclarator extends public interface ICPPASTFunctionTryBlockDeclarator extends ICPPASTFunctionDeclarator {
ICPPASTFunctionDeclarator {
/** /**
* A <code>CATCH_HANDLER</code> is the role of an ICPPASTCatchHandler in * A <code>CATCH_HANDLER</code> is the role of an ICPPASTCatchHandler in
* this interface. * this interface.

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.gnu.cpp; package org.eclipse.cdt.core.dom.ast.gnu.cpp;
@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
*/ */
@Deprecated @Deprecated
public interface IGPPASTDeclSpecifier extends IASTDeclSpecifier { public interface IGPPASTDeclSpecifier extends IASTDeclSpecifier {
/** /**
* @since 5.1 * @since 5.1
*/ */

View file

@ -1,15 +1,15 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2011 IBM Corporation and others. * Copyright (c) 2004, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.parser; package org.eclipse.cdt.core.dom.parser;
@ -50,15 +50,15 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx
addPreprocessorKeyword(Keywords.cASSERT, IPreprocessorDirective.ppIgnore); addPreprocessorKeyword(Keywords.cASSERT, IPreprocessorDirective.ppIgnore);
addPreprocessorKeyword(Keywords.cUNASSERT, IPreprocessorDirective.ppIgnore); addPreprocessorKeyword(Keywords.cUNASSERT, IPreprocessorDirective.ppIgnore);
addKeyword(GCCKeywords.cp__ALIGNOF, IGCCToken.t___alignof__ ); addKeyword(GCCKeywords.cp__ALIGNOF, IGCCToken.t___alignof__);
addKeyword(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ ); addKeyword(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__);
addKeyword(GCCKeywords.cp__ASM, IToken.t_asm); addKeyword(GCCKeywords.cp__ASM, IToken.t_asm);
addKeyword(GCCKeywords.cp__ASM__, IToken.t_asm); addKeyword(GCCKeywords.cp__ASM__, IToken.t_asm);
addKeyword(GCCKeywords.cp__ATTRIBUTE, IGCCToken.t__attribute__ ); addKeyword(GCCKeywords.cp__ATTRIBUTE, IGCCToken.t__attribute__);
addKeyword(GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ ); addKeyword(GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__);
addKeyword(GCCKeywords.cp__CONST, IToken.t_const); addKeyword(GCCKeywords.cp__CONST, IToken.t_const);
addKeyword(GCCKeywords.cp__CONST__, IToken.t_const); addKeyword(GCCKeywords.cp__CONST__, IToken.t_const);
addKeyword(GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec ); addKeyword(GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec);
addKeyword(GCCKeywords.cp__INLINE, IToken.t_inline); addKeyword(GCCKeywords.cp__INLINE, IToken.t_inline);
addKeyword(GCCKeywords.cp__INLINE__, IToken.t_inline); addKeyword(GCCKeywords.cp__INLINE__, IToken.t_inline);
addKeyword(GCCKeywords.cp__RESTRICT, IToken.t_restrict); addKeyword(GCCKeywords.cp__RESTRICT, IToken.t_restrict);
@ -69,7 +69,7 @@ public abstract class GNUScannerExtensionConfiguration extends AbstractScannerEx
addKeyword(GCCKeywords.cp__SIGNED__, IToken.t_signed); addKeyword(GCCKeywords.cp__SIGNED__, IToken.t_signed);
addKeyword(GCCKeywords.cp__TYPEOF, IGCCToken.t_typeof); addKeyword(GCCKeywords.cp__TYPEOF, IGCCToken.t_typeof);
addKeyword(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof); addKeyword(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof);
addKeyword(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof ); addKeyword(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof);
} }
@Override @Override

View file

@ -419,7 +419,7 @@ public interface IIndex {
* Returns an IIndexBinding for this IIndex that is equivalent to the specified binding, * Returns an IIndexBinding for this IIndex that is equivalent to the specified binding,
* or null if such a binding does not exist in this index. This is useful for adapting * or null if such a binding does not exist in this index. This is useful for adapting
* bindings obtained from IIndex objects that might have been created for a different scope * bindings obtained from IIndex objects that might have been created for a different scope
* or for IBinding objects obtained direct from the AST. * or for IBinding objects obtained directly from the AST.
* @param binding * @param binding
* @return an IIndexBinding for this IIndex that is equivalent to the specified binding * @return an IIndexBinding for this IIndex that is equivalent to the specified binding
*/ */

View file

@ -33,21 +33,21 @@ public interface IIndexManager extends IPDOMManager {
* projects referenced by the set of input projects should also be added * projects referenced by the set of input projects should also be added
* to the resulting index. * to the resulting index.
*/ */
public final static int ADD_DEPENDENCIES = 0x1; public static final int ADD_DEPENDENCIES = 0x1;
/** /**
* Constant for passing to getIndex methods. This constant, when set, indicates * Constant for passing to getIndex methods. This constant, when set, indicates
* projects which reference any of the set of input projects should also be * projects which reference any of the set of input projects should also be
* added to the resulting index. * added to the resulting index.
*/ */
public final static int ADD_DEPENDENT = 0x2; public static final int ADD_DEPENDENT = 0x2;
/** /**
* @deprecated Extension fragments are now used depending on their configuration. * @deprecated Extension fragments are now used depending on their configuration.
* Use one of the ADD_EXTENSION_XX flags instead. * Use one of the ADD_EXTENSION_XX flags instead.
*/ */
@Deprecated @Deprecated
public final static int SKIP_PROVIDED = 0x4; public static final int SKIP_PROVIDED = 0x4;
/** /**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index * Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -56,7 +56,7 @@ public interface IIndexManager extends IPDOMManager {
* *
* @since 5.4 * @since 5.4
*/ */
public final static int ADD_EXTENSION_FRAGMENTS_NAVIGATION = 0x8; public static final int ADD_EXTENSION_FRAGMENTS_NAVIGATION = 0x8;
/** /**
* Constant for passing to getIndex methods. This constant, when set, indicates that the each index * Constant for passing to getIndex methods. This constant, when set, indicates that the each index
@ -65,7 +65,7 @@ public interface IIndexManager extends IPDOMManager {
* *
* @since 5.4 * @since 5.4
*/ */
public final static int ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST = 0x10; public static final int ADD_EXTENSION_FRAGMENTS_CONTENT_ASSIST = 0x10;
/** /**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index * Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -74,7 +74,7 @@ public interface IIndexManager extends IPDOMManager {
* *
* @since 5.4 * @since 5.4
*/ */
public final static int ADD_EXTENSION_FRAGMENTS_ADD_IMPORT = 0x20; public static final int ADD_EXTENSION_FRAGMENTS_ADD_IMPORT = 0x20;
/** /**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index * Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -83,7 +83,7 @@ public interface IIndexManager extends IPDOMManager {
* *
* @since 5.4 * @since 5.4
*/ */
public final static int ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY = 0x40; public static final int ADD_EXTENSION_FRAGMENTS_CALL_HIERARCHY = 0x40;
/** /**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index * Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -92,7 +92,7 @@ public interface IIndexManager extends IPDOMManager {
* *
* @since 5.4 * @since 5.4
*/ */
public final static int ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY = 0x80; public static final int ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY = 0x80;
/** /**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index * Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -101,7 +101,7 @@ public interface IIndexManager extends IPDOMManager {
* *
* @since 5.4 * @since 5.4
*/ */
public final static int ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER = 0x100; public static final int ADD_EXTENSION_FRAGMENTS_INCLUDE_BROWSER = 0x100;
/** /**
* Constant for passing to getIndex methods. This constant, when set, indicates that each index * Constant for passing to getIndex methods. This constant, when set, indicates that each index
@ -110,29 +110,29 @@ public interface IIndexManager extends IPDOMManager {
* *
* @since 5.4 * @since 5.4
*/ */
public final static int ADD_EXTENSION_FRAGMENTS_SEARCH = 0x200; public static final int ADD_EXTENSION_FRAGMENTS_SEARCH = 0x200;
/** /**
* Constant for indicating that there is no time out period for joining the indexer job. * Constant for indicating that there is no time out period for joining the indexer job.
* @see IIndexManager#joinIndexer(int, IProgressMonitor) * @see IIndexManager#joinIndexer(int, IProgressMonitor)
*/ */
public final static int FOREVER= -1; public static final int FOREVER= -1;
/** /**
* Constant for requesting an update of all translation units. * Constant for requesting an update of all translation units.
*/ */
public final static int UPDATE_ALL= 0x1; public static final int UPDATE_ALL= 0x1;
/** /**
* Constant for requesting an update of translation units if theit timestamps have changed. * Constant for requesting an update of translation units if theit timestamps have changed.
*/ */
public final static int UPDATE_CHECK_TIMESTAMPS= 0x2; public static final int UPDATE_CHECK_TIMESTAMPS= 0x2;
/** /**
* Constant for requesting an update of translation units if their configurations * Constant for requesting an update of translation units if their configurations
* have changed. The flag currently has no effect. * have changed. The flag currently has no effect.
*/ */
public final static int UPDATE_CHECK_CONFIGURATION= 0x4; public static final int UPDATE_CHECK_CONFIGURATION= 0x4;
/** /**
* Constant for requesting to update the external files for a project, also. This flag works * Constant for requesting to update the external files for a project, also. This flag works
@ -140,7 +140,7 @@ public interface IIndexManager extends IPDOMManager {
* {@link #UPDATE_ALL} or {@link #UPDATE_CHECK_TIMESTAMPS}. * {@link #UPDATE_ALL} or {@link #UPDATE_CHECK_TIMESTAMPS}.
* @since 5.1 * @since 5.1
*/ */
public final static int UPDATE_EXTERNAL_FILES_FOR_PROJECT= 0x8; public static final int UPDATE_EXTERNAL_FILES_FOR_PROJECT= 0x8;
/** /**
* This flag modifies behavior of UPDATE_CHECK_TIMESTAMPS. Both, the timestamp and the hash * This flag modifies behavior of UPDATE_CHECK_TIMESTAMPS. Both, the timestamp and the hash
@ -149,7 +149,7 @@ public interface IIndexManager extends IPDOMManager {
* generation since generated files are sometimes recreated with identical contents. * generation since generated files are sometimes recreated with identical contents.
* @since 5.2 * @since 5.2
*/ */
public final static int UPDATE_CHECK_CONTENTS_HASH= 0x10; public static final int UPDATE_CHECK_CONTENTS_HASH= 0x10;
/** /**
* Include files that are otherwise would be excluded from the index. This flag is sticky * Include files that are otherwise would be excluded from the index. This flag is sticky
@ -157,7 +157,7 @@ public interface IIndexManager extends IPDOMManager {
* they remain in the index. * they remain in the index.
* @since 5.3 * @since 5.3
*/ */
public final static int FORCE_INDEX_INCLUSION= 0x20; public static final int FORCE_INDEX_INCLUSION= 0x20;
/** /**
* Causes files previously included in the index due to FORCE_INDEX_INCLUSION to loose * Causes files previously included in the index due to FORCE_INDEX_INCLUSION to loose
@ -165,13 +165,13 @@ public interface IIndexManager extends IPDOMManager {
* will be removed from the index. * will be removed from the index.
* @since 5.4 * @since 5.4
*/ */
public final static int RESET_INDEX_INCLUSION= 0x40; public static final int RESET_INDEX_INCLUSION= 0x40;
/** /**
* Constant for requesting an update of translation units that had unresolved includes. * Constant for requesting an update of translation units that had unresolved includes.
* @since 5.4 * @since 5.4
*/ */
public final static int UPDATE_UNRESOLVED_INCLUDES= 0x80; public static final int UPDATE_UNRESOLVED_INCLUDES= 0x80;
/** /**
* Returns the index for the given project. * Returns the index for the given project.

View file

@ -115,6 +115,7 @@ public interface IToken {
/** @deprecated use {@link #tBITCOMPLEMENT} */ @Deprecated int t_compl = 66; /** @deprecated use {@link #tBITCOMPLEMENT} */ @Deprecated int t_compl = 66;
int t_const = 67; int t_const = 67;
/** @since 5.4 */ int t_constexpr = 5400;
int t_const_cast = 69; int t_const_cast = 69;
int t_continue = 70; int t_continue = 70;
/** @since 5.2 */ /** @since 5.2 */
@ -141,7 +142,8 @@ public interface IToken {
int t_mutable = 90; int t_mutable = 90;
int t_namespace = 91; int t_namespace = 91;
int t_new = 92; int t_new = 92;
/** @since 5.4 */ int t_nullptr = 5400; /** @since 5.4 */ int t_noexcept = 5401;
/** @since 5.4 */ int t_nullptr = 5402;
/** @deprecated use {@link #tNOT} */ @Deprecated int t_not = 93; /** @deprecated use {@link #tNOT} */ @Deprecated int t_not = 93;
/** @deprecated use {@link #tNOTEQUAL} */ @Deprecated int t_not_eq = 94; /** @deprecated use {@link #tNOTEQUAL} */ @Deprecated int t_not_eq = 94;
int t_operator = 95; int t_operator = 95;
@ -164,6 +166,7 @@ public interface IToken {
int t_switch = 110; int t_switch = 110;
int t_template = 111; int t_template = 111;
int t_this = 112; int t_this = 112;
/** @since 5.4 */ int t_thread_local = 5403;
int t_throw = 113; int t_throw = 113;
int t_true = 114; int t_true = 114;
int t_try = 115; int t_try = 115;

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation * John Camelon (IBM Rational Software) - Initial API and implementation
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser; package org.eclipse.cdt.core.parser;
@ -20,8 +20,9 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
*/ */
@SuppressWarnings("nls") @SuppressWarnings("nls")
public class Keywords { public class Keywords {
public static final String CAST = "cast"; public static final String CAST = "cast";
/** @since 5.4 */
public static final String ALIGNAS = "alignas";
public static final String ALIGNOF = "alignof"; public static final String ALIGNOF = "alignof";
public static final String TYPEOF = "typeof"; public static final String TYPEOF = "typeof";
@ -46,6 +47,8 @@ public class Keywords {
public static final String CLASS = "class"; public static final String CLASS = "class";
public static final String COMPL = "compl"; public static final String COMPL = "compl";
public static final String CONST = "const"; public static final String CONST = "const";
/** @since 5.4 */
public static final String CONSTEXPR = "constexpr";
public static final String CONST_CAST = "const_cast"; public static final String CONST_CAST = "const_cast";
public static final String CONTINUE = "continue"; public static final String CONTINUE = "continue";
/** @since 5.2 */ /** @since 5.2 */
@ -75,6 +78,8 @@ public class Keywords {
/** @since 5.4 */ /** @since 5.4 */
public static final String NULLPTR = "nullptr"; public static final String NULLPTR = "nullptr";
public static final String NEW = "new"; public static final String NEW = "new";
/** @since 5.4 */
public static final String NOEXCEPT = "noexcept";
public static final String NOT = "not"; public static final String NOT = "not";
public static final String NOT_EQ = "not_eq"; public static final String NOT_EQ = "not_eq";
public static final String OPERATOR = "operator"; public static final String OPERATOR = "operator";
@ -98,6 +103,8 @@ public class Keywords {
public static final String SWITCH = "switch"; public static final String SWITCH = "switch";
public static final String TEMPLATE = "template"; public static final String TEMPLATE = "template";
public static final String THIS = "this"; public static final String THIS = "this";
/** @since 5.4 */
public static final String THREAD_LOCAL = "thread_local";
public static final String THROW = "throw"; public static final String THROW = "throw";
public static final String TRUE = "true"; public static final String TRUE = "true";
public static final String TRY = "try"; public static final String TRY = "try";
@ -119,6 +126,8 @@ public class Keywords {
public static final char[] c_BOOL = "_Bool".toCharArray(); public static final char[] c_BOOL = "_Bool".toCharArray();
public static final char[] c_COMPLEX = "_Complex".toCharArray(); public static final char[] c_COMPLEX = "_Complex".toCharArray();
public static final char[] c_IMAGINARY = "_Imaginary".toCharArray(); public static final char[] c_IMAGINARY = "_Imaginary".toCharArray();
/** @since 5.4 */
public static final char[] cALIGNAS = "alignas".toCharArray();
/** @since 5.3 */ /** @since 5.3 */
public static final char[] cALIGNOF = "alignof".toCharArray(); public static final char[] cALIGNOF = "alignof".toCharArray();
public static final char[] cAND = "and".toCharArray(); public static final char[] cAND = "and".toCharArray();
@ -139,6 +148,8 @@ public class Keywords {
public static final char[] cCLASS = "class".toCharArray(); public static final char[] cCLASS = "class".toCharArray();
public static final char[] cCOMPL = "compl".toCharArray(); public static final char[] cCOMPL = "compl".toCharArray();
public static final char[] cCONST = "const".toCharArray(); public static final char[] cCONST = "const".toCharArray();
/** @since 5.4 */
public static final char[] cCONSTEXPR = "constexpr".toCharArray();
public static final char[] cCONST_CAST = "const_cast".toCharArray(); public static final char[] cCONST_CAST = "const_cast".toCharArray();
public static final char[] cCONTINUE = "continue".toCharArray(); public static final char[] cCONTINUE = "continue".toCharArray();
public static final char[] cDEFAULT = "default".toCharArray(); public static final char[] cDEFAULT = "default".toCharArray();
@ -167,6 +178,8 @@ public class Keywords {
public static final char[] cNEW = "new".toCharArray(); public static final char[] cNEW = "new".toCharArray();
/** @since 5.4 */ /** @since 5.4 */
public static final char[] cNULLPTR = NULLPTR.toCharArray(); public static final char[] cNULLPTR = NULLPTR.toCharArray();
/** @since 5.4 */
public static final char[] cNOEXCEPT = "noexcept".toCharArray();
public static final char[] cNOT = "not".toCharArray(); public static final char[] cNOT = "not".toCharArray();
public static final char[] cNOT_EQ = "not_eq".toCharArray(); public static final char[] cNOT_EQ = "not_eq".toCharArray();
public static final char[] cOPERATOR = "operator".toCharArray(); public static final char[] cOPERATOR = "operator".toCharArray();
@ -192,6 +205,8 @@ public class Keywords {
public static final char[] cSWITCH = "switch".toCharArray(); public static final char[] cSWITCH = "switch".toCharArray();
public static final char[] cTEMPLATE = "template".toCharArray(); public static final char[] cTEMPLATE = "template".toCharArray();
public static final char[] cTHIS = "this".toCharArray(); public static final char[] cTHIS = "this".toCharArray();
/** @since 5.4 */
public static final char[] cTHREAD_LOCAL = "thread_local".toCharArray();
public static final char[] cTHROW = "throw".toCharArray(); public static final char[] cTHROW = "throw".toCharArray();
public static final char[] cTRUE = "true".toCharArray(); public static final char[] cTRUE = "true".toCharArray();
public static final char[] cTRY = "try".toCharArray(); public static final char[] cTRY = "try".toCharArray();
@ -301,7 +316,6 @@ public class Keywords {
addCpp(kw); addCpp(kw);
} }
private static void addCommon(CharArrayIntMap words) { private static void addCommon(CharArrayIntMap words) {
words.put(Keywords._Pragma, IToken.t_PRAGMA); words.put(Keywords._Pragma, IToken.t_PRAGMA);
words.put(Keywords.cAUTO, IToken.t_auto); words.put(Keywords.cAUTO, IToken.t_auto);
@ -354,6 +368,7 @@ public class Keywords {
cppkeywords.put(Keywords.cCHAR16_T, IToken.t_char16_t); cppkeywords.put(Keywords.cCHAR16_T, IToken.t_char16_t);
cppkeywords.put(Keywords.cCHAR32_T, IToken.t_char32_t); cppkeywords.put(Keywords.cCHAR32_T, IToken.t_char32_t);
cppkeywords.put(Keywords.cCLASS, IToken.t_class); cppkeywords.put(Keywords.cCLASS, IToken.t_class);
cppkeywords.put(Keywords.cCONSTEXPR, IToken.t_constexpr);
cppkeywords.put(Keywords.cCONST_CAST, IToken.t_const_cast); cppkeywords.put(Keywords.cCONST_CAST, IToken.t_const_cast);
cppkeywords.put(Keywords.cDECLTYPE, IToken.t_decltype); cppkeywords.put(Keywords.cDECLTYPE, IToken.t_decltype);
cppkeywords.put(Keywords.cDELETE, IToken.t_delete); cppkeywords.put(Keywords.cDELETE, IToken.t_delete);
@ -365,6 +380,7 @@ public class Keywords {
cppkeywords.put(Keywords.cMUTABLE, IToken.t_mutable); cppkeywords.put(Keywords.cMUTABLE, IToken.t_mutable);
cppkeywords.put(Keywords.cNAMESPACE, IToken.t_namespace); cppkeywords.put(Keywords.cNAMESPACE, IToken.t_namespace);
cppkeywords.put(Keywords.cNEW, IToken.t_new); cppkeywords.put(Keywords.cNEW, IToken.t_new);
cppkeywords.put(Keywords.cNOEXCEPT, IToken.t_noexcept);
cppkeywords.put(Keywords.cNULLPTR, IToken.t_nullptr); cppkeywords.put(Keywords.cNULLPTR, IToken.t_nullptr);
cppkeywords.put(Keywords.cOPERATOR, IToken.t_operator); cppkeywords.put(Keywords.cOPERATOR, IToken.t_operator);
cppkeywords.put(Keywords.cPRIVATE, IToken.t_private); cppkeywords.put(Keywords.cPRIVATE, IToken.t_private);
@ -375,6 +391,7 @@ public class Keywords {
cppkeywords.put(Keywords.cSTATIC_CAST, IToken.t_static_cast); cppkeywords.put(Keywords.cSTATIC_CAST, IToken.t_static_cast);
cppkeywords.put(Keywords.cTEMPLATE, IToken.t_template); cppkeywords.put(Keywords.cTEMPLATE, IToken.t_template);
cppkeywords.put(Keywords.cTHIS, IToken.t_this); cppkeywords.put(Keywords.cTHIS, IToken.t_this);
cppkeywords.put(Keywords.cTHREAD_LOCAL, IToken.t_thread_local);
cppkeywords.put(Keywords.cTHROW, IToken.t_throw); cppkeywords.put(Keywords.cTHROW, IToken.t_throw);
cppkeywords.put(Keywords.cTRUE, IToken.t_true); cppkeywords.put(Keywords.cTRUE, IToken.t_true);
cppkeywords.put(Keywords.cTRY, IToken.t_try); cppkeywords.put(Keywords.cTRY, IToken.t_try);

View file

@ -162,5 +162,4 @@ public class CharArrayObjectMap <T> extends CharTable {
System.arraycopy(valueTable, 0, values, 0, values.length); System.arraycopy(valueTable, 0, values, 0, values.length);
return values; return values;
} }
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Niefer (IBM Corporation) - Initial API and implementation * Andrew Niefer (IBM Corporation) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser.util; package org.eclipse.cdt.core.parser.util;
@ -15,47 +15,47 @@ import java.util.List;
public class CharArraySet extends CharTable { public class CharArraySet extends CharTable {
public static final CharArraySet EMPTY_SET = new CharArraySet( 0 ){ public static final CharArraySet EMPTY_SET = new CharArraySet(0) {
@Override @Override
public Object clone() { return this; } public Object clone() { return this; }
@Override @Override
public List<char[]> toList() { return Collections.emptyList(); } public List<char[]> toList() { return Collections.emptyList(); }
@Override @Override
public void put( char[] key ) { throw new UnsupportedOperationException(); } public void put(char[] key) { throw new UnsupportedOperationException(); }
@Override @Override
public void addAll( List<char[]> list ) { throw new UnsupportedOperationException(); } public void addAll(List<char[]> list) { throw new UnsupportedOperationException(); }
@Override @Override
public void addAll( CharArraySet set ) { throw new UnsupportedOperationException(); } public void addAll(CharArraySet set) { throw new UnsupportedOperationException(); }
}; };
public CharArraySet(int initialSize) { public CharArraySet(int initialSize) {
super(initialSize); super(initialSize);
} }
public void put(char[] key ){ public void put(char[] key) {
addIndex(key); addIndex(key);
} }
public void addAll( List<char[]> list ){ public void addAll(List<char[]> list) {
if( list == null ) if (list == null)
return; return;
int size = list.size(); int size = list.size();
for( int i = 0; i < size; i++ ){ for (int i = 0; i < size; i++) {
addIndex( list.get( i ) ); addIndex(list.get(i));
} }
} }
public void addAll( CharArraySet set ){ public void addAll(CharArraySet set) {
if( set == null ) if (set == null)
return; return;
int size = set.size(); int size = set.size();
for( int i = 0; i < size; i++ ){ for (int i = 0; i < size; i++) {
addIndex( set.keyAt( i ) ); addIndex(set.keyAt(i));
} }
} }
final public boolean remove( char[] key ) { final public boolean remove(char[] key) {
int i = lookup(key); int i = lookup(key);
if (i < 0) if (i < 0)
return false; return false;
@ -65,11 +65,11 @@ public class CharArraySet extends CharTable {
} }
@Override @Override
final public void clear(){ final public void clear() {
for( int i = 0; i < keyTable.length; i++ ){ for (int i = 0; i < keyTable.length; i++) {
keyTable[i] = null; keyTable[i] = null;
hashTable[ 2*i ] = 0; hashTable[2 * i] = 0;
hashTable[ 2*i + 1 ] = 0; hashTable[2 * i + 1] = 0;
nextTable[i] = 0; nextTable[i] = 0;
} }
currEntry = -1; currEntry = -1;

View file

@ -291,7 +291,7 @@ public class CharArrayUtils {
return -1; return -1;
} }
final static public char[] trim(char[] chars) { static final public char[] trim(char[] chars) {
if (chars == null) if (chars == null)
return null; return null;
@ -308,7 +308,7 @@ public class CharArrayUtils {
return chars; return chars;
} }
final static public char[] lastSegment(char[] array, char[] separator) { static final public char[] lastSegment(char[] array, char[] separator) {
int pos = lastIndexOf(separator, array); int pos = lastIndexOf(separator, array);
if (pos < 0) if (pos < 0)
return array; return array;

View file

@ -10,7 +10,6 @@
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser.util; package org.eclipse.cdt.core.parser.util;
import java.util.ArrayList; import java.util.ArrayList;
@ -18,7 +17,6 @@ import java.util.List;
/** /**
* @author ddaoust * @author ddaoust
*
*/ */
public class CharTable extends HashTable { public class CharTable extends HashTable {
protected char[][] keyTable; protected char[][] keyTable;
@ -39,12 +37,12 @@ public class CharTable extends HashTable {
@Override @Override
public void clear() { public void clear() {
super.clear(); super.clear();
for( int i = 0; i < capacity(); i++ ) for (int i = 0; i < capacity(); i++)
keyTable[i] = null; keyTable[i] = null;
} }
@Override @Override
public Object clone(){ public Object clone() {
CharTable newTable = (CharTable) super.clone(); CharTable newTable = (CharTable) super.clone();
int size = capacity(); int size = capacity();
@ -59,53 +57,49 @@ public class CharTable extends HashTable {
} }
@Override @Override
protected final int hash( int pos ){ protected final int hash(int pos) {
return hash(keyTable[pos], 0, keyTable[pos].length); return hash(keyTable[pos], 0, keyTable[pos].length);
} }
protected final int hash( char[] obj ){ protected final int hash(char[] obj) {
return hash( obj, 0, obj.length ); return hash(obj, 0, obj.length);
} }
protected final int addIndex(char[] buffer ) { protected final int addIndex(char[] buffer) {
return addIndex(buffer, 0, buffer.length); return addIndex(buffer, 0, buffer.length);
} }
public final int addIndex(char[] buffer, int start, int len) { public final int addIndex(char[] buffer, int start, int len) {
if (hashTable != null) if (hashTable != null) {
{
int hash = hash(buffer, start, len); int hash = hash(buffer, start, len);
int pos = lookup(buffer, start, len, hash); int pos = lookup(buffer, start, len, hash);
if (pos != -1) if (pos != -1)
return pos; return pos;
// key is not here, add it. // key is not here, add it.
if( (currEntry + 1) >= capacity()) { if ((currEntry + 1) >= capacity()) {
resize(); resize();
hash = hash(buffer, start, len); hash = hash(buffer, start, len);
} }
currEntry++; currEntry++;
keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len); keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len);
linkIntoHashTable(currEntry, hash); linkIntoHashTable(currEntry, hash);
} } else {
else
{
int pos = lookup(buffer, start, len); int pos = lookup(buffer, start, len);
if (pos != -1) if (pos != -1)
return pos; return pos;
// key is not here, add it. // key is not here, add it.
if( (currEntry + 1) >= capacity()) { if ((currEntry + 1) >= capacity()) {
resize(); resize();
if( capacity() > minHashSize ){ if (capacity() > minHashSize) {
//if we grew from list to hash, then recurse and add as a hashtable //if we grew from list to hash, then recurse and add as a hashtable
return addIndex( buffer, start, len ); return addIndex(buffer, start, len);
} }
} }
currEntry++; currEntry++;
keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len); keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len);
} }
return currEntry; return currEntry;
} }
protected void removeEntry(int i) { protected void removeEntry(int i) {
@ -120,17 +114,17 @@ public class CharTable extends HashTable {
removeEntry(i, hash); removeEntry(i, hash);
} }
public List<char[]> toList(){ public List<char[]> toList() {
List<char[]> list = new ArrayList<char[]>( size() ); List<char[]> list = new ArrayList<char[]>(size());
int size = size(); int size = size();
for( int i = 0; i < size; i++ ){ for (int i = 0; i < size; i++) {
list.add( keyAt( i ) ); list.add(keyAt(i));
} }
return list; return list;
} }
public final char[] keyAt( int i ){ public final char[] keyAt(int i) {
if( i < 0 || i > currEntry ) if (i < 0 || i > currEntry)
return null; return null;
return keyTable[ i ]; return keyTable[ i ];
@ -140,25 +134,25 @@ public class CharTable extends HashTable {
return lookup(key, start, len) != -1; return lookup(key, start, len) != -1;
} }
public final boolean containsKey(char[] key){ public final boolean containsKey(char[] key) {
return lookup(key) != -1; return lookup(key) != -1;
} }
public final char[] findKey( char[] buffer, int start, int len ){ public final char[] findKey(char[] buffer, int start, int len) {
int idx = lookup( buffer, start, len ); int idx = lookup(buffer, start, len);
if( idx == -1 ) if (idx == -1)
return null; return null;
return keyTable[ idx ]; return keyTable[ idx ];
} }
public int lookup(char[] buffer ){ public int lookup(char[] buffer) {
return lookup(buffer, 0, buffer.length); return lookup(buffer, 0, buffer.length);
} }
protected final int lookup(char[] buffer, int start, int len) { protected final int lookup(char[] buffer, int start, int len) {
if (hashTable != null) if (hashTable != null)
return lookup(buffer, start, len, hash(buffer, start, len) ); return lookup(buffer, start, len, hash(buffer, start, len));
for (int i = 0; i <= currEntry; i++) { for (int i = 0; i <= currEntry; i++) {
if (CharArrayUtils.equals(buffer, start, len, keyTable[i])) if (CharArrayUtils.equals(buffer, start, len, keyTable[i]))
return i; return i;
@ -182,9 +176,9 @@ public class CharTable extends HashTable {
return -1; return -1;
} }
public Object [] keyArray(){ public Object[] keyArray() {
Object [] keys = new Object[ size() ]; Object[] keys = new Object[ size() ];
System.arraycopy( keyTable, 0, keys, 0, keys.length ); System.arraycopy(keyTable, 0, keys, 0, keys.length);
return keys; return keys;
} }
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -19,13 +19,14 @@ import org.eclipse.cdt.internal.core.model.ASTStringUtil;
* Base for all c++ declaration specifiers * Base for all c++ declaration specifiers
*/ */
public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPASTDeclSpecifier { public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPASTDeclSpecifier {
private boolean friend; private boolean friend;
private boolean inline; private boolean inline;
private boolean isConst; private boolean isConst;
private boolean isConstexpr;
private boolean isVolatile; private boolean isVolatile;
private boolean isRestrict; private boolean isRestrict;
private int sc; private int sc;
private boolean isThreadLocal;
private boolean virtual; private boolean virtual;
private boolean explicit; private boolean explicit;
@ -45,6 +46,17 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
sc = storageClass; sc = storageClass;
} }
@Override
public boolean isThreadLocal() {
return isThreadLocal;
}
@Override
public void setThreadLocal(boolean value) {
assertNotFrozen();
isThreadLocal = value;
}
@Override @Override
public boolean isConst() { public boolean isConst() {
return isConst; return isConst;
@ -56,6 +68,17 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
isConst = value; isConst = value;
} }
@Override
public boolean isConstexpr() {
return isConstexpr;
}
@Override
public void setConstexpr(boolean value) {
assertNotFrozen();
isConstexpr = value;
}
@Override @Override
public boolean isVolatile() { public boolean isVolatile() {
return isVolatile; return isVolatile;
@ -117,17 +140,18 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
this.explicit = value; this.explicit = value;
} }
protected void copyBaseDeclSpec(CPPASTBaseDeclSpecifier other) { protected <T extends CPPASTBaseDeclSpecifier> T copy(T copy, CopyStyle style) {
other.friend = friend; copy.friend = friend;
other.inline = inline; copy.inline = inline;
other.isConst = isConst; copy.isConst = isConst;
other.isVolatile = isVolatile; copy.isConstexpr = isConstexpr;
other.isRestrict= isRestrict; copy.isVolatile = isVolatile;
other.virtual = virtual; copy.isRestrict= isRestrict;
other.explicit = explicit; copy.virtual = virtual;
other.sc = sc; copy.explicit = explicit;
other.setOffsetAndLength(this); copy.sc = sc;
} return super.copy(copy, style);
}
/** /**
* Provided for debugging purposes, only. * Provided for debugging purposes, only.

View file

@ -61,16 +61,11 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
public CPPASTCompositeTypeSpecifier copy(CopyStyle style) { public CPPASTCompositeTypeSpecifier copy(CopyStyle style) {
CPPASTCompositeTypeSpecifier copy = CPPASTCompositeTypeSpecifier copy =
new CPPASTCompositeTypeSpecifier(fKey, fName == null ? null : fName.copy(style)); new CPPASTCompositeTypeSpecifier(fKey, fName == null ? null : fName.copy(style));
copyBaseDeclSpec(copy);
for (IASTDeclaration member : getMembers()) for (IASTDeclaration member : getMembers())
copy.addMemberDeclaration(member == null ? null : member.copy(style)); copy.addMemberDeclaration(member == null ? null : member.copy(style));
for (ICPPASTBaseSpecifier baseSpecifier : getBaseSpecifiers()) for (ICPPASTBaseSpecifier baseSpecifier : getBaseSpecifiers())
copy.addBaseSpecifier(baseSpecifier == null ? null : baseSpecifier.copy(style)); copy.addBaseSpecifier(baseSpecifier == null ? null : baseSpecifier.copy(style));
return super.copy(copy, style);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
} }
@Override @Override

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -27,7 +27,6 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
*/ */
public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier
implements ICPPASTElaboratedTypeSpecifier, IASTInternalNameOwner { implements ICPPASTElaboratedTypeSpecifier, IASTInternalNameOwner {
private int kind; private int kind;
private IASTName name; private IASTName name;
@ -46,13 +45,9 @@ public class CPPASTElaboratedTypeSpecifier extends CPPASTBaseDeclSpecifier
@Override @Override
public CPPASTElaboratedTypeSpecifier copy(CopyStyle style) { public CPPASTElaboratedTypeSpecifier copy(CopyStyle style) {
CPPASTElaboratedTypeSpecifier copy = new CPPASTElaboratedTypeSpecifier(kind, name == null CPPASTElaboratedTypeSpecifier copy =
? null : name.copy(style)); new CPPASTElaboratedTypeSpecifier(kind, name == null ? null : name.copy(style));
copyBaseDeclSpec(copy); return super.copy(copy, style);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
} }
@Override @Override

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -24,16 +24,15 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalEnumerationSpecifier
*/ */
public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
implements IASTInternalEnumerationSpecifier, ICPPASTEnumerationSpecifier { implements IASTInternalEnumerationSpecifier, ICPPASTEnumerationSpecifier {
private boolean fIsScoped; private boolean fIsScoped;
private boolean fIsOpaque; private boolean fIsOpaque;
private IASTName fName; private IASTName fName;
private ICPPASTDeclSpecifier fBaseType; private ICPPASTDeclSpecifier fBaseType;
private IASTEnumerator[] fItems = null; private IASTEnumerator[] fItems;
private int fItemPos=-1; private int fItemPos= -1;
private boolean fValuesComputed= false; private boolean fValuesComputed;
private CPPEnumScope fScope; private CPPEnumScope fScope;
public CPPASTEnumerationSpecifier() { public CPPASTEnumerationSpecifier() {
@ -52,16 +51,14 @@ public class CPPASTEnumerationSpecifier extends CPPASTBaseDeclSpecifier
@Override @Override
public CPPASTEnumerationSpecifier copy(CopyStyle style) { public CPPASTEnumerationSpecifier copy(CopyStyle style) {
CPPASTEnumerationSpecifier copy = new CPPASTEnumerationSpecifier(fIsScoped, fName == null CPPASTEnumerationSpecifier copy =
? null : fName.copy(style), fBaseType == null ? null : fBaseType.copy(style)); new CPPASTEnumerationSpecifier(fIsScoped, fName == null ? null : fName.copy(style),
fBaseType == null ? null : fBaseType.copy(style));
copy.fIsOpaque = fIsOpaque; copy.fIsOpaque = fIsOpaque;
for (IASTEnumerator enumerator : getEnumerators()) for (IASTEnumerator enumerator : getEnumerators()) {
copy.addEnumerator(enumerator == null ? null : enumerator.copy(style)); copy.addEnumerator(enumerator == null ? null : enumerator.copy(style));
copyBaseDeclSpec(copy);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
} }
return copy; return super.copy(copy, style);
} }
@Override @Override

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -26,13 +26,11 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier
ICPPASTNamedTypeSpecifier, ICPPASTCompletionContext { implements ICPPASTNamedTypeSpecifier, ICPPASTCompletionContext {
private boolean typename; private boolean typename;
private IASTName name; private IASTName name;
public CPPASTNamedTypeSpecifier() { public CPPASTNamedTypeSpecifier() {
} }
@ -47,14 +45,10 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements
@Override @Override
public CPPASTNamedTypeSpecifier copy(CopyStyle style) { public CPPASTNamedTypeSpecifier copy(CopyStyle style) {
CPPASTNamedTypeSpecifier copy = new CPPASTNamedTypeSpecifier(name == null ? null CPPASTNamedTypeSpecifier copy =
: name.copy(style)); new CPPASTNamedTypeSpecifier(name == null ? null : name.copy(style));
copyBaseDeclSpec(copy);
copy.typename = typename; copy.typename = typename;
if (style == CopyStyle.withLocations) { return super.copy(copy, style);
copy.setCopyLocation(this);
}
return copy;
} }
@Override @Override
@ -73,7 +67,6 @@ public class CPPASTNamedTypeSpecifier extends CPPASTBaseDeclSpecifier implements
return name; return name;
} }
@Override @Override
public void setName(IASTName name) { public void setName(IASTName name) {
assertNotFrozen(); assertNotFrozen();

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -18,16 +18,16 @@ import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implements ICPPASTSimpleDeclSpecifier, public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
IASTAmbiguityParent { implements ICPPASTSimpleDeclSpecifier, IASTAmbiguityParent {
private int type; private int type;
private boolean isSigned; private boolean isSigned;
private boolean isUnsigned; private boolean isUnsigned;
private boolean isShort; private boolean isShort;
private boolean isLong; private boolean isLong;
private boolean isLonglong; private boolean isLonglong;
private boolean isComplex=false; private boolean isComplex;
private boolean isImaginary=false; private boolean isImaginary;
private IASTExpression fDeclTypeExpression; private IASTExpression fDeclTypeExpression;
@Override @Override
@ -37,27 +37,22 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier implement
@Override @Override
public CPPASTSimpleDeclSpecifier copy(CopyStyle style) { public CPPASTSimpleDeclSpecifier copy(CopyStyle style) {
CPPASTSimpleDeclSpecifier copy = new CPPASTSimpleDeclSpecifier(); return copy(new CPPASTSimpleDeclSpecifier(), style);
copySimpleDeclSpec(copy, style);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
} }
protected void copySimpleDeclSpec(CPPASTSimpleDeclSpecifier other, CopyStyle style) { protected <T extends CPPASTSimpleDeclSpecifier> T copy(T copy, CopyStyle style) {
copyBaseDeclSpec(other); copy.type = type;
other.type = type; copy.isSigned = isSigned;
other.isSigned = isSigned; copy.isUnsigned = isUnsigned;
other.isUnsigned = isUnsigned; copy.isShort = isShort;
other.isShort = isShort; copy.isLong = isLong;
other.isLong = isLong; copy.isLonglong= isLonglong;
other.isLonglong= isLonglong; copy.isComplex= isComplex;
other.isComplex= isComplex; copy.isImaginary= isImaginary;
other.isImaginary= isImaginary;
if (fDeclTypeExpression != null) { if (fDeclTypeExpression != null) {
other.setDeclTypeExpression(fDeclTypeExpression.copy(style)); copy.setDeclTypeExpression(fDeclTypeExpression.copy(style));
} }
return super.copy(copy, style);
} }
/** /**

View file

@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
* The result of instantiating a class template. * The result of instantiating a class template.
*/ */
public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemplateInstance { public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemplateInstance {
private ICPPTemplateArgument[] arguments; private final ICPPTemplateArgument[] arguments;
public CPPClassInstance(ICPPClassType orig, IBinding owner, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args) { public CPPClassInstance(ICPPClassType orig, IBinding owner, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args) {
super(orig, owner, argMap); super(orig, owner, argMap);
@ -52,6 +52,8 @@ public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemp
protected ICPPClassSpecializationScope getSpecializationScope() { protected ICPPClassSpecializationScope getSpecializationScope() {
// An instance with a declaration has no specialization scope. // An instance with a declaration has no specialization scope.
checkForDefinition(); checkForDefinition();
if (getDefinition() != null)
return null;
final IASTNode[] decls = getDeclarations(); final IASTNode[] decls = getDeclarations();
if (decls != null && decls.length > 0 && decls[0] != null) if (decls != null && decls.length > 0 && decls[0] != null)
return null; return null;

View file

@ -2593,11 +2593,11 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
} }
private final static int INLINE=0x1, CONST=0x2, RESTRICT=0x4, VOLATILE=0x8, private final static int INLINE= 0x1, CONST= 0x2, CONSTEXPR= 0x4, RESTRICT= 0x8, VOLATILE= 0x10,
SHORT=0x10, UNSIGNED= 0x20, SIGNED=0x40, COMPLEX=0x80, IMAGINARY=0x100, SHORT= 0x20, UNSIGNED= 0x40, SIGNED= 0x80, COMPLEX= 0x100, IMAGINARY= 0x200,
VIRTUAL=0x200, EXPLICIT=0x400, FRIEND=0x800; VIRTUAL= 0x400, EXPLICIT= 0x800, FRIEND= 0x1000, THREAD_LOCAL= 0x2000;
private static final int FORBID_IN_EMPTY_DECLSPEC = private static final int FORBID_IN_EMPTY_DECLSPEC =
CONST | RESTRICT | VOLATILE | SHORT | UNSIGNED | SIGNED | COMPLEX | IMAGINARY | FRIEND; CONST | RESTRICT | VOLATILE | SHORT | UNSIGNED | SIGNED | COMPLEX | IMAGINARY | FRIEND | THREAD_LOCAL;
/** /**
@ -2606,7 +2606,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
* declSpecifier : * declSpecifier :
* "register" | "static" | "extern" | "mutable" | * "register" | "static" | "extern" | "mutable" |
* "inline" | "virtual" | "explicit" | * "inline" | "virtual" | "explicit" |
* "typedef" | "friend" | * "typedef" | "friend" | "constexpr" |
* "const" | "volatile" | * "const" | "volatile" |
* "short" | "long" | "signed" | "unsigned" | "int" | * "short" | "long" | "signed" | "unsigned" | "int" |
* "char" | "wchar_t" | "bool" | "float" | "double" | "void" | * "char" | "wchar_t" | "bool" | "float" | "double" | "void" |
@ -2682,6 +2682,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
storageClass = IASTDeclSpecifier.sc_extern; storageClass = IASTDeclSpecifier.sc_extern;
endOffset= consume().getEndOffset(); endOffset= consume().getEndOffset();
break; break;
case IToken.t_thread_local:
options |= THREAD_LOCAL; // thread_local may appear with static or extern
endOffset= consume().getEndOffset();
break;
case IToken.t_mutable: case IToken.t_mutable:
storageClass = IASTDeclSpecifier.sc_mutable; storageClass = IASTDeclSpecifier.sc_mutable;
endOffset= consume().getEndOffset(); endOffset= consume().getEndOffset();
@ -2707,6 +2711,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
options |= FRIEND; options |= FRIEND;
endOffset= consume().getEndOffset(); endOffset= consume().getEndOffset();
break; break;
case IToken.t_constexpr:
options |= CONSTEXPR;
endOffset= consume().getEndOffset();
break;
// type specifier // type specifier
case IToken.t_const: case IToken.t_const:
options |= CONST; options |= CONST;
@ -3007,12 +3015,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private void configureDeclSpec(ICPPASTDeclSpecifier declSpec, int storageClass, int options) { private void configureDeclSpec(ICPPASTDeclSpecifier declSpec, int storageClass, int options) {
declSpec.setStorageClass(storageClass); declSpec.setStorageClass(storageClass);
declSpec.setConst((options & CONST) != 0); declSpec.setConst((options & CONST) != 0);
declSpec.setConstexpr((options & CONSTEXPR) != 0);
declSpec.setVolatile((options & VOLATILE) != 0); declSpec.setVolatile((options & VOLATILE) != 0);
declSpec.setInline((options & INLINE) != 0); declSpec.setInline((options & INLINE) != 0);
declSpec.setFriend((options & FRIEND) != 0); declSpec.setFriend((options & FRIEND) != 0);
declSpec.setVirtual((options & VIRTUAL) != 0); declSpec.setVirtual((options & VIRTUAL) != 0);
declSpec.setExplicit((options & EXPLICIT) != 0); declSpec.setExplicit((options & EXPLICIT) != 0);
declSpec.setRestrict((options & RESTRICT) != 0); declSpec.setRestrict((options & RESTRICT) != 0);
declSpec.setThreadLocal((options & THREAD_LOCAL) != 0);
} }
private ICPPASTDeclSpecifier enumDeclaration(boolean allowOpaque) throws BacktrackException, EndOfFileException { private ICPPASTDeclSpecifier enumDeclaration(boolean allowOpaque) throws BacktrackException, EndOfFileException {

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -18,8 +18,8 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
* @deprecated Replaced by {@link CPPASTSimpleDeclSpecifier} * @deprecated Replaced by {@link CPPASTSimpleDeclSpecifier}
*/ */
@Deprecated @Deprecated
public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier implements public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier
IGPPASTSimpleDeclSpecifier { implements IGPPASTSimpleDeclSpecifier {
public GPPASTSimpleDeclSpecifier() { public GPPASTSimpleDeclSpecifier() {
} }
@ -36,12 +36,7 @@ public class GPPASTSimpleDeclSpecifier extends CPPASTSimpleDeclSpecifier impleme
@Override @Override
public GPPASTSimpleDeclSpecifier copy(CopyStyle style) { public GPPASTSimpleDeclSpecifier copy(CopyStyle style) {
GPPASTSimpleDeclSpecifier copy = new GPPASTSimpleDeclSpecifier(); return copy(new GPPASTSimpleDeclSpecifier(), style);
copySimpleDeclSpec(copy, style);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
}
return copy;
} }
@Override @Override

View file

@ -250,7 +250,7 @@ class BaseClassLookup {
continue; continue;
final IName nbaseName = nbase.getBaseClassSpecifierName(); final IName nbaseName = nbase.getBaseClassSpecifierName();
int cmp= baseName == null ? -1 : CPPSemantics.compareByRelevance(data, baseName, nbaseName); int cmp= baseName == null ? 0 : CPPSemantics.compareByRelevance(data, baseName, nbaseName);
if (cmp <= 0) { if (cmp <= 0) {
if (cmp < 0) { if (cmp < 0) {
selectedBases.clear(); selectedBases.clear();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others * Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -8,6 +8,7 @@
* *
* Contributors: * Contributors:
* Institute for Software - initial API and implementation * Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@ -44,22 +45,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
* @author Emanuel Graf IFS * @author Emanuel Graf IFS
*/ */
public class DeclSpecWriter extends NodeWriter { public class DeclSpecWriter extends NodeWriter {
private static final String MUTABLE = "mutable "; //$NON-NLS-1$
private static final String _COMPLEX = "_Complex "; //$NON-NLS-1$
private static final String LONG_LONG = "long long "; //$NON-NLS-1$
private static final String REGISTER = "register "; //$NON-NLS-1$
private static final String AUTO = "auto "; //$NON-NLS-1$
private static final String TYPEDEF = "typedef "; //$NON-NLS-1$
private static final String UNION = "union"; //$NON-NLS-1$
private static final String STRUCT = "struct"; //$NON-NLS-1$
private static final String CLASS = "class"; //$NON-NLS-1$
private static final String FRIEND = "friend "; //$NON-NLS-1$
private static final String EXPLICIT = "explicit "; //$NON-NLS-1$
private static final String VIRTUAL = "virtual "; //$NON-NLS-1$
private static final String UNION_SPACE = "union "; //$NON-NLS-1$
private static final String STRUCT_SPACE = "struct "; //$NON-NLS-1$
private static final String ENUM = "enum "; //$NON-NLS-1$
private static final String _BOOL = "_Bool"; //$NON-NLS-1$
public DeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { public DeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
super(scribe, visitor, commentMap); super(scribe, visitor, commentMap);
@ -88,23 +73,23 @@ public class DeclSpecWriter extends NodeWriter {
case IASTSimpleDeclSpecifier.t_unspecified: case IASTSimpleDeclSpecifier.t_unspecified:
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
case IASTSimpleDeclSpecifier.t_void: case IASTSimpleDeclSpecifier.t_void:
return VOID; return Keywords.VOID;
case IASTSimpleDeclSpecifier.t_char: case IASTSimpleDeclSpecifier.t_char:
return CHAR; return Keywords.CHAR;
case IASTSimpleDeclSpecifier.t_int: case IASTSimpleDeclSpecifier.t_int:
return INT; return Keywords.INT;
case IASTSimpleDeclSpecifier.t_float: case IASTSimpleDeclSpecifier.t_float:
return FLOAT; return Keywords.FLOAT;
case IASTSimpleDeclSpecifier.t_double: case IASTSimpleDeclSpecifier.t_double:
return DOUBLE; return Keywords.DOUBLE;
case IASTSimpleDeclSpecifier.t_bool: case IASTSimpleDeclSpecifier.t_bool:
return isCpp ? CPP_BOOL : _BOOL; return isCpp ? Keywords.BOOL : Keywords._BOOL;
case IASTSimpleDeclSpecifier.t_wchar_t: case IASTSimpleDeclSpecifier.t_wchar_t:
if (isCpp) if (isCpp)
return WCHAR_T; return Keywords.WCHAR_T;
break; break;
case IASTSimpleDeclSpecifier.t_char16_t: case IASTSimpleDeclSpecifier.t_char16_t:
if (isCpp) if (isCpp)
@ -133,7 +118,7 @@ public class DeclSpecWriter extends NodeWriter {
private void writeCDeclSpec(ICASTDeclSpecifier cDeclSpec) { private void writeCDeclSpec(ICASTDeclSpecifier cDeclSpec) {
if (cDeclSpec.isRestrict()) { if (cDeclSpec.isRestrict()) {
scribe.print(RESTRICT); scribe.printStringSpace(Keywords.RESTRICT);
} }
if (cDeclSpec instanceof ICASTCompositeTypeSpecifier) { if (cDeclSpec instanceof ICASTCompositeTypeSpecifier) {
@ -151,7 +136,7 @@ public class DeclSpecWriter extends NodeWriter {
private void writeNamedTypeSpecifier(ICPPASTNamedTypeSpecifier namedSpc) { private void writeNamedTypeSpecifier(ICPPASTNamedTypeSpecifier namedSpc) {
if (namedSpc.isTypename()) { if (namedSpc.isTypename()) {
scribe.print(TYPENAME); scribe.printStringSpace(Keywords.TYPENAME);
} }
namedSpc.getName().accept(visitor); namedSpc.getName().accept(visitor);
} }
@ -161,20 +146,20 @@ public class DeclSpecWriter extends NodeWriter {
} }
private void writeElaboratedTypeSec(IASTElaboratedTypeSpecifier elabType) { private void writeElaboratedTypeSec(IASTElaboratedTypeSpecifier elabType) {
scribe.print(getElabTypeString(elabType.getKind())); scribe.printStringSpace(getElabTypeString(elabType.getKind()));
elabType.getName().accept(visitor); elabType.getName().accept(visitor);
} }
private String getElabTypeString(int kind) { private String getElabTypeString(int kind) {
switch (kind) { switch (kind) {
case IASTElaboratedTypeSpecifier.k_enum: case IASTElaboratedTypeSpecifier.k_enum:
return ENUM; return Keywords.ENUM;
case IASTElaboratedTypeSpecifier.k_struct: case IASTElaboratedTypeSpecifier.k_struct:
return STRUCT_SPACE; return Keywords.STRUCT;
case IASTElaboratedTypeSpecifier.k_union: case IASTElaboratedTypeSpecifier.k_union:
return UNION_SPACE; return Keywords.UNION;
case ICPPASTElaboratedTypeSpecifier.k_class: case ICPPASTElaboratedTypeSpecifier.k_class:
return CLASS_SPACE; return Keywords.CLASS;
default: default:
throw new IllegalArgumentException("Unknown elaborated type: " + kind); //$NON-NLS-1$ throw new IllegalArgumentException("Unknown elaborated type: " + kind); //$NON-NLS-1$
@ -183,16 +168,22 @@ public class DeclSpecWriter extends NodeWriter {
private void writeCPPDeclSpec(ICPPASTDeclSpecifier cppDelcSpec) { private void writeCPPDeclSpec(ICPPASTDeclSpecifier cppDelcSpec) {
if (cppDelcSpec.isVirtual()) { if (cppDelcSpec.isVirtual()) {
scribe.print(VIRTUAL); scribe.printStringSpace(Keywords.VIRTUAL);
}
if (cppDelcSpec.isConstexpr()) {
scribe.printStringSpace(Keywords.CONSTEXPR);
} }
if (cppDelcSpec.isExplicit()) { if (cppDelcSpec.isExplicit()) {
scribe.print(EXPLICIT); scribe.printStringSpace(Keywords.EXPLICIT);
} }
if (cppDelcSpec.isFriend()) { if (cppDelcSpec.isFriend()) {
scribe.print(FRIEND); scribe.printStringSpace(Keywords.FRIEND);
}
if (cppDelcSpec.isThreadLocal()) {
scribe.printStringSpace(Keywords.THREAD_LOCAL);
} }
if (cppDelcSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) { if (cppDelcSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
scribe.print(MUTABLE); scribe.printStringSpace(Keywords.MUTABLE);
} }
if (cppDelcSpec instanceof ICPPASTCompositeTypeSpecifier) { if (cppDelcSpec instanceof ICPPASTCompositeTypeSpecifier) {
@ -209,7 +200,7 @@ public class DeclSpecWriter extends NodeWriter {
} }
private void writeEnumSpec(IASTEnumerationSpecifier enumSpec) { private void writeEnumSpec(IASTEnumerationSpecifier enumSpec) {
scribe.print(ENUM); scribe.printStringSpace(Keywords.ENUM);
enumSpec.getName().accept(visitor); enumSpec.getName().accept(visitor);
scribe.print('{'); scribe.print('{');
scribe.printSpace(); scribe.printSpace();
@ -284,13 +275,13 @@ public class DeclSpecWriter extends NodeWriter {
private void writeBaseSpecifiers(ICPPASTBaseSpecifier specifier) { private void writeBaseSpecifiers(ICPPASTBaseSpecifier specifier) {
switch (specifier.getVisibility()) { switch (specifier.getVisibility()) {
case ICPPASTBaseSpecifier.v_public: case ICPPASTBaseSpecifier.v_public:
scribe.printStringSpace(PUBLIC); scribe.printStringSpace(Keywords.PUBLIC);
break; break;
case ICPPASTBaseSpecifier.v_protected: case ICPPASTBaseSpecifier.v_protected:
scribe.printStringSpace(PROTECTED); scribe.printStringSpace(Keywords.PROTECTED);
break; break;
case ICPPASTBaseSpecifier.v_private: case ICPPASTBaseSpecifier.v_private:
scribe.printStringSpace(PRIVATE); scribe.printStringSpace(Keywords.PRIVATE);
break; break;
} }
specifier.getName().accept(visitor); specifier.getName().accept(visitor);
@ -302,7 +293,7 @@ public class DeclSpecWriter extends NodeWriter {
} }
switch (key) { switch (key) {
case ICPPASTCompositeTypeSpecifier.k_class: case ICPPASTCompositeTypeSpecifier.k_class:
return CLASS; return Keywords.CLASS;
default: default:
throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$ throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
} }
@ -311,9 +302,9 @@ public class DeclSpecWriter extends NodeWriter {
private String getCompositeTypeString(int key) { private String getCompositeTypeString(int key) {
switch (key) { switch (key) {
case IASTCompositeTypeSpecifier.k_struct: case IASTCompositeTypeSpecifier.k_struct:
return STRUCT; return Keywords.STRUCT;
case IASTCompositeTypeSpecifier.k_union: case IASTCompositeTypeSpecifier.k_union:
return UNION; return Keywords.UNION;
default: default:
throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$ throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
} }
@ -321,30 +312,30 @@ public class DeclSpecWriter extends NodeWriter {
private void writeDeclSpec(IASTDeclSpecifier declSpec) { private void writeDeclSpec(IASTDeclSpecifier declSpec) {
if (declSpec.isInline()) { if (declSpec.isInline()) {
scribe.print(INLINE); scribe.printStringSpace(Keywords.INLINE);
} }
switch (declSpec.getStorageClass()) { switch (declSpec.getStorageClass()) {
case IASTDeclSpecifier.sc_typedef: case IASTDeclSpecifier.sc_typedef:
scribe.print(TYPEDEF); scribe.printStringSpace(Keywords.TYPEDEF);
break; break;
case IASTDeclSpecifier.sc_extern: case IASTDeclSpecifier.sc_extern:
scribe.print(EXTERN); scribe.printStringSpace(Keywords.EXTERN);
break; break;
case IASTDeclSpecifier.sc_static: case IASTDeclSpecifier.sc_static:
scribe.print(STATIC); scribe.printStringSpace(Keywords.STATIC);
break; break;
case IASTDeclSpecifier.sc_auto: case IASTDeclSpecifier.sc_auto:
scribe.print(AUTO); scribe.printStringSpace(Keywords.AUTO);
break; break;
case IASTDeclSpecifier.sc_register: case IASTDeclSpecifier.sc_register:
scribe.print(REGISTER); scribe.printStringSpace(Keywords.REGISTER);
break; break;
} }
if (declSpec.isConst()) { if (declSpec.isConst()) {
scribe.printStringSpace(CONST); scribe.printStringSpace(Keywords.CONST);
} }
if (declSpec.isVolatile()) { if (declSpec.isVolatile()) {
scribe.printStringSpace(VOLATILE); scribe.printStringSpace(Keywords.VOLATILE);
} }
} }
@ -363,22 +354,23 @@ public class DeclSpecWriter extends NodeWriter {
private void printQualifiers(IASTSimpleDeclSpecifier simpDeclSpec) { private void printQualifiers(IASTSimpleDeclSpecifier simpDeclSpec) {
if (simpDeclSpec.isSigned()) { if (simpDeclSpec.isSigned()) {
scribe.printStringSpace(SIGNED); scribe.printStringSpace(Keywords.SIGNED);
} else if (simpDeclSpec.isUnsigned()) { } else if (simpDeclSpec.isUnsigned()) {
scribe.printStringSpace(UNSIGNED); scribe.printStringSpace(Keywords.UNSIGNED);
} }
if (simpDeclSpec.isShort()) { if (simpDeclSpec.isShort()) {
scribe.printStringSpace(SHORT); scribe.printStringSpace(Keywords.SHORT);
} else if (simpDeclSpec.isLong()) { } else if (simpDeclSpec.isLong()) {
scribe.printStringSpace(LONG); scribe.printStringSpace(Keywords.LONG);
} else if (simpDeclSpec.isLongLong()) { } else if (simpDeclSpec.isLongLong()) {
scribe.print(LONG_LONG); scribe.printStringSpace(Keywords.LONG);
scribe.printStringSpace(Keywords.LONG);
} }
if (simpDeclSpec instanceof ICASTSimpleDeclSpecifier) { if (simpDeclSpec instanceof ICASTSimpleDeclSpecifier) {
ICASTSimpleDeclSpecifier cSimpDeclSpec = (ICASTSimpleDeclSpecifier) simpDeclSpec; ICASTSimpleDeclSpecifier cSimpDeclSpec = (ICASTSimpleDeclSpecifier) simpDeclSpec;
if (cSimpDeclSpec.isComplex()) { if (cSimpDeclSpec.isComplex()) {
scribe.print(_COMPLEX); scribe.printStringSpace(Keywords._COMPLEX);
} }
} }
} }

View file

@ -51,10 +51,7 @@ public class DeclarationWriter extends NodeWriter {
private static final String ASM_END = ")"; //$NON-NLS-1$ private static final String ASM_END = ")"; //$NON-NLS-1$
private static final String ASM_START = "asm("; //$NON-NLS-1$ private static final String ASM_START = "asm("; //$NON-NLS-1$
private static final String TEMPLATE_DECLARATION = "template<"; //$NON-NLS-1$ private static final String TEMPLATE_DECLARATION = "template<"; //$NON-NLS-1$
private static final String EXPORT = "export "; //$NON-NLS-1$
private static final String TEMPLATE_SPECIALIZATION = "template <> "; //$NON-NLS-1$ private static final String TEMPLATE_SPECIALIZATION = "template <> "; //$NON-NLS-1$
private static final String NAMESPACE = "namespace "; //$NON-NLS-1$
private static final String USING = "using "; //$NON-NLS-1$
private boolean printSemicolon; private boolean printSemicolon;
public DeclarationWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { public DeclarationWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
@ -111,15 +108,15 @@ public class DeclarationWriter extends NodeWriter {
scribe.decrementIndentationLevel(); scribe.decrementIndentationLevel();
switch (visiblityLabel.getVisibility()) { switch (visiblityLabel.getVisibility()) {
case ICPPASTVisibilityLabel.v_private: case ICPPASTVisibilityLabel.v_private:
scribe.print(PRIVATE); scribe.print(Keywords.PRIVATE);
scribe.print(':'); scribe.print(':');
break; break;
case ICPPASTVisibilityLabel.v_protected: case ICPPASTVisibilityLabel.v_protected:
scribe.print(PROTECTED); scribe.print(Keywords.PROTECTED);
scribe.print(':'); scribe.print(':');
break; break;
case ICPPASTVisibilityLabel.v_public: case ICPPASTVisibilityLabel.v_public:
scribe.print(PUBLIC); scribe.print(Keywords.PUBLIC);
scribe.print(':'); scribe.print(':');
break; break;
default: default:
@ -129,15 +126,16 @@ public class DeclarationWriter extends NodeWriter {
} }
private void writeUsingDirective(ICPPASTUsingDirective usingDirective) { private void writeUsingDirective(ICPPASTUsingDirective usingDirective) {
scribe.print(USING + NAMESPACE); scribe.printStringSpace(Keywords.USING);
scribe.printStringSpace(Keywords.NAMESPACE);
usingDirective.getQualifiedName().accept(visitor); usingDirective.getQualifiedName().accept(visitor);
scribe.printSemicolon(); scribe.printSemicolon();
} }
private void writeUsingDeclaration(ICPPASTUsingDeclaration usingDeclaration) { private void writeUsingDeclaration(ICPPASTUsingDeclaration usingDeclaration) {
scribe.print(USING); scribe.printStringSpace(Keywords.USING);
if (usingDeclaration.isTypename()) { if (usingDeclaration.isTypename()) {
scribe.print(TYPENAME); scribe.printStringSpace(Keywords.TYPENAME);
} }
usingDeclaration.getName().accept(visitor); usingDeclaration.getName().accept(visitor);
scribe.printSemicolon(); scribe.printSemicolon();
@ -150,7 +148,7 @@ public class DeclarationWriter extends NodeWriter {
protected void writeTemplateDeclaration(ICPPASTTemplateDeclaration templateDeclaration) { protected void writeTemplateDeclaration(ICPPASTTemplateDeclaration templateDeclaration) {
if (templateDeclaration.isExported()) { if (templateDeclaration.isExported()) {
scribe.print(EXPORT); scribe.printStringSpace(Keywords.EXPORT);
} }
scribe.print(TEMPLATE_DECLARATION); scribe.print(TEMPLATE_DECLARATION);
ICPPASTTemplateParameter[] paraDecls = templateDeclaration.getTemplateParameters(); ICPPASTTemplateParameter[] paraDecls = templateDeclaration.getTemplateParameters();
@ -172,7 +170,7 @@ public class DeclarationWriter extends NodeWriter {
} }
private void writeNamespaceDefinition(ICPPASTNamespaceDefinition namespaceDefinition) { private void writeNamespaceDefinition(ICPPASTNamespaceDefinition namespaceDefinition) {
scribe.print(NAMESPACE); scribe.printStringSpace(Keywords.NAMESPACE);
namespaceDefinition.getName().accept(visitor); namespaceDefinition.getName().accept(visitor);
if (!hasTrailingComments(namespaceDefinition.getName())) { if (!hasTrailingComments(namespaceDefinition.getName())) {
scribe.newLine(); scribe.newLine();
@ -200,7 +198,7 @@ public class DeclarationWriter extends NodeWriter {
} }
private void writeNamespaceAlias(ICPPASTNamespaceAlias namespaceAliasDefinition) { private void writeNamespaceAlias(ICPPASTNamespaceAlias namespaceAliasDefinition) {
scribe.print(NAMESPACE); scribe.printStringSpace(Keywords.NAMESPACE);
namespaceAliasDefinition.getAlias().accept(visitor); namespaceAliasDefinition.getAlias().accept(visitor);
scribe.print(EQUALS); scribe.print(EQUALS);
namespaceAliasDefinition.getMappingName().accept(visitor); namespaceAliasDefinition.getMappingName().accept(visitor);
@ -208,9 +206,8 @@ public class DeclarationWriter extends NodeWriter {
} }
private void writeLinkageSpecification(ICPPASTLinkageSpecification linkageSpecification) { private void writeLinkageSpecification(ICPPASTLinkageSpecification linkageSpecification) {
scribe.print(EXTERN); scribe.printStringSpace(Keywords.EXTERN);
scribe.print(linkageSpecification.getLiteral()); scribe.printStringSpace(linkageSpecification.getLiteral());
scribe.printSpaces(1);
IASTDeclaration[] declarations = linkageSpecification.getDeclarations(); IASTDeclaration[] declarations = linkageSpecification.getDeclarations();
if (declarations.length > 1) { if (declarations.length > 1) {
@ -230,17 +227,17 @@ public class DeclarationWriter extends NodeWriter {
private void writeExplicitTemplateInstantiation(ICPPASTExplicitTemplateInstantiation explicitTemplateInstantiation) { private void writeExplicitTemplateInstantiation(ICPPASTExplicitTemplateInstantiation explicitTemplateInstantiation) {
switch(explicitTemplateInstantiation.getModifier()) { switch(explicitTemplateInstantiation.getModifier()) {
case ICPPASTExplicitTemplateInstantiation.EXTERN: case ICPPASTExplicitTemplateInstantiation.EXTERN:
scribe.print(EXTERN); scribe.printStringSpace(Keywords.EXTERN);
break; break;
case ICPPASTExplicitTemplateInstantiation.INLINE: case ICPPASTExplicitTemplateInstantiation.INLINE:
scribe.print(INLINE); scribe.printStringSpace(Keywords.INLINE);
break; break;
case ICPPASTExplicitTemplateInstantiation.STATIC: case ICPPASTExplicitTemplateInstantiation.STATIC:
scribe.print(STATIC); scribe.printStringSpace(Keywords.STATIC);
break; break;
} }
scribe.print(TEMPLATE); scribe.printStringSpace(Keywords.TEMPLATE);
explicitTemplateInstantiation.getDeclaration().accept(visitor); explicitTemplateInstantiation.getDeclaration().accept(visitor);
} }

View file

@ -9,6 +9,7 @@
* Contributors: * Contributors:
* Institute for Software - initial API and implementation * Institute for Software - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
@ -29,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/** /**
@ -41,7 +43,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
public class DeclaratorWriter extends NodeWriter { public class DeclaratorWriter extends NodeWriter {
private static final String AMPERSAND_AMPERSAND = "&&"; //$NON-NLS-1$ private static final String AMPERSAND_AMPERSAND = "&&"; //$NON-NLS-1$
private static final String PURE_VIRTUAL = " = 0"; //$NON-NLS-1$ private static final String PURE_VIRTUAL = " = 0"; //$NON-NLS-1$
private static final String MUTABLE = "mutable"; //$NON-NLS-1$
private static final String ARROW_OPERATOR = "->"; //$NON-NLS-1$ private static final String ARROW_OPERATOR = "->"; //$NON-NLS-1$
public DeclaratorWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) { public DeclaratorWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
@ -128,15 +129,15 @@ public class DeclaratorWriter extends NodeWriter {
private void writeCppFunctionDeclarator(ICPPASTFunctionDeclarator funcDec) { private void writeCppFunctionDeclarator(ICPPASTFunctionDeclarator funcDec) {
if (funcDec.isConst()) { if (funcDec.isConst()) {
scribe.printSpace(); scribe.printSpace();
scribe.print(CONST); scribe.print(Keywords.CONST);
} }
if (funcDec.isVolatile()) { if (funcDec.isVolatile()) {
scribe.printSpace(); scribe.printSpace();
scribe.print(VOLATILE); scribe.print(Keywords.VOLATILE);
} }
if (funcDec.isMutable()) { if (funcDec.isMutable()) {
scribe.printSpace(); scribe.printSpace();
scribe.print(MUTABLE); scribe.print(Keywords.MUTABLE);
} }
if (funcDec.isPureVirtual()) { if (funcDec.isPureVirtual()) {
scribe.print(PURE_VIRTUAL); scribe.print(PURE_VIRTUAL);
@ -153,7 +154,7 @@ public class DeclaratorWriter extends NodeWriter {
protected void writeExceptionSpecification(ICPPASTFunctionDeclarator funcDec, IASTTypeId[] exceptions) { protected void writeExceptionSpecification(ICPPASTFunctionDeclarator funcDec, IASTTypeId[] exceptions) {
if (exceptions != ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION) { if (exceptions != ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION) {
scribe.printSpace(); scribe.printSpace();
scribe.print(THROW); scribe.printStringSpace(Keywords.THROW);
scribe.print('('); scribe.print('(');
writeNodeList(exceptions); writeNodeList(exceptions);
scribe.print(')'); scribe.print(')');
@ -182,13 +183,13 @@ public class DeclaratorWriter extends NodeWriter {
} }
if (operator.isConst()) { if (operator.isConst()) {
scribe.printStringSpace(CONST); scribe.printStringSpace(Keywords.CONST);
} }
if (operator.isVolatile()) { if (operator.isVolatile()) {
scribe.printStringSpace(VOLATILE); scribe.printStringSpace(Keywords.VOLATILE);
} }
if (operator.isRestrict()) { if (operator.isRestrict()) {
scribe.print(RESTRICT); scribe.printStringSpace(Keywords.RESTRICT);
} }
} }

View file

@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/** /**
@ -112,6 +113,7 @@ public class ExpressionWriter extends NodeWriter{
private static final String OPENING_SQUARE_BRACKET = "["; //$NON-NLS-1$ private static final String OPENING_SQUARE_BRACKET = "["; //$NON-NLS-1$
private static final String CLOSING_SQUARE_BRACKET = "]"; //$NON-NLS-1$ private static final String CLOSING_SQUARE_BRACKET = "]"; //$NON-NLS-1$
private static final String THIS = "this"; //$NON-NLS-1$ private static final String THIS = "this"; //$NON-NLS-1$
private static final String THROW = "throw "; //$NON-NLS-1$
private final MacroExpansionHandler macroHandler; private final MacroExpansionHandler macroHandler;
public ExpressionWriter(Scribe scribe, ASTWriterVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) { public ExpressionWriter(Scribe scribe, ASTWriterVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) {
@ -423,7 +425,7 @@ public class ExpressionWriter extends NodeWriter{
if (fieldRef instanceof ICPPASTFieldReference) { if (fieldRef instanceof ICPPASTFieldReference) {
ICPPASTFieldReference cppFieldRef = (ICPPASTFieldReference) fieldRef; ICPPASTFieldReference cppFieldRef = (ICPPASTFieldReference) fieldRef;
if (cppFieldRef.isTemplate()) { if (cppFieldRef.isTemplate()) {
scribe.print(TEMPLATE); scribe.printStringSpace(Keywords.TEMPLATE);
} }
} }
fieldRef.getFieldName().accept(visitor); fieldRef.getFieldName().accept(visitor);

View file

@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeParameter; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeParameter;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
@ -58,7 +59,7 @@ public class NameWriter extends NodeWriter {
private void writeTempalteId(ICPPASTTemplateId tempId) { private void writeTempalteId(ICPPASTTemplateId tempId) {
if (needsTemplateQualifier(tempId)) { if (needsTemplateQualifier(tempId)) {
scribe.print(TEMPLATE); scribe.printStringSpace(Keywords.TEMPLATE);
} }
scribe.print(tempId.getTemplateName().toString()); scribe.print(tempId.getTemplateName().toString());
scribe.print('<'); scribe.print('<');

View file

@ -30,31 +30,7 @@ public class NodeWriter {
protected NodeCommentMap commentMap; protected NodeCommentMap commentMap;
protected static final String COMMA_SPACE = ", "; //$NON-NLS-1$ protected static final String COMMA_SPACE = ", "; //$NON-NLS-1$
protected static final String EQUALS = " = "; //$NON-NLS-1$ protected static final String EQUALS = " = "; //$NON-NLS-1$
protected static final String RESTRICT = "restrict "; //$NON-NLS-1$
protected static final String TYPENAME = "typename "; //$NON-NLS-1$
protected static final String PUBLIC = "public"; //$NON-NLS-1$
protected static final String PRIVATE = "private"; //$NON-NLS-1$
protected static final String PROTECTED = "protected"; //$NON-NLS-1$
protected static final String CONST = "const"; //$NON-NLS-1$
protected static final String VOLATILE = "volatile"; //$NON-NLS-1$
protected static final String INLINE = "inline "; //$NON-NLS-1$
protected static final String EXTERN = "extern "; //$NON-NLS-1$
protected static final String STATIC = "static "; //$NON-NLS-1$
protected static final String THROW = "throw "; //$NON-NLS-1$
protected static final String SPACE_COLON_SPACE = " : "; //$NON-NLS-1$ protected static final String SPACE_COLON_SPACE = " : "; //$NON-NLS-1$
protected static final String TEMPLATE = "template "; //$NON-NLS-1$
protected static final String DOUBLE = "double"; //$NON-NLS-1$
protected static final String FLOAT = "float"; //$NON-NLS-1$
protected static final String INT = "int"; //$NON-NLS-1$
protected static final String CHAR = "char"; //$NON-NLS-1$
protected static final String VOID = "void"; //$NON-NLS-1$
protected static final String WCHAR_T = "wchar_t"; //$NON-NLS-1$
protected static final String CPP_BOOL = "bool"; //$NON-NLS-1$
protected static final String LONG = "long"; //$NON-NLS-1$
protected static final String SHORT = "short"; //$NON-NLS-1$
protected static final String UNSIGNED = "unsigned"; //$NON-NLS-1$
protected static final String SIGNED = "signed"; //$NON-NLS-1$
protected static final String CLASS_SPACE = "class "; //$NON-NLS-1$
protected static final String VAR_ARGS = "..."; //$NON-NLS-1$ protected static final String VAR_ARGS = "..."; //$NON-NLS-1$
protected static final String COLON_COLON = "::"; //$NON-NLS-1$ protected static final String COLON_COLON = "::"; //$NON-NLS-1$
protected static final String COLON_SPACE = ": "; //$NON-NLS-1$ protected static final String COLON_SPACE = ": "; //$NON-NLS-1$

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
/** /**
@ -69,10 +70,10 @@ public class TemplateParameterWriter extends NodeWriter {
private void writeSimpleTypeTemplateParameter(ICPPASTSimpleTypeTemplateParameter simple) { private void writeSimpleTypeTemplateParameter(ICPPASTSimpleTypeTemplateParameter simple) {
switch (simple.getParameterType()) { switch (simple.getParameterType()) {
case ICPPASTSimpleTypeTemplateParameter.st_class: case ICPPASTSimpleTypeTemplateParameter.st_class:
scribe.print(CLASS_SPACE); scribe.printStringSpace(Keywords.CLASS);
break; break;
case ICPPASTSimpleTypeTemplateParameter.st_typename: case ICPPASTSimpleTypeTemplateParameter.st_typename:
scribe.print(TYPENAME); scribe.printStringSpace(Keywords.TYPENAME);
break; break;
} }

View file

@ -242,11 +242,12 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
private boolean fHandledCompletion= false; private boolean fHandledCompletion= false;
private boolean fSplitShiftRightOperator= false; private boolean fSplitShiftRightOperator= false;
// state information // State information
private final CharArrayMap<PreprocessorMacro> fMacroDictionary = new CharArrayMap<PreprocessorMacro>(512); private final CharArrayMap<PreprocessorMacro> fMacroDictionary = new CharArrayMap<PreprocessorMacro>(512);
private final IMacroDictionary fMacroDictionaryFacade = new MacroDictionary(); private final IMacroDictionary fMacroDictionaryFacade = new MacroDictionary();
private final LocationMap fLocationMap; private final LocationMap fLocationMap;
private CharArraySet fPreventInclusion= new CharArraySet(0); private CharArraySet fPreventInclusion;
private CharArraySet fImports;
private final ScannerContext fRootContext; private final ScannerContext fRootContext;
protected ScannerContext fCurrentContext; protected ScannerContext fCurrentContext;
@ -1233,11 +1234,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
switch (type) { switch (type) {
case IPreprocessorDirective.ppImport: case IPreprocessorDirective.ppImport:
case IPreprocessorDirective.ppInclude: case IPreprocessorDirective.ppInclude:
executeInclude(lexer, startOffset, false, fCurrentContext.getCodeState() == CodeState.eActive,
withinExpansion);
break;
case IPreprocessorDirective.ppInclude_next: case IPreprocessorDirective.ppInclude_next:
executeInclude(lexer, startOffset, true, fCurrentContext.getCodeState() == CodeState.eActive, executeInclude(lexer, startOffset, type, fCurrentContext.getCodeState() == CodeState.eActive,
withinExpansion); withinExpansion);
break; break;
case IPreprocessorDirective.ppDefine: case IPreprocessorDirective.ppDefine:
@ -1329,7 +1327,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
} }
} }
private void executeInclude(final Lexer lexer, int poundOffset, boolean include_next, private void executeInclude(final Lexer lexer, int poundOffset, int includeType,
boolean active, boolean withinExpansion) throws OffsetLimitReachedException { boolean active, boolean withinExpansion) throws OffsetLimitReachedException {
// Make sure to clear the extern include guard. // Make sure to clear the extern include guard.
final char[] externGuard= fExternIncludeGuard; final char[] externGuard= fExternIncludeGuard;
@ -1409,13 +1407,29 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
return; return;
} }
if (active && fCurrentContext.getDepth() == MAX_INCLUSION_DEPTH || fPreventInclusion.containsKey(headerName)) { if (includeType == IPreprocessorDirective.ppImport) {
// Imports are executed only once.
// See http://gcc.gnu.org/onlinedocs/gcc-3.2/cpp/Obsolete-once-only-headers.html.
if (fImports != null && fImports.containsKey(headerName))
return;
if (active) {
if (fImports == null)
fImports = new CharArraySet(0);
fImports.put(headerName);
}
}
if ((active && fCurrentContext.getDepth() == MAX_INCLUSION_DEPTH) ||
(fPreventInclusion != null && fPreventInclusion.containsKey(headerName))) {
handleProblem(IProblem.PREPROCESSOR_EXCEEDS_MAXIMUM_INCLUSION_DEPTH, handleProblem(IProblem.PREPROCESSOR_EXCEEDS_MAXIMUM_INCLUSION_DEPTH,
lexer.getInputChars(poundOffset, condEndOffset), poundOffset, condEndOffset); lexer.getInputChars(poundOffset, condEndOffset), poundOffset, condEndOffset);
if (fPreventInclusion == null)
fPreventInclusion = new CharArraySet(0);
fPreventInclusion.put(headerName); fPreventInclusion.put(headerName);
return; return;
} }
boolean includeNext = includeType == IPreprocessorDirective.ppInclude_next;
final String includeDirective = new String(headerName); final String includeDirective = new String(headerName);
if (!active) { if (!active) {
// Inactive include // Inactive include
@ -1429,7 +1443,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
// #endif // #endif
// When the extern guard matches we need to resolve the inclusion. We don't actually // When the extern guard matches we need to resolve the inclusion. We don't actually
// check whether the guard matches. // check whether the guard matches.
final IncludeResolution resolved= findInclusion(includeDirective, userInclude, include_next, final IncludeResolution resolved= findInclusion(includeDirective, userInclude, includeNext,
getCurrentFilename(), createPathTester); getCurrentFilename(), createPathTester);
if (resolved != null) { if (resolved != null) {
nominationDelegate = fFileContentProvider.isIncludedWithPragmaOnceSemantics(resolved.fLocation); nominationDelegate = fFileContentProvider.isIncludedWithPragmaOnceSemantics(resolved.fLocation);
@ -1445,7 +1459,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
} }
// Active include // Active include
final InternalFileContent fi= findInclusion(includeDirective, userInclude, include_next, final InternalFileContent fi= findInclusion(includeDirective, userInclude, includeNext,
getCurrentFilename(), createCodeReaderTester); getCurrentFilename(), createCodeReaderTester);
if (fi == null) { if (fi == null) {
// Unresolved active include // Unresolved active include
@ -1824,10 +1838,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
switch (type) { switch (type) {
case IPreprocessorDirective.ppImport: case IPreprocessorDirective.ppImport:
case IPreprocessorDirective.ppInclude: case IPreprocessorDirective.ppInclude:
executeInclude(lexer, ident.getOffset(), false, false, withinExpansion);
break;
case IPreprocessorDirective.ppInclude_next: case IPreprocessorDirective.ppInclude_next:
executeInclude(lexer, ident.getOffset(), true, false, withinExpansion); executeInclude(lexer, ident.getOffset(), type, false, withinExpansion);
break; break;
case IPreprocessorDirective.ppIfdef: case IPreprocessorDirective.ppIfdef:
return executeIfdef(lexer, pound.getOffset(), false, withinExpansion); return executeIfdef(lexer, pound.getOffset(), false, withinExpansion);

View file

@ -24,8 +24,8 @@ import org.eclipse.cdt.core.parser.util.CharArraySet;
* @since 5.0 * @since 5.0
*/ */
final class ScannerContext { final class ScannerContext {
enum BranchKind {eIf, eElif, eElse, eEnd} enum BranchKind { eIf, eElif, eElse, eEnd }
enum CodeState {eActive, eParseInactive, eSkipInactive} enum CodeState { eActive, eParseInactive, eSkipInactive }
final static class Conditional { final static class Conditional {
private final CodeState fInitialState; private final CodeState fInitialState;
@ -52,7 +52,7 @@ final class ScannerContext {
private final ScannerContext fParent; private final ScannerContext fParent;
private final Lexer fLexer; private final Lexer fLexer;
private Token fTokens; private Token fTokens;
private ArrayList<Conditional> fConditionals= null; private ArrayList<Conditional> fConditionals;
private CodeState fCurrentState= CodeState.eActive; private CodeState fCurrentState= CodeState.eActive;
private IncludeSearchPathElement fFoundOnPath; private IncludeSearchPathElement fFoundOnPath;
private String fFoundViaDirective; private String fFoundViaDirective;
@ -61,7 +61,6 @@ final class ScannerContext {
private boolean fPragmaOnce; private boolean fPragmaOnce;
private int fLoadedVersionCount; private int fLoadedVersionCount;
/** /**
* @param ctx * @param ctx
* @param parent context to be used after this context is done. * @param parent context to be used after this context is done.
@ -70,7 +69,7 @@ final class ScannerContext {
fLocationCtx= ctx; fLocationCtx= ctx;
fParent= parent; fParent= parent;
fLexer= lexer; fLexer= lexer;
fDepth = parent == null ? 0 : parent.fDepth+1; fDepth = parent == null ? 0 : parent.fDepth + 1;
} }
public ScannerContext(ILocationCtx ctx, ScannerContext parent, TokenList tokens) { public ScannerContext(ILocationCtx ctx, ScannerContext parent, TokenList tokens) {
@ -131,7 +130,7 @@ final class ScannerContext {
} }
// if we are not inside of an conditional there shouldn't be an #else, #elsif or #end // if we are not inside of an conditional there shouldn't be an #else, #elsif or #end
final int pos= fConditionals.size()-1; final int pos= fConditionals.size() - 1;
if (pos < 0) { if (pos < 0) {
return null; return null;
} }
@ -348,6 +347,11 @@ final class ScannerContext {
} }
public void significantMacro(IMacroBinding macro) { public void significantMacro(IMacroBinding macro) {
if (fCurrentState == CodeState.eParseInactive) {
// Macros in inactive code should not be considered significant to match behavior of indexer,
// which doesn't parse inactive code (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=370146).
return;
}
final char[] macroName= macro.getNameCharArray(); final char[] macroName= macro.getNameCharArray();
if (fInternalModifications != null && !fInternalModifications.containsKey(macroName)) { if (fInternalModifications != null && !fInternalModifications.containsKey(macroName)) {
final char[] expansion = macro.getExpansion(); final char[] expansion = macro.getExpansion();
@ -393,7 +397,7 @@ final class ScannerContext {
// Propagate significant macros to direct parent, if it is interested. // Propagate significant macros to direct parent, if it is interested.
if (collector == fParent.fInternalModifications) { if (collector == fParent.fInternalModifications) {
final CharArrayObjectMap<char[]> significant = fParent.fSignificantMacros; final CharArrayObjectMap<char[]> significant = fParent.fSignificantMacros;
for (int i=0; i<fSignificantMacros.size(); i++) { for (int i= 0; i < fSignificantMacros.size(); i++) {
final char[] name = fSignificantMacros.keyAt(i); final char[] name = fSignificantMacros.keyAt(i);
if (!collector.containsKey(name)) { if (!collector.containsKey(name)) {
final char[] value= fSignificantMacros.getAt(i); final char[] value= fSignificantMacros.getAt(i);
@ -425,6 +429,7 @@ final class ScannerContext {
} }
return true; return true;
} }
@Override @Override
public boolean visitUndefined(char[] macro) { public boolean visitUndefined(char[] macro) {
if (!fInternalModifications.containsKey(macro)) { if (!fInternalModifications.containsKey(macro)) {
@ -432,6 +437,7 @@ final class ScannerContext {
} }
return true; return true;
} }
@Override @Override
public boolean visitDefined(char[] macro) { public boolean visitDefined(char[] macro) {
if (!fInternalModifications.containsKey(macro)) { if (!fInternalModifications.containsKey(macro)) {

View file

@ -49,8 +49,7 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener
if (project != null) { if (project != null) {
fIndexerSetupParticipant.notifyIndexerSetup(project); fIndexerSetupParticipant.notifyIndexerSetup(project);
} }
} } else if (old != null && changedDefaultSettingConfiguration(old, act)) {
else if (old != null && changedDefaultSettingConfiguration(old, act)) {
ICProject project= getProject(event); ICProject project= getProject(event);
if (project != null) { if (project != null) {
fIndexManager.reindex(project); fIndexManager.reindex(project);
@ -86,7 +85,7 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener
// Check for a project that has been created by the new project wizard just // Check for a project that has been created by the new project wizard just
// just for the purpose of editing preferences (Advanced button) // just for the purpose of editing preferences (Advanced button)
ICProjectDescription desc= CProjectDescriptionManager.getInstance().getProjectDescription(project.getProject(), false, false); ICProjectDescription desc= CProjectDescriptionManager.getInstance().getProjectDescription(project.getProject(), false, false);
return desc==null || !desc.isCdtProjectCreating(); return desc == null || !desc.isCdtProjectCreating();
} }
private boolean completedProjectCreation(ICProjectDescription old, ICProjectDescription act) { private boolean completedProjectCreation(ICProjectDescription old, ICProjectDescription act) {

View file

@ -30,11 +30,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IIndexName;
@ -140,10 +138,6 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope {
} }
private IBinding getClassNameBinding() { private IBinding getClassNameBinding() {
if (fBinding instanceof ICPPClassTemplatePartialSpecialization)
return ((ICPPClassTemplatePartialSpecialization) fBinding).getPrimaryClassTemplate();
if (fBinding instanceof ICPPSpecialization)
return ((ICPPSpecialization) fBinding).getSpecializedBinding();
return fBinding; return fBinding;
} }

View file

@ -61,7 +61,7 @@ class PDOMCPPUsingDeclarationSpecialization extends PDOMCPPSpecialization implem
@Override @Override
public int getNodeType() { public int getNodeType() {
return IIndexCPPBindingConstants.CPP_USING_DECLARATION; return IIndexCPPBindingConstants.CPP_USING_DECLARATION_SPECIALIZATION;
} }
@Override @Override

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.index.IndexFilter; import org.eclipse.cdt.core.index.IndexFilter;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -30,7 +31,7 @@ import org.eclipse.core.runtime.CoreException;
*/ */
class PDOMClassUtil { class PDOMClassUtil {
static class FieldCollector implements IPDOMVisitor { static class FieldCollector implements IPDOMVisitor {
private List<ICPPField> fields = new ArrayList<ICPPField>(); private final List<ICPPField> fields = new ArrayList<ICPPField>();
@Override @Override
public boolean visit(IPDOMNode node) throws CoreException { public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof ICPPField) { if (node instanceof ICPPField) {
@ -50,7 +51,7 @@ class PDOMClassUtil {
} }
static class ConstructorCollector implements IPDOMVisitor { static class ConstructorCollector implements IPDOMVisitor {
private List<ICPPConstructor> fConstructors = new ArrayList<ICPPConstructor>(); private final List<ICPPConstructor> fConstructors = new ArrayList<ICPPConstructor>();
@Override @Override
public boolean visit(IPDOMNode node) throws CoreException { public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof ICPPConstructor) { if (node instanceof ICPPConstructor) {
@ -108,10 +109,10 @@ class PDOMClassUtil {
} }
static class NestedClassCollector implements IPDOMVisitor { static class NestedClassCollector implements IPDOMVisitor {
private List<IPDOMNode> nestedClasses = new ArrayList<IPDOMNode>(); private final List<IPDOMNode> nestedClasses = new ArrayList<IPDOMNode>();
@Override @Override
public boolean visit(IPDOMNode node) throws CoreException { public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof ICPPClassType) if (node instanceof ICPPClassType && !(node instanceof ICPPDeferredClassInstance))
nestedClasses.add(node); nestedClasses.add(node);
return false; return false;
} }

View file

@ -260,8 +260,8 @@ public class PDOMUpdateTask implements IPDOMIndexerTask {
*/ */
private boolean fileIsNotOlderThanTimestamp(String filename, long timestamp) { private boolean fileIsNotOlderThanTimestamp(String filename, long timestamp) {
// We are subtracting 1 second from the timestamp to account for limited precision // We are subtracting 1 second from the timestamp to account for limited precision
// of File.lastModified() method and possible asynchrony between clocks on multi-CPU // of File.lastModified() method and possible skew between clocks on a multi-CPU
// systems. This may produce false positives, but they are pretty harmless. // system. This may produce false positives, but they are pretty harmless.
return new File(filename).lastModified() >= timestamp - 1000; return new File(filename).lastModified() >= timestamp - 1000;
} }

View file

@ -33,10 +33,10 @@ import org.eclipse.osgi.util.NLS;
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
public class CConventions { public class CConventions {
private final static String scopeResolutionOperator= "::"; //$NON-NLS-1$ private static final String scopeResolutionOperator= "::"; //$NON-NLS-1$
private final static char fgDot= '.'; private static final char fgDot= '.';
private final static String ILLEGAL_FILE_CHARS = "/\\:<>?*|\""; //$NON-NLS-1$ private static final String ILLEGAL_FILE_CHARS = "/\\:<>?*|\""; //$NON-NLS-1$
public static boolean isLegalIdentifier(String name) { public static boolean isLegalIdentifier(String name) {
if (name == null) { if (name == null) {

View file

@ -109,11 +109,11 @@ public class CCorePlugin extends Plugin {
public static final String BUILDER_MODEL_ID = PLUGIN_ID + ".CBuildModel"; //$NON-NLS-1$ public static final String BUILDER_MODEL_ID = PLUGIN_ID + ".CBuildModel"; //$NON-NLS-1$
public static final String BINARY_PARSER_SIMPLE_ID = "BinaryParser"; //$NON-NLS-1$ public static final String BINARY_PARSER_SIMPLE_ID = "BinaryParser"; //$NON-NLS-1$
public final static String BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$ public static final String BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$
public final static String PREF_BINARY_PARSER = "binaryparser"; //$NON-NLS-1$ public static final String PREF_BINARY_PARSER = "binaryparser"; //$NON-NLS-1$
public final static String DEFAULT_BINARY_PARSER_SIMPLE_ID = "ELF"; //$NON-NLS-1$ public static final String DEFAULT_BINARY_PARSER_SIMPLE_ID = "ELF"; //$NON-NLS-1$
public final static String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$ public static final String DEFAULT_BINARY_PARSER_UNIQ_ID = PLUGIN_ID + "." + DEFAULT_BINARY_PARSER_SIMPLE_ID; //$NON-NLS-1$
public final static String PREF_USE_STRUCTURAL_PARSE_MODE = "useStructualParseMode"; //$NON-NLS-1$ public static final String PREF_USE_STRUCTURAL_PARSE_MODE = "useStructualParseMode"; //$NON-NLS-1$
public static final String INDEX_SIMPLE_ID = "CIndex"; //$NON-NLS-1$ public static final String INDEX_SIMPLE_ID = "CIndex"; //$NON-NLS-1$
public static final String INDEX_UNIQ_ID = PLUGIN_ID + "." + INDEX_SIMPLE_ID; //$NON-NLS-1$ public static final String INDEX_UNIQ_ID = PLUGIN_ID + "." + INDEX_SIMPLE_ID; //$NON-NLS-1$
@ -126,23 +126,23 @@ public class CCorePlugin extends Plugin {
/** /**
* Name of the extension point for contributing an error parser * Name of the extension point for contributing an error parser
*/ */
public final static String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$ public static final String ERROR_PARSER_SIMPLE_ID = "ErrorParser"; //$NON-NLS-1$
/** /**
* Full unique name of the extension point for contributing an error parser * Full unique name of the extension point for contributing an error parser
*/ */
public final static String ERROR_PARSER_UNIQ_ID = PLUGIN_ID + "." + ERROR_PARSER_SIMPLE_ID; //$NON-NLS-1$ public static final String ERROR_PARSER_UNIQ_ID = PLUGIN_ID + "." + ERROR_PARSER_SIMPLE_ID; //$NON-NLS-1$
// default store for pathentry // default store for pathentry
public final static String DEFAULT_PATHENTRY_STORE_ID = PLUGIN_ID + ".cdtPathEntryStore"; //$NON-NLS-1$ public static final String DEFAULT_PATHENTRY_STORE_ID = PLUGIN_ID + ".cdtPathEntryStore"; //$NON-NLS-1$
// Build Model Interface Discovery // Build Model Interface Discovery
public final static String BUILD_SCANNER_INFO_SIMPLE_ID = "ScannerInfoProvider"; //$NON-NLS-1$ public static final String BUILD_SCANNER_INFO_SIMPLE_ID = "ScannerInfoProvider"; //$NON-NLS-1$
public final static String BUILD_SCANNER_INFO_UNIQ_ID = PLUGIN_ID + "." + BUILD_SCANNER_INFO_SIMPLE_ID; //$NON-NLS-1$ public static final String BUILD_SCANNER_INFO_UNIQ_ID = PLUGIN_ID + "." + BUILD_SCANNER_INFO_SIMPLE_ID; //$NON-NLS-1$
public static final String DEFAULT_PROVIDER_ID = CCorePlugin.PLUGIN_ID + ".defaultConfigDataProvider"; //$NON-NLS-1$ public static final String DEFAULT_PROVIDER_ID = CCorePlugin.PLUGIN_ID + ".defaultConfigDataProvider"; //$NON-NLS-1$
private final static String SCANNER_INFO_PROVIDER2_NAME = "ScannerInfoProvider2"; //$NON-NLS-1$ private static final String SCANNER_INFO_PROVIDER2_NAME = "ScannerInfoProvider2"; //$NON-NLS-1$
private final static String SCANNER_INFO_PROVIDER2 = PLUGIN_ID + "." + SCANNER_INFO_PROVIDER2_NAME; //$NON-NLS-1$ private static final String SCANNER_INFO_PROVIDER2 = PLUGIN_ID + "." + SCANNER_INFO_PROVIDER2_NAME; //$NON-NLS-1$
/** /**
* Name of the extension point for contributing a source code formatter * Name of the extension point for contributing a source code formatter
@ -158,27 +158,27 @@ public class CCorePlugin extends Plugin {
/** /**
* IContentType id for C Source Unit * IContentType id for C Source Unit
*/ */
public final static String CONTENT_TYPE_CSOURCE = "org.eclipse.cdt.core.cSource"; //$NON-NLS-1$ public static final String CONTENT_TYPE_CSOURCE = "org.eclipse.cdt.core.cSource"; //$NON-NLS-1$
/** /**
* IContentType id for C Header Unit * IContentType id for C Header Unit
*/ */
public final static String CONTENT_TYPE_CHEADER = "org.eclipse.cdt.core.cHeader"; //$NON-NLS-1$ public static final String CONTENT_TYPE_CHEADER = "org.eclipse.cdt.core.cHeader"; //$NON-NLS-1$
/** /**
* IContentType id for C++ Source Unit * IContentType id for C++ Source Unit
*/ */
public final static String CONTENT_TYPE_CXXSOURCE = "org.eclipse.cdt.core.cxxSource"; //$NON-NLS-1$ public static final String CONTENT_TYPE_CXXSOURCE = "org.eclipse.cdt.core.cxxSource"; //$NON-NLS-1$
/** /**
* IContentType id for C++ Header Unit * IContentType id for C++ Header Unit
*/ */
public final static String CONTENT_TYPE_CXXHEADER = "org.eclipse.cdt.core.cxxHeader"; //$NON-NLS-1$ public static final String CONTENT_TYPE_CXXHEADER = "org.eclipse.cdt.core.cxxHeader"; //$NON-NLS-1$
/** /**
* IContentType id for ASM Unit * IContentType id for ASM Unit
*/ */
public final static String CONTENT_TYPE_ASMSOURCE = "org.eclipse.cdt.core.asmSource"; //$NON-NLS-1$ public static final String CONTENT_TYPE_ASMSOURCE = "org.eclipse.cdt.core.asmSource"; //$NON-NLS-1$
/** /**
* IContentType id for Binary Files * IContentType id for Binary Files
*/ */
public final static String CONTENT_TYPE_BINARYFILE = "org.eclipse.cdt.core.binaryFile"; //$NON-NLS-1$ public static final String CONTENT_TYPE_BINARYFILE = "org.eclipse.cdt.core.binaryFile"; //$NON-NLS-1$
/** /**
* Possible configurable option value. * Possible configurable option value.

View file

@ -268,7 +268,7 @@ public class BuildRunnerHelper implements Closeable {
} }
/** /**
* Close all streams. * Close all streams except console Info stream which is handled by {@link #greeting(String)}/{@link #goodbye()}.
*/ */
@Override @Override
public void close() throws IOException { public void close() throws IOException {
@ -303,14 +303,6 @@ public class BuildRunnerHelper implements Closeable {
CCorePlugin.log(e); CCorePlugin.log(e);
} finally { } finally {
consoleOut = null; consoleOut = null;
try {
if (consoleInfo != null)
consoleInfo.close();
} catch (Exception e) {
CCorePlugin.log(e);
} finally {
consoleInfo = null;
}
} }
} }
} }
@ -349,6 +341,9 @@ public class BuildRunnerHelper implements Closeable {
* Print a standard greeting to the console. * Print a standard greeting to the console.
* Note that start time of the build is recorded by this method. * Note that start time of the build is recorded by this method.
* *
* This method may open an Info stream which must be closed by call to {@link #goodbye()}
* after all informational messages are printed.
*
* @param kind - kind of build. {@link IncrementalProjectBuilder} constants such as * @param kind - kind of build. {@link IncrementalProjectBuilder} constants such as
* {@link IncrementalProjectBuilder#FULL_BUILD} should be used. * {@link IncrementalProjectBuilder#FULL_BUILD} should be used.
*/ */
@ -362,6 +357,9 @@ public class BuildRunnerHelper implements Closeable {
* Print a standard greeting to the console. * Print a standard greeting to the console.
* Note that start time of the build is recorded by this method. * Note that start time of the build is recorded by this method.
* *
* This method may open an Info stream which must be closed by call to {@link #goodbye()}
* after all informational messages are printed.
*
* @param kind - kind of build. {@link IncrementalProjectBuilder} constants such as * @param kind - kind of build. {@link IncrementalProjectBuilder} constants such as
* {@link IncrementalProjectBuilder#FULL_BUILD} should be used. * {@link IncrementalProjectBuilder#FULL_BUILD} should be used.
* @param cfgName - configuration name. * @param cfgName - configuration name.
@ -376,6 +374,9 @@ public class BuildRunnerHelper implements Closeable {
* Print a standard greeting to the console. * Print a standard greeting to the console.
* Note that start time of the build is recorded by this method. * Note that start time of the build is recorded by this method.
* *
* This method may open an Info stream which must be closed by call to {@link #goodbye()}
* after all informational messages are printed.
*
* @param kind - kind of build as a String. * @param kind - kind of build as a String.
* @param cfgName - configuration name. * @param cfgName - configuration name.
* @param toolchainName - tool-chain name. * @param toolchainName - tool-chain name.
@ -396,6 +397,9 @@ public class BuildRunnerHelper implements Closeable {
/** /**
* Print the specified greeting to the console. * Print the specified greeting to the console.
* Note that start time of the build is recorded by this method. * Note that start time of the build is recorded by this method.
*
* This method may open an Info stream which must be closed by call to {@link #goodbye()}
* after all informational messages are printed.
*/ */
public void greeting(String msg) { public void greeting(String msg) {
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
@ -410,14 +414,14 @@ public class BuildRunnerHelper implements Closeable {
} }
/** /**
* Print a standard footer to the console. * Print a standard footer to the console and close Info stream (must be open with one of {@link #greeting(String)} calls).
* That prints duration of the build determined by start time recorded in {@link #greeting(String)}. * That prints duration of the build determined by start time recorded in {@link #greeting(String)}.
* *
* <br><strong>Important: {@link #close()} the streams BEFORE calling this method to properly flush all outputs</strong> * <br><strong>Important: {@link #close()} the streams BEFORE calling this method to properly flush all outputs</strong>
*/ */
public void goodbye() { public void goodbye() {
Assert.isTrue(startTime != 0, "Start time must be set before calling this method"); //$NON-NLS-1$ Assert.isTrue(startTime != 0, "Start time must be set before calling this method."); //$NON-NLS-1$
Assert.isTrue(!isStreamsOpen, "Close streams before calling this method."); //$NON-NLS-1$ Assert.isTrue(consoleInfo != null, "consoleInfo must be open with greetings(...) call before using this method."); //$NON-NLS-1$
endTime = System.currentTimeMillis(); endTime = System.currentTimeMillis();
String duration = durationToString(endTime - startTime); String duration = durationToString(endTime - startTime);
@ -425,17 +429,15 @@ public class BuildRunnerHelper implements Closeable {
: CCorePlugin.getFormattedString("BuildRunnerHelper.buildFinished", duration); //$NON-NLS-1$ : CCorePlugin.getFormattedString("BuildRunnerHelper.buildFinished", duration); //$NON-NLS-1$
String goodbye = '\n' + timestamp(endTime) + msg + '\n'; String goodbye = '\n' + timestamp(endTime) + msg + '\n';
if (consoleInfo != null) { try {
toConsole(goodbye); toConsole(goodbye);
} else { } finally {
// in current flow goodbye() can be called after close()
try { try {
consoleInfo = console.getInfoStream();
toConsole(goodbye);
consoleInfo.close(); consoleInfo.close();
consoleInfo = null;
} catch (Exception e) { } catch (Exception e) {
CCorePlugin.log(e); CCorePlugin.log(e);
} finally {
consoleInfo = null;
} }
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others. * Copyright (c) 2000, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Salvatore Culcasi - Bug 322475
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.utils.debug.dwarf; package org.eclipse.cdt.utils.debug.dwarf;
@ -476,7 +477,7 @@ public class Dwarf {
case DwarfConstants.DW_FORM_block1 : case DwarfConstants.DW_FORM_block1 :
{ {
int size = in.get(); int size = in.get();
byte[] bytes = new byte[size]; byte[] bytes = new byte[size & 0xff];
in.get(bytes); in.get(bytes);
obj = bytes; obj = bytes;
} }
@ -485,7 +486,7 @@ public class Dwarf {
case DwarfConstants.DW_FORM_block2 : case DwarfConstants.DW_FORM_block2 :
{ {
int size = read_2_bytes(in); int size = read_2_bytes(in);
byte[] bytes = new byte[size]; byte[] bytes = new byte[size & 0xffff];
in.get(bytes); in.get(bytes);
obj = bytes; obj = bytes;
} }

View file

@ -368,7 +368,7 @@ public abstract class RefactoringTestBase extends BaseTestCase {
while ((read= reader.read(part)) != -1) while ((read= reader.read(part)) != -1)
buffer.append(part, 0, read); buffer.append(part, 0, read);
reader.close(); reader.close();
return buffer.toString(); return buffer.toString().replace("\r", "");
} }
protected void resetPreferences() { protected void resetPreferences() {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others * Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0

View file

@ -1599,4 +1599,36 @@ public class GenerateGettersAndSettersTest extends RefactoringTestBase {
selectedSetters = new String[] { "mClass" }; selectedSetters = new String[] { "mClass" };
assertRefactoringSuccess(); assertRefactoringSuccess();
} }
//A.h
//class Foo {
// int a, *b, /*$*/c[2]/*$$*/;
//};
//====================
//class Foo {
//public:
// void setA(int a) {
// this->a = a;
// }
//
// int* getB() const {
// return b;
// }
//
// void setB(int* b) {
// this->b = b;
// }
//
// const int* getC() const {
// return c;
// }
//
//private:
// int a, *b, c[2];
//};
public void testMultipleDeclarators_371840() throws Exception {
selectedGetters = new String[] { "b", "c" };
selectedSetters = new String[] { "a", "b" };
assertRefactoringSuccess();
}
} }

View file

@ -1,13 +1,13 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 IBM Corporation and others. * Copyright (c) 2005, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.text.selection; package org.eclipse.cdt.ui.tests.text.selection;
@ -228,7 +228,7 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase {
final IASTName[] result= {null}; final IASTName[] result= {null};
if (sel instanceof ITextSelection) { if (sel instanceof ITextSelection) {
final ITextSelection textSel = (ITextSelection)sel; final ITextSelection textSel = (ITextSelection)sel;
ITranslationUnit tu = (ITranslationUnit)editor.getInputCElement(); ITranslationUnit tu = editor.getInputCElement();
IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() { IStatus ok= ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, monitor, new ASTRunnable() {
@Override @Override
public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException { public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.text.selection; package org.eclipse.cdt.ui.tests.text.selection;
@ -34,7 +34,7 @@ import org.eclipse.cdt.ui.testplugin.CTestPlugin;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/** /**
* Test Ctrl_F3/F3 with the DOM Indexer for a C++ project. * Test Ctrl-F3/F3 with the DOM Indexer for a C++ project.
*/ */
public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsIndexer { public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsIndexer {
private static final int MAX_WAIT_TIME = 8000; private static final int MAX_WAIT_TIME = 8000;
@ -170,7 +170,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
int hoffset= hcode.indexOf("testTemplate"); int hoffset= hcode.indexOf("testTemplate");
int soffset = scode.indexOf("testTemplate"); int soffset = scode.indexOf("testTemplate");
IASTNode def = testF3(file, soffset+2); IASTNode def = testF3(file, soffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertEquals("testTemplate", ((IASTName) def).toString()); assertEquals("testTemplate", ((IASTName) def).toString());
assertEquals(hoffset, ((ASTNode) def).getOffset()); assertEquals(hoffset, ((ASTNode) def).getOffset());
@ -227,8 +227,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
int hoffset= hcode.indexOf("MyInt"); int hoffset= hcode.indexOf("MyInt");
int soffset = scode.indexOf("MyInt"); int soffset = scode.indexOf("MyInt");
IASTNode decl = testF3(file, soffset+2); IASTNode decl = testF3(file, soffset + 2);
IASTNode def = testF3(hfile, hoffset+2); IASTNode def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName); assertTrue(decl instanceof IASTName);
assertEquals("MyInt", ((IASTName) decl).toString()); assertEquals("MyInt", ((IASTName) decl).toString());
@ -240,8 +240,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyConst"); hoffset= hcode.indexOf("MyConst");
soffset = scode.indexOf("MyConst"); soffset = scode.indexOf("MyConst");
decl = testF3(file, soffset+2); decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset+2); def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName); assertTrue(decl instanceof IASTName);
assertEquals("MyConst", ((IASTName) decl).toString()); assertEquals("MyConst", ((IASTName) decl).toString());
@ -253,8 +253,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyFunc"); hoffset= hcode.indexOf("MyFunc");
soffset = scode.indexOf("MyFunc"); soffset = scode.indexOf("MyFunc");
decl = testF3(file, soffset+2); decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset+2); def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName); assertTrue(decl instanceof IASTName);
assertEquals("MyFunc", ((IASTName) decl).toString()); assertEquals("MyFunc", ((IASTName) decl).toString());
@ -266,8 +266,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyStruct"); hoffset= hcode.indexOf("MyStruct");
soffset = scode.indexOf("MyStruct"); soffset = scode.indexOf("MyStruct");
decl = testF3(file, soffset+2); decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset+2); def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName); assertTrue(decl instanceof IASTName);
assertEquals("MyStruct", ((IASTName) decl).toString()); assertEquals("MyStruct", ((IASTName) decl).toString());
@ -279,8 +279,8 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
hoffset= hcode.indexOf("MyClass"); hoffset= hcode.indexOf("MyClass");
soffset = scode.indexOf("MyClass"); soffset = scode.indexOf("MyClass");
decl = testF3(file, soffset+2); decl = testF3(file, soffset + 2);
def = testF3(hfile, hoffset+2); def = testF3(hfile, hoffset + 2);
assertTrue(def instanceof IASTName); assertTrue(def instanceof IASTName);
assertTrue(decl instanceof IASTName); assertTrue(decl instanceof IASTName);
assertEquals("MyClass", ((IASTName) decl).toString()); assertEquals("MyClass", ((IASTName) decl).toString());
@ -984,6 +984,24 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
assertNode("gvar", offset0, decl); assertNode("gvar", offset0, decl);
} }
// #define MYMACRO
// #undef MYMACRO
public void testUndef_312399() throws Exception {
StringBuilder[] buffers= getContents(2);
String hcode= buffers[0].toString();
String scode= buffers[1].toString();
IFile hfile = importFile("testUndef_312399.h", hcode);
IFile file = importFile("testUndef_312399.cpp", scode);
waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME);
IASTNode target = testF3(file, scode.indexOf("MYMACRO"));
assertTrue(target instanceof IASTName);
assertEquals("MYMACRO", ((IASTName) target).toString());
assertEquals(hcode.indexOf("MYMACRO"), target.getFileLocation().getNodeOffset());
assertEquals("MYMACRO".length(), ((ASTNode) target).getLength());
}
// int wurscht; // int wurscht;
// #include "aheader.h" // #include "aheader.h"
@ -1230,21 +1248,31 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
} }
} }
// #define MYMACRO // namespace ns {
// void func();
// }
// #undef MYMACRO // #include "test.h"
public void testUndef_312399() throws Exception { // using ns::func;
StringBuilder[] buffers= getContents(2); //
// void test() {
// func();
// }
public void testBug380197() throws Exception {
StringBuilder[] buffers= getContents(2);
String hcode= buffers[0].toString(); String hcode= buffers[0].toString();
String scode= buffers[1].toString(); String scode= buffers[1].toString();
IFile hfile = importFile("testUndef_312399.h", hcode); IFile hfile = importFile("test.h", hcode);
IFile file = importFile("testUndef_312399.cpp", scode); IFile file = importFile("test.cpp", scode);
waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME); waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME);
IASTNode target = testF3(file, scode.indexOf("MYMACRO")); int hoffset= hcode.indexOf("func");
assertTrue(target instanceof IASTName); int offset = scode.indexOf("func()");
assertEquals("MYMACRO", ((IASTName) target).toString()); IASTNode def = testF3(file, offset + 1);
assertEquals(hcode.indexOf("MYMACRO"), target.getFileLocation().getNodeOffset()); assertTrue(def instanceof IASTName);
assertEquals("MYMACRO".length(), ((ASTNode) target).getLength()); assertEquals("func", def.toString());
IASTFileLocation location = def.getFileLocation();
assertEquals(hfile.getLocation().toOSString(), location.getFileName());
assertEquals(hoffset, location.getNodeOffset());
} }
} }

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.text.selection; package org.eclipse.cdt.ui.tests.text.selection;
import junit.framework.Test; import junit.framework.Test;

View file

@ -9,7 +9,6 @@
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.corext.template.c; package org.eclipse.cdt.internal.corext.template.c;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
@ -21,29 +20,21 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
* A context type for C/C++ code. * A context type for C/C++ code.
*/ */
public class CContextType extends TranslationUnitContextType { public class CContextType extends TranslationUnitContextType {
public static final String ID = "org.eclipse.cdt.ui.text.templates.c"; //$NON-NLS-1$
public final static String ID = "org.eclipse.cdt.ui.text.templates.c"; //$NON-NLS-1$
public CContextType() { public CContextType() {
super(); super();
} }
/*
* @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, int, int, org.eclipse.cdt.core.model.ITranslationUnit)
*/
@Override @Override
public TranslationUnitContext createContext(IDocument document, int offset, public TranslationUnitContext createContext(IDocument document, int offset,
int length, ITranslationUnit translationUnit) { int length, ITranslationUnit translationUnit) {
return new CContext(this, document, offset, length, translationUnit); return new CContext(this, document, offset, length, translationUnit);
} }
/*
* @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position, org.eclipse.cdt.core.model.ITranslationUnit)
*/
@Override @Override
public TranslationUnitContext createContext(IDocument document, public TranslationUnitContext createContext(IDocument document,
Position position, ITranslationUnit translationUnit) { Position position, ITranslationUnit translationUnit) {
return new CContext(this, document, position, translationUnit); return new CContext(this, document, position, translationUnit);
} }
} }

View file

@ -10,16 +10,19 @@
* Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
* Andrew Gvozdev (Quoin Inc.) - Copy build log (bug 306222) * Andrew Gvozdev (Quoin Inc.) - Copy build log (bug 306222)
* Alex Collins (Broadcom Corp.) - Global console * Alex Collins (Broadcom Corp.) - Global console
* Sergey Prigogin (Google) - Performance improvements
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.buildconsole; package org.eclipse.cdt.internal.ui.buildconsole;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URI; import java.net.URI;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Vector;
import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.IFileStore;
@ -48,14 +51,205 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage; import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
public class BuildConsolePartitioner public class BuildConsolePartitioner
implements implements IDocumentPartitioner, IDocumentPartitionerExtension, IConsole, IPropertyChangeListener {
IDocumentPartitioner,
IDocumentPartitionerExtension, private static class SynchronizedDeque<E> implements Deque<E> {
IConsole, private final Deque<E> deque;
IPropertyChangeListener {
public SynchronizedDeque(Deque<E> deque) {
this.deque = deque;
}
@Override
public synchronized boolean isEmpty() {
return deque.isEmpty();
}
@Override
public synchronized void addFirst(E e) {
deque.addFirst(e);
}
@Override
public synchronized void addLast(E e) {
deque.addLast(e);
}
@Override
public synchronized Object[] toArray() {
return deque.toArray();
}
@Override
public synchronized <T> T[] toArray(T[] a) {
return deque.toArray(a);
}
@Override
public synchronized boolean offerFirst(E e) {
return deque.offerFirst(e);
}
@Override
public synchronized boolean offerLast(E e) {
return deque.offerLast(e);
}
@Override
public synchronized E removeFirst() {
return deque.removeFirst();
}
@Override
public synchronized E removeLast() {
return deque.removeLast();
}
@Override
public synchronized E pollFirst() {
return deque.pollFirst();
}
@Override
public synchronized E pollLast() {
return deque.pollLast();
}
@Override
public synchronized E getFirst() {
return deque.getFirst();
}
@Override
public synchronized E getLast() {
return deque.getLast();
}
@Override
public synchronized E peekFirst() {
return deque.peekFirst();
}
@Override
public synchronized E peekLast() {
return deque.peekLast();
}
@Override
public synchronized boolean removeFirstOccurrence(Object o) {
return deque.removeFirstOccurrence(o);
}
@Override
public synchronized boolean containsAll(Collection<?> c) {
return deque.containsAll(c);
}
@Override
public synchronized boolean removeLastOccurrence(Object o) {
return deque.removeLastOccurrence(o);
}
@Override
public synchronized boolean addAll(Collection<? extends E> c) {
return deque.addAll(c);
}
@Override
public synchronized boolean add(E e) {
return deque.add(e);
}
@Override
public synchronized boolean removeAll(Collection<?> c) {
return deque.removeAll(c);
}
@Override
public synchronized boolean offer(E e) {
return deque.offer(e);
}
@Override
public synchronized boolean retainAll(Collection<?> c) {
return deque.retainAll(c);
}
@Override
public synchronized E remove() {
return deque.remove();
}
@Override
public synchronized E poll() {
return deque.poll();
}
@Override
public synchronized E element() {
return deque.element();
}
@Override
public synchronized void clear() {
deque.clear();
}
@Override
public synchronized boolean equals(Object o) {
return deque.equals(o);
}
@Override
public synchronized E peek() {
return deque.peek();
}
@Override
public synchronized void push(E e) {
deque.push(e);
}
@Override
public synchronized E pop() {
return deque.pop();
}
@Override
public synchronized int hashCode() {
return deque.hashCode();
}
@Override
public synchronized boolean remove(Object o) {
return deque.remove(o);
}
@Override
public synchronized boolean contains(Object o) {
return deque.contains(o);
}
@Override
public synchronized int size() {
return deque.size();
}
@Override
public synchronized Iterator<E> iterator() {
return deque.iterator();
}
@Override
public synchronized Iterator<E> descendingIterator() {
return deque.descendingIterator();
}
}
private IProject fProject; private IProject fProject;
private int openStreamCount = 0;
/** /**
* List of partitions * List of partitions
*/ */
@ -66,7 +260,7 @@ public class BuildConsolePartitioner
/** /**
* The stream that was last appended to * The stream that was last appended to
*/ */
BuildConsoleStreamDecorator fLastStream = null; BuildConsoleStreamDecorator fLastStream;
BuildConsoleDocument fDocument; BuildConsoleDocument fDocument;
DocumentMarkerManager fDocumentMarkerManager; DocumentMarkerManager fDocumentMarkerManager;
@ -76,19 +270,18 @@ public class BuildConsolePartitioner
/** /**
* A queue of stream entries written to standard out and standard err. * A queue of stream entries written to standard out and standard err.
* Entries appended to the end of the queue and removed from the front. * Entries appended to the end of the queue and removed from the front.
* Intentionally a vector to obtain synchronization as entries are added and
* removed.
*/ */
Vector<StreamEntry> fQueue = new Vector<StreamEntry>(5); private final Deque<StreamEntry> fQueue =
new SynchronizedDeque<StreamEntry>(new ArrayDeque<StreamEntry>());
private URI fLogURI; private URI fLogURI;
private OutputStream fLogStream; private OutputStream fLogStream;
private class StreamEntry { private class StreamEntry {
static public final int EVENT_APPEND = 0; public static final int EVENT_APPEND = 0;
static public final int EVENT_OPEN_LOG = 1; public static final int EVENT_OPEN_LOG = 1;
static public final int EVENT_CLOSE_LOG = 2; public static final int EVENT_CLOSE_LOG = 2;
static public final int EVENT_OPEN_APPEND_LOG = 3; public static final int EVENT_OPEN_APPEND_LOG = 3;
/** Identifier of the stream written to. */ /** Identifier of the stream written to. */
private BuildConsoleStreamDecorator fStream; private BuildConsoleStreamDecorator fStream;
@ -153,7 +346,6 @@ public class BuildConsolePartitioner
public int getEventType() { public int getEventType() {
return eventType; return eventType;
} }
} }
/** /**
@ -214,12 +406,12 @@ public class BuildConsolePartitioner
public void appendToDocument(String text, BuildConsoleStreamDecorator stream, ProblemMarkerInfo marker) { public void appendToDocument(String text, BuildConsoleStreamDecorator stream, ProblemMarkerInfo marker) {
boolean addToQueue = true; boolean addToQueue = true;
synchronized (fQueue) { synchronized (fQueue) {
int i = fQueue.size(); StreamEntry entry = fQueue.peekLast();
if (i > 0) { if (entry != null) {
StreamEntry entry = fQueue.get(i - 1); // If last stream is the same and we have not exceeded
// if last stream is the same and we have not exceeded our // the display write limit, append.
// display write limit, append. if (entry.getStream() == stream && entry.getEventType() == StreamEntry.EVENT_APPEND &&
if (entry.getStream()==stream && entry.getEventType()==StreamEntry.EVENT_APPEND && entry.getMarker()==marker && entry.size()<10000) { entry.getMarker() == marker && entry.size() < 10000) {
entry.appendText(text); entry.appendText(text);
addToQueue = false; addToQueue = false;
} }
@ -243,13 +435,14 @@ public class BuildConsolePartitioner
@Override @Override
public void run() { public void run() {
StreamEntry entry; StreamEntry entry;
try { entry = fQueue.pollFirst();
entry = fQueue.remove(0); if (entry == null)
} catch (ArrayIndexOutOfBoundsException e) {
return; return;
}
switch (entry.getEventType()) { switch (entry.getEventType()) {
case StreamEntry.EVENT_OPEN_LOG: case StreamEntry.EVENT_OPEN_LOG:
openStreamCount++;
//$FALL-THROUGH$
case StreamEntry.EVENT_OPEN_APPEND_LOG: case StreamEntry.EVENT_OPEN_APPEND_LOG:
logOpen(entry.getEventType() == StreamEntry.EVENT_OPEN_APPEND_LOG); logOpen(entry.getEventType() == StreamEntry.EVENT_OPEN_APPEND_LOG);
break; break;
@ -265,16 +458,28 @@ public class BuildConsolePartitioner
fDocument.set(""); //$NON-NLS-1$ fDocument.set(""); //$NON-NLS-1$
} }
String text = entry.getText(); String text = entry.getText();
if (text.length()>0) { if (text.length() > 0) {
addStreamEntryToDocument(entry); addStreamEntryToDocument(entry);
log(text); log(text);
checkOverflow(); boolean allowSlack = false;
entry = fQueue.peekFirst();
if (entry != null && entry.getEventType() == StreamEntry.EVENT_APPEND) {
// Buffer truncation is an expensive operation. Allow some slack
// if more data is coming and we will be truncating the buffer
// again soon.
allowSlack = true;
}
checkOverflow(allowSlack);
} }
} catch (BadLocationException e) { } catch (BadLocationException e) {
} }
break; break;
case StreamEntry.EVENT_CLOSE_LOG: case StreamEntry.EVENT_CLOSE_LOG:
logClose(); openStreamCount--;
if (openStreamCount <= 0) {
openStreamCount = 0;
logClose();
}
break; break;
} }
} }
@ -285,7 +490,7 @@ public class BuildConsolePartitioner
*/ */
private void logOpen(boolean append) { private void logOpen(boolean append) {
fLogURI = fManager.getLogURI(fProject); fLogURI = fManager.getLogURI(fProject);
if (fLogURI!=null) { if (fLogURI != null) {
try { try {
IFileStore logStore = EFS.getStore(fLogURI); IFileStore logStore = EFS.getStore(fLogURI);
// Ensure the directory exists before opening the file // Ensure the directory exists before opening the file
@ -303,7 +508,7 @@ public class BuildConsolePartitioner
} }
private void log(String text) { private void log(String text) {
if (fLogStream!=null) { if (fLogStream != null) {
try { try {
fLogStream.write(text.getBytes()); fLogStream.write(text.getBytes());
if (fQueue.isEmpty()) { if (fQueue.isEmpty()) {
@ -318,7 +523,7 @@ public class BuildConsolePartitioner
} }
private void logClose() { private void logClose() {
if (fLogStream!=null) { if (fLogStream != null) {
try { try {
fLogStream.close(); fLogStream.close();
} catch (IOException e) { } catch (IOException e) {
@ -339,7 +544,7 @@ public class BuildConsolePartitioner
private void addStreamEntryToDocument(StreamEntry entry) throws BadLocationException { private void addStreamEntryToDocument(StreamEntry entry) throws BadLocationException {
ProblemMarkerInfo marker = entry.getMarker(); ProblemMarkerInfo marker = entry.getMarker();
if (marker==null) { if (marker == null) {
// It is plain unmarkered console output // It is plain unmarkered console output
addPartition(new BuildConsolePartition(fLastStream, addPartition(new BuildConsolePartition(fLastStream,
fDocument.getLength(), fDocument.getLength(),
@ -349,9 +554,9 @@ public class BuildConsolePartitioner
// this text line in entry is markered with ProblemMarkerInfo, // this text line in entry is markered with ProblemMarkerInfo,
// create special partition for it. // create special partition for it.
String errorPartitionType; String errorPartitionType;
if (marker.severity==IMarker.SEVERITY_INFO) { if (marker.severity == IMarker.SEVERITY_INFO) {
errorPartitionType = BuildConsolePartition.INFO_PARTITION_TYPE; errorPartitionType = BuildConsolePartition.INFO_PARTITION_TYPE;
} else if (marker.severity==IMarker.SEVERITY_WARNING) { } else if (marker.severity == IMarker.SEVERITY_WARNING) {
errorPartitionType = BuildConsolePartition.WARNING_PARTITION_TYPE; errorPartitionType = BuildConsolePartition.WARNING_PARTITION_TYPE;
} else { } else {
errorPartitionType = BuildConsolePartition.ERROR_PARTITION_TYPE; errorPartitionType = BuildConsolePartition.ERROR_PARTITION_TYPE;
@ -377,8 +582,7 @@ public class BuildConsolePartitioner
public void setDocumentSize(int nLines) { public void setDocumentSize(int nLines) {
fMaxLines = nLines; fMaxLines = nLines;
nLines = fDocument.getNumberOfLines(); checkOverflow(false);
checkOverflow();
} }
@Override @Override
@ -437,7 +641,7 @@ public class BuildConsolePartitioner
ITypedRegion partition = fPartitions.get(i); ITypedRegion partition = fPartitions.get(i);
int partitionStart = partition.getOffset(); int partitionStart = partition.getOffset();
int partitionEnd = partitionStart + partition.getLength(); int partitionEnd = partitionStart + partition.getLength();
if ( (offset >= partitionStart && offset <= partitionEnd) || if ((offset >= partitionStart && offset <= partitionEnd) ||
(offset < partitionStart && end >= partitionStart)) { (offset < partitionStart && end >= partitionStart)) {
list.add(partition); list.add(partition);
} }
@ -489,55 +693,56 @@ public class BuildConsolePartitioner
* Checks to see if the console buffer has overflowed, and empties the * Checks to see if the console buffer has overflowed, and empties the
* overflow if needed, updating partitions and hyperlink positions. * overflow if needed, updating partitions and hyperlink positions.
*/ */
protected void checkOverflow() { protected void checkOverflow(boolean allowSlack) {
if (fMaxLines >= 0) { if (fMaxLines <= 0)
int nLines = fDocument.getNumberOfLines(); return;
if (nLines > fMaxLines + 1) { int nLines = fDocument.getNumberOfLines();
int overflow = 0; if (nLines <= (allowSlack ? fMaxLines * 2 : fMaxLines) + 1)
try { return;
overflow = fDocument.getLineOffset(nLines - fMaxLines);
} catch (BadLocationException e1) {
}
// update partitions
List<ITypedRegion> newParitions = new ArrayList<ITypedRegion>(fPartitions.size());
Iterator<ITypedRegion> partitions = fPartitions.iterator();
while (partitions.hasNext()) {
ITypedRegion region = partitions.next();
if (region instanceof BuildConsolePartition) {
BuildConsolePartition messageConsolePartition = (BuildConsolePartition)region;
ITypedRegion newPartition = null; int overflow = 0;
int offset = region.getOffset(); try {
String type = messageConsolePartition.getType(); overflow = fDocument.getLineOffset(nLines - fMaxLines);
if (offset < overflow) { } catch (BadLocationException e) {
int endOffset = offset + region.getLength(); }
if (endOffset < overflow || BuildConsolePartition.isProblemPartitionType(type)) { // Update partitions
// remove partition, List<ITypedRegion> newParitions = new ArrayList<ITypedRegion>(fPartitions.size());
// partitions with problem markers can't be split - remove them too Iterator<ITypedRegion> partitions = fPartitions.iterator();
} else { while (partitions.hasNext()) {
// split partition ITypedRegion region = partitions.next();
int length = endOffset - overflow; if (region instanceof BuildConsolePartition) {
newPartition = messageConsolePartition.createNewPartition(0, length, type); BuildConsolePartition messageConsolePartition = (BuildConsolePartition) region;
}
} else { ITypedRegion newPartition = null;
// modify partition offset int offset = region.getOffset();
offset = messageConsolePartition.getOffset() - overflow; String type = messageConsolePartition.getType();
newPartition = messageConsolePartition.createNewPartition(offset, messageConsolePartition.getLength(), type); if (offset < overflow) {
} int endOffset = offset + region.getLength();
if (newPartition != null) { if (endOffset < overflow || BuildConsolePartition.isProblemPartitionType(type)) {
newParitions.add(newPartition); // Remove partition,
} // partitions with problem markers can't be split - remove them too.
} else {
// Split partition
int length = endOffset - overflow;
newPartition = messageConsolePartition.createNewPartition(0, length, type);
} }
} else {
// Modify partition offset
offset = messageConsolePartition.getOffset() - overflow;
newPartition = messageConsolePartition.createNewPartition(offset, messageConsolePartition.getLength(), type);
} }
fPartitions = newParitions; if (newPartition != null) {
fDocumentMarkerManager.moveToFirstError(); newParitions.add(newPartition);
try {
fDocument.replace(0, overflow, ""); //$NON-NLS-1$
} catch (BadLocationException e) {
} }
} }
} }
fPartitions = newParitions;
fDocumentMarkerManager.moveToFirstError();
try {
fDocument.replace(0, overflow, ""); //$NON-NLS-1$
} catch (BadLocationException e) {
}
} }
/** /**
@ -548,7 +753,7 @@ public class BuildConsolePartitioner
fPartitions.add(partition); fPartitions.add(partition);
} else { } else {
int index = fPartitions.size() - 1; int index = fPartitions.size() - 1;
BuildConsolePartition last = (BuildConsolePartition)fPartitions.get(index); BuildConsolePartition last = (BuildConsolePartition) fPartitions.get(index);
if (last.canBeCombinedWith(partition)) { if (last.canBeCombinedWith(partition)) {
// replace with a single partition // replace with a single partition
partition = last.combineWith(partition); partition = last.combineWith(partition);

View file

@ -690,7 +690,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
/** Preference key for temporary problems */ /** Preference key for temporary problems */
private final static String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS; private static final String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS;
/** Internal property changed listener */ /** Internal property changed listener */
private IPropertyChangeListener fPropertyListener; private IPropertyChangeListener fPropertyListener;

View file

@ -1336,7 +1336,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private SurroundWithActionGroup fSurroundWithActionGroup; private SurroundWithActionGroup fSurroundWithActionGroup;
/** Pairs of brackets, used to match. */ /** Pairs of brackets, used to match. */
protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' }; protected static final char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' };
/** Matches the brackets. */ /** Matches the brackets. */
protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS); protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS);
@ -1348,24 +1348,24 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private CEditorErrorTickUpdater fCEditorErrorTickUpdater; private CEditorErrorTickUpdater fCEditorErrorTickUpdater;
/** Preference key for sub-word navigation, aka smart caret positioning */ /** Preference key for sub-word navigation, aka smart caret positioning */
public final static String SUB_WORD_NAVIGATION = "subWordNavigation"; //$NON-NLS-1$ public static final String SUB_WORD_NAVIGATION = "subWordNavigation"; //$NON-NLS-1$
/** Preference key for matching brackets */ /** Preference key for matching brackets */
public final static String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$ public static final String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$
/** Preference key for matching brackets color */ /** Preference key for matching brackets color */
public final static String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$ public static final String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$
/** Preference key for inactive code painter enablement */ /** Preference key for inactive code painter enablement */
public static final String INACTIVE_CODE_ENABLE = "inactiveCodeEnable"; //$NON-NLS-1$ public static final String INACTIVE_CODE_ENABLE = "inactiveCodeEnable"; //$NON-NLS-1$
/** Preference key for inactive code painter color */ /** Preference key for inactive code painter color */
public static final String INACTIVE_CODE_COLOR = "inactiveCodeColor"; //$NON-NLS-1$ public static final String INACTIVE_CODE_COLOR = "inactiveCodeColor"; //$NON-NLS-1$
/** Preference key for automatically closing strings */ /** Preference key for automatically closing strings */
private final static String CLOSE_STRINGS = PreferenceConstants.EDITOR_CLOSE_STRINGS; private static final String CLOSE_STRINGS = PreferenceConstants.EDITOR_CLOSE_STRINGS;
/** Preference key for automatically closing brackets and parenthesis */ /** Preference key for automatically closing brackets and parenthesis */
private final static String CLOSE_BRACKETS = PreferenceConstants.EDITOR_CLOSE_BRACKETS; private static final String CLOSE_BRACKETS = PreferenceConstants.EDITOR_CLOSE_BRACKETS;
/** Preference key for automatically closing angular brackets */ /** Preference key for automatically closing angular brackets */
private final static String CLOSE_ANGULAR_BRACKETS = PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS; private static final String CLOSE_ANGULAR_BRACKETS = PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS;
/** Preference key for compiler task tags */ /** Preference key for compiler task tags */
private final static String TODO_TASK_TAGS = CCorePreferenceConstants.TODO_TASK_TAGS; private static final String TODO_TASK_TAGS = CCorePreferenceConstants.TODO_TASK_TAGS;
/** /**
* This editor's projection support * This editor's projection support

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. * Copyright (c) 2006, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
* IBM Corporation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser; package org.eclipse.cdt.internal.ui.includebrowser;
@ -37,7 +38,10 @@ public class IBFile {
public IBFile(ICProject preferredProject, IIndexFileLocation location) throws CModelException { public IBFile(ICProject preferredProject, IIndexFileLocation location) throws CModelException {
fLocation= location; fLocation= location;
fTU= CoreModelUtil.findTranslationUnitForLocation(location, preferredProject); ITranslationUnit TU = CoreModelUtil.findTranslationUnitForLocation(location, preferredProject);
if (TU == null) //for EFS file that might not be on this filesystem
TU = CoreModelUtil.findTranslationUnitForLocation(location.getURI(), preferredProject);
fTU = TU;
String name= fLocation.getURI().getPath(); String name= fLocation.getURI().getPath();
fName= name.substring(name.lastIndexOf('/')+1); fName= name.substring(name.lastIndexOf('/')+1);
} }

View file

@ -67,7 +67,7 @@ public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock {
/** /**
* Some C++ source code used for preview. * Some C++ source code used for preview.
*/ */
private final static String PREVIEW= private static final String PREVIEW=
"/*\n* " + //$NON-NLS-1$ "/*\n* " + //$NON-NLS-1$
FormatterMessages.CodingStyleConfigurationBlock_preview_title + FormatterMessages.CodingStyleConfigurationBlock_preview_title +
"\n*/\n" + //$NON-NLS-1$ "\n*/\n" + //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others * Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -16,7 +16,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration; import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
@ -106,8 +105,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
} else if (node instanceof IASTName) { } else if (node instanceof IASTName) {
return isNameEqual(trailNode, node); return isNameEqual(trailNode, node);
} else { } else {
Assert.isLegal(false, "Unexpected node type " + node.getClass().getSimpleName() + //$NON-NLS-1$ CUIPlugin.logError("Unexpected node type " + node.getClass().getSimpleName()); //$NON-NLS-1$
", this code shoud not be reached"); //$NON-NLS-1$
return true; return true;
} }
} }
@ -140,10 +138,12 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
ICPPASTNamedTypeSpecifier decl = (ICPPASTNamedTypeSpecifier) node; ICPPASTNamedTypeSpecifier decl = (ICPPASTNamedTypeSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl) return isDeclSpecifierEqual(trailDecl, decl)
&& isSameNamedTypeSpecifierName(trailDecl, decl) && isSameNamedTypeSpecifierName(trailDecl, decl)
&& trailDecl.isTypename() == decl.isTypename() && trailDecl.isConstexpr() == decl.isConstexpr()
&& trailDecl.isExplicit() == decl.isExplicit() && trailDecl.isExplicit() == decl.isExplicit()
&& trailDecl.isFriend() == decl.isFriend() && trailDecl.isFriend() == decl.isFriend()
&& trailDecl.isVirtual() == decl.isVirtual(); && trailDecl.isThreadLocal() == decl.isThreadLocal()
&& trailDecl.isTypename() == decl.isTypename()
&& trailDecl.isVirtual() == decl.isVirtual();
} else if (trailNode instanceof IASTNamedTypeSpecifier) { } else if (trailNode instanceof IASTNamedTypeSpecifier) {
IASTNamedTypeSpecifier trailDecl = (IASTNamedTypeSpecifier) trailNode; IASTNamedTypeSpecifier trailDecl = (IASTNamedTypeSpecifier) trailNode;
IASTNamedTypeSpecifier decl = (IASTNamedTypeSpecifier) node; IASTNamedTypeSpecifier decl = (IASTNamedTypeSpecifier) node;
@ -158,25 +158,27 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
IASTCompositeTypeSpecifier trailDecl = (IASTCompositeTypeSpecifier) trailNode; IASTCompositeTypeSpecifier trailDecl = (IASTCompositeTypeSpecifier) trailNode;
IASTCompositeTypeSpecifier decl = (IASTCompositeTypeSpecifier) node; IASTCompositeTypeSpecifier decl = (IASTCompositeTypeSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl) return isDeclSpecifierEqual(trailDecl, decl)
&& trailDecl.getKey() == decl.getKey(); && trailDecl.getKey() == decl.getKey();
} else if (trailNode instanceof ICPPASTDeclSpecifier) { } else if (trailNode instanceof ICPPASTDeclSpecifier) {
ICPPASTDeclSpecifier trailDecl = (ICPPASTDeclSpecifier) trailNode; ICPPASTDeclSpecifier trailDecl = (ICPPASTDeclSpecifier) trailNode;
ICPPASTDeclSpecifier decl = (ICPPASTDeclSpecifier) node; ICPPASTDeclSpecifier decl = (ICPPASTDeclSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl) return isDeclSpecifierEqual(trailDecl, decl)
&& trailDecl.isExplicit() == decl.isExplicit() && trailDecl.isConstexpr() == decl.isConstexpr()
&& trailDecl.isFriend() == decl.isFriend() && trailDecl.isExplicit() == decl.isExplicit()
&& trailDecl.isVirtual() == decl.isVirtual(); && trailDecl.isFriend() == decl.isFriend()
&& trailDecl.isThreadLocal() == decl.isThreadLocal()
&& trailDecl.isVirtual() == decl.isVirtual();
} else if (trailNode instanceof ICASTDeclSpecifier) { } else if (trailNode instanceof ICASTDeclSpecifier) {
ICASTDeclSpecifier trailDecl = (ICASTDeclSpecifier) trailNode; ICASTDeclSpecifier trailDecl = (ICASTDeclSpecifier) trailNode;
ICASTDeclSpecifier decl = (ICASTDeclSpecifier) node; ICASTDeclSpecifier decl = (ICASTDeclSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl) return isDeclSpecifierEqual(trailDecl, decl)
&& trailDecl.isRestrict() == decl.isRestrict(); && trailDecl.isRestrict() == decl.isRestrict();
} else if (trailNode instanceof IASTDeclSpecifier) { } else if (trailNode instanceof IASTDeclSpecifier) {
IASTDeclSpecifier trailDecl = (IASTDeclSpecifier) trailNode; IASTDeclSpecifier trailDecl = (IASTDeclSpecifier) trailNode;
IASTDeclSpecifier decl = (IASTDeclSpecifier) node; IASTDeclSpecifier decl = (IASTDeclSpecifier) node;
return isDeclSpecifierEqual(trailDecl, decl); return isDeclSpecifierEqual(trailDecl, decl);
} else { } else {
//is same // The same.
return true; return true;
} }
} }
@ -315,8 +317,10 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
if (trailDeclSpeci instanceof ICPPASTDeclSpecifier) { if (trailDeclSpeci instanceof ICPPASTDeclSpecifier) {
ICPPASTDeclSpecifier trailCppDecl= (ICPPASTDeclSpecifier) trailDeclSpeci; ICPPASTDeclSpecifier trailCppDecl= (ICPPASTDeclSpecifier) trailDeclSpeci;
ICPPASTDeclSpecifier cppDecl= (ICPPASTDeclSpecifier) declSpeci; ICPPASTDeclSpecifier cppDecl= (ICPPASTDeclSpecifier) declSpeci;
if (trailCppDecl.isExplicit() != cppDecl.isExplicit() if (trailCppDecl.isConstexpr() != cppDecl.isConstexpr()
|| trailCppDecl.isExplicit() != cppDecl.isExplicit()
|| trailCppDecl.isFriend() != cppDecl.isFriend() || trailCppDecl.isFriend() != cppDecl.isFriend()
|| trailCppDecl.isThreadLocal() != cppDecl.isThreadLocal()
|| trailCppDecl.isVirtual() != cppDecl.isVirtual()) { || trailCppDecl.isVirtual() != cppDecl.isVirtual()) {
return false; return false;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2011 Google, Inc and others. * Copyright (c) 2011, 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -45,7 +45,7 @@ public class AccessorDescriptor implements Comparable<AccessorDescriptor> {
this.fieldName = fieldDescriptor.getFieldName(); this.fieldName = fieldDescriptor.getFieldName();
if (accessorName != null) { if (accessorName != null) {
this.accessorFactory = AccessorFactory.createFactory(kind, fieldName, this.accessorFactory = AccessorFactory.createFactory(kind, fieldName,
fieldDescriptor.getFieldDeclaration(), accessorName); fieldDescriptor.getFieldDeclarator(), accessorName);
this.accessorDeclaration = accessorFactory.createDeclaration(); this.accessorDeclaration = accessorFactory.createDeclaration();
for (IASTFunctionDefinition currentDefinition : context.existingFunctionDefinitions) { for (IASTFunctionDefinition currentDefinition : context.existingFunctionDefinitions) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others * Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -55,26 +55,29 @@ import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescrip
public abstract class AccessorFactory { public abstract class AccessorFactory {
protected final IASTName fieldName; protected final IASTName fieldName;
protected final IASTSimpleDeclaration fieldDeclaration; protected final IASTDeclarator fieldDeclarator;
private final IASTDeclSpecifier declSpecifier;
protected final String accessorName; protected final String accessorName;
protected boolean passByReference; protected boolean passByReference;
public static AccessorFactory createFactory(AccessorKind kind, IASTName fieldName, public static AccessorFactory createFactory(AccessorKind kind, IASTName fieldName,
IASTSimpleDeclaration fieldDeclaration, String accessorName) { IASTDeclarator declarator, String accessorName) {
if (kind == AccessorKind.GETTER) { if (kind == AccessorKind.GETTER) {
return new GetterFactory(fieldName, fieldDeclaration, accessorName); return new GetterFactory(fieldName, declarator, accessorName);
} else { } else {
return new SetterFactory(fieldName, fieldDeclaration, accessorName); return new SetterFactory(fieldName, declarator, accessorName);
} }
} }
protected AccessorFactory(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration, protected AccessorFactory(IASTName fieldName, IASTDeclarator fieldDeclarator, String accessorName) {
String accessorName) {
this.fieldName = fieldName; this.fieldName = fieldName;
this.fieldDeclaration = fieldDeclaration; this.fieldDeclarator = fieldDeclarator;
this.accessorName = accessorName; this.accessorName = accessorName;
IType type = CPPVisitor.createType(fieldDeclaration.getDeclSpecifier()); IASTSimpleDeclaration declaration =
passByReference = TypeHelper.shouldBePassedByReference(type, fieldDeclaration.getTranslationUnit()); CPPVisitor.findAncestorWithType(fieldDeclarator, IASTSimpleDeclaration.class);
this.declSpecifier = declaration.getDeclSpecifier();
IType type = CPPVisitor.createType(declSpecifier);
passByReference = TypeHelper.shouldBePassedByReference(type, fieldDeclarator.getTranslationUnit());
} }
/** /**
@ -90,16 +93,16 @@ public abstract class AccessorFactory {
public abstract IASTFunctionDefinition createDefinition(ICPPASTQualifiedName className); public abstract IASTFunctionDefinition createDefinition(ICPPASTQualifiedName className);
protected IASTDeclSpecifier getParamOrReturnDeclSpecifier() { protected IASTDeclSpecifier getParamOrReturnDeclSpecifier() {
IASTDeclSpecifier declSpec = fieldDeclaration.getDeclSpecifier().copy(CopyStyle.withLocations); IASTDeclSpecifier declSpec = declSpecifier.copy(CopyStyle.withLocations);
if (passByReference || fieldDeclaration.getDeclarators()[0] instanceof IASTArrayDeclarator) { if (passByReference || fieldDeclarator instanceof IASTArrayDeclarator) {
declSpec.setConst(true); declSpec.setConst(true);
} }
return declSpec; return declSpec;
} }
private static class GetterFactory extends AccessorFactory { private static class GetterFactory extends AccessorFactory {
GetterFactory(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration, String getterName) { GetterFactory(IASTName fieldName, IASTDeclarator fieldDeclarator, String getterName) {
super(fieldName, fieldDeclaration, getterName); super(fieldName, fieldDeclarator, getterName);
} }
@Override @Override
@ -142,7 +145,7 @@ public abstract class AccessorFactory {
getterName.setName(accessorName.toCharArray()); getterName.setName(accessorName.toCharArray());
// Copy declarator hierarchy // Copy declarator hierarchy
IASTDeclarator topDeclarator = fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations); IASTDeclarator topDeclarator = fieldDeclarator.copy(CopyStyle.withLocations);
if (topDeclarator instanceof IASTArrayDeclarator) { if (topDeclarator instanceof IASTArrayDeclarator) {
boolean isCpp = topDeclarator instanceof ICPPASTArrayDeclarator; boolean isCpp = topDeclarator instanceof ICPPASTArrayDeclarator;
@ -190,8 +193,8 @@ public abstract class AccessorFactory {
} }
private static class SetterFactory extends AccessorFactory { private static class SetterFactory extends AccessorFactory {
SetterFactory(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration, String setterName) { SetterFactory(IASTName fieldName, IASTDeclarator fieldDeclarator, String setterName) {
super(fieldName, fieldDeclaration, setterName); super(fieldName, fieldDeclarator, setterName);
} }
@Override @Override
@ -215,7 +218,7 @@ public abstract class AccessorFactory {
CPPASTCompoundStatement compound = new CPPASTCompoundStatement(); CPPASTCompoundStatement compound = new CPPASTCompoundStatement();
CPPASTExpressionStatement exprStmt = new CPPASTExpressionStatement(); CPPASTExpressionStatement exprStmt = new CPPASTExpressionStatement();
CPPASTBinaryExpression binExpr = new CPPASTBinaryExpression(); CPPASTBinaryExpression binExpr = new CPPASTBinaryExpression();
IASTDeclarator innerDeclarator = fieldDeclaration.getDeclarators()[0]; IASTDeclarator innerDeclarator = fieldDeclarator;
while (innerDeclarator.getNestedDeclarator() != null) { while (innerDeclarator.getNestedDeclarator() != null) {
innerDeclarator = innerDeclarator.getNestedDeclarator(); innerDeclarator = innerDeclarator.getNestedDeclarator();
} }
@ -252,7 +255,7 @@ public abstract class AccessorFactory {
declarator.setName(setterName); declarator.setName(setterName);
} }
CPPASTParameterDeclaration parameterDeclaration = new CPPASTParameterDeclaration(); CPPASTParameterDeclaration parameterDeclaration = new CPPASTParameterDeclaration();
IASTDeclarator parameterDeclarator = fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations); IASTDeclarator parameterDeclarator = fieldDeclarator.copy(CopyStyle.withLocations);
parameterDeclarator.setName(getSetterParameterName()); parameterDeclarator.setName(getSetterParameterName());
if (passByReference) { if (passByReference) {
parameterDeclarator.addPointerOperator(new CPPASTReferenceOperator(false)); parameterDeclarator.addPointerOperator(new CPPASTReferenceOperator(false));

View file

@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2011, 2012 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters; package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
import java.util.ArrayList; import java.util.ArrayList;
@ -6,9 +16,9 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IPointerType;
@ -23,21 +33,21 @@ import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescrip
class FieldDescriptor { class FieldDescriptor {
private final IASTName fieldName; private final IASTName fieldName;
private final IASTSimpleDeclaration fieldDeclaration; private final IASTDeclarator fieldDeclarator;
private final AccessorDescriptor getter; private final AccessorDescriptor getter;
private final AccessorDescriptor setter; private final AccessorDescriptor setter;
private final AccessorDescriptor[] childNodes; private final AccessorDescriptor[] childNodes;
private final GetterSetterContext context; private final GetterSetterContext context;
FieldDescriptor(IASTSimpleDeclaration fieldDeclaration, GetterSetterContext context) { FieldDescriptor(IASTDeclarator field, GetterSetterContext context) {
this.fieldName = GetterSetterContext.getDeclarationName(fieldDeclaration); this.fieldName = GetterSetterContext.getDeclaratorName(field);
this.fieldDeclaration = fieldDeclaration; this.fieldDeclarator = field;
this.context = context; this.context = context;
Set<String> namesToAvoid = getNamesToAvoid(); Set<String> namesToAvoid = getNamesToAvoid();
String name = GetterSetterNameGenerator.generateGetterName(fieldName, namesToAvoid); String name = GetterSetterNameGenerator.generateGetterName(fieldName, namesToAvoid);
this.getter = new AccessorDescriptor(AccessorKind.GETTER, name, this); this.getter = new AccessorDescriptor(AccessorKind.GETTER, name, this);
name = GetterSetterNameGenerator.generateSetterName(fieldName, namesToAvoid); name = GetterSetterNameGenerator.generateSetterName(fieldName, namesToAvoid);
if (!isAssignable(fieldDeclaration)) if (!isAssignable(field))
name = null; name = null;
this.setter = new AccessorDescriptor(AccessorKind.SETTER, name, this); this.setter = new AccessorDescriptor(AccessorKind.SETTER, name, this);
@ -54,8 +64,8 @@ class FieldDescriptor {
private Set<String> getNamesToAvoid() { private Set<String> getNamesToAvoid() {
Set<String> namesToAvoid = new HashSet<String>(); Set<String> namesToAvoid = new HashSet<String>();
// Add field names. // Add field names.
for (IASTSimpleDeclaration fieldDeclaration : context.existingFields) { for (IASTDeclarator fieldDeclarator : context.existingFields) {
namesToAvoid.add(String.valueOf(GetterSetterContext.getDeclarationName(fieldDeclaration).getSimpleID())); namesToAvoid.add(String.valueOf(GetterSetterContext.getDeclaratorName(fieldDeclarator).getSimpleID()));
} }
// Add constructor name. // Add constructor name.
if (!context.existingFields.isEmpty()) { if (!context.existingFields.isEmpty()) {
@ -69,8 +79,8 @@ class FieldDescriptor {
return namesToAvoid; return namesToAvoid;
} }
private static boolean isAssignable(IASTSimpleDeclaration declaration) { private static boolean isAssignable(IASTDeclarator fieldDeclarator) {
IASTName name = GetterSetterContext.getDeclarationName(declaration); IASTName name = GetterSetterContext.getDeclaratorName(fieldDeclarator);
IBinding binding = name.resolveBinding(); IBinding binding = name.resolveBinding();
if (!(binding instanceof ICPPField)) if (!(binding instanceof ICPPField))
return false; return false;
@ -107,8 +117,8 @@ class FieldDescriptor {
return fieldName; return fieldName;
} }
public IASTSimpleDeclaration getFieldDeclaration() { public IASTDeclarator getFieldDeclarator() {
return fieldDeclaration; return fieldDeclarator;
} }
public AccessorDescriptor getGetter() { public AccessorDescriptor getGetter() {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others. * Rapperswil, University of applied sciences and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -26,7 +26,6 @@ import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus; import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@ -44,6 +43,7 @@ import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ContainerNode; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ContainerNode;
import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
@ -87,7 +87,6 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
} }
} }
private static final String MEMBER_DECLARATION = "MEMBER_DECLARATION"; //$NON-NLS-1$
private final GetterSetterContext context; private final GetterSetterContext context;
private InsertLocation definitionInsertLocation; private InsertLocation definitionInsertLocation;
@ -195,27 +194,23 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
@Override @Override
public int visit(IASTDeclaration declaration) { public int visit(IASTDeclaration declaration) {
if (declaration instanceof IASTSimpleDeclaration) { if (declaration instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration fieldDeclaration = (IASTSimpleDeclaration) declaration; IASTSimpleDeclaration simpleDeclaration = (IASTSimpleDeclaration) declaration;
ASTNodeProperty props = fieldDeclaration.getPropertyInParent(); if (simpleDeclaration.getPropertyInParent() == IASTCompositeTypeSpecifier.MEMBER_DECLARATION) {
if (props.getName().contains(MEMBER_DECLARATION)) { for (IASTDeclarator declarator : simpleDeclaration.getDeclarators()) {
final IASTDeclarator[] declarators = fieldDeclaration.getDeclarators(); IASTDeclarator innermostDeclarator = declarator;
if (declarators.length > 0) {
IASTDeclarator innermostDeclarator = declarators[0];
while (innermostDeclarator.getNestedDeclarator() != null) { while (innermostDeclarator.getNestedDeclarator() != null) {
innermostDeclarator = innermostDeclarator.getNestedDeclarator(); innermostDeclarator = innermostDeclarator.getNestedDeclarator();
} }
if ((innermostDeclarator instanceof IASTFunctionDeclarator)) { if ((innermostDeclarator instanceof IASTFunctionDeclarator)) {
context.existingFunctionDeclarations.add(fieldDeclaration); context.existingFunctionDeclarations.add(simpleDeclaration);
} else if (fieldDeclaration.isPartOfTranslationUnitFile()) { } else if (simpleDeclaration.isPartOfTranslationUnitFile()) {
context.existingFields.add(fieldDeclaration); context.existingFields.add(declarator);
} }
} }
} }
} } else if (declaration instanceof IASTFunctionDefinition) {
if (declaration instanceof IASTFunctionDefinition) {
IASTFunctionDefinition functionDefinition = (IASTFunctionDefinition) declaration; IASTFunctionDefinition functionDefinition = (IASTFunctionDefinition) declaration;
ASTNodeProperty props = functionDefinition.getPropertyInParent(); if (functionDefinition.getPropertyInParent() == IASTCompositeTypeSpecifier.MEMBER_DECLARATION) {
if (props.getName().contains(MEMBER_DECLARATION)) {
context.existingFunctionDefinitions.add(functionDefinition); context.existingFunctionDefinitions.add(functionDefinition);
} }
} }
@ -246,7 +241,7 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
addDefinition(collector, definitions, pm); addDefinition(collector, definitions, pm);
} }
ICPPASTCompositeTypeSpecifier classDefinition = ICPPASTCompositeTypeSpecifier classDefinition =
(ICPPASTCompositeTypeSpecifier) context.existingFields.get(context.existingFields.size() - 1).getParent(); CPPVisitor.findAncestorWithType(context.existingFields.get(0), ICPPASTCompositeTypeSpecifier.class);
ClassMemberInserter.createChange(classDefinition, VisibilityEnum.v_public, ClassMemberInserter.createChange(classDefinition, VisibilityEnum.v_public,
getterAndSetters, false, collector); getterAndSetters, false, collector);
@ -275,7 +270,8 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring {
return; return;
} }
IASTSimpleDeclaration decl = context.existingFields.get(0); IASTSimpleDeclaration decl =
CPPVisitor.findAncestorWithType(context.existingFields.get(0), IASTSimpleDeclaration.class);
MethodDefinitionInsertLocationFinder locationFinder = new MethodDefinitionInsertLocationFinder(); MethodDefinitionInsertLocationFinder locationFinder = new MethodDefinitionInsertLocationFinder();
InsertLocation location = locationFinder.find(tu, decl.getFileLocation(), decl.getParent(), InsertLocation location = locationFinder.find(tu, decl.getFileLocation(), decl.getParent(),
refactoringContext, pm); refactoringContext, pm);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others * Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -28,7 +28,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescriptor.AccessorKind; import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescriptor.AccessorKind;
public class GetterSetterContext implements ITreeContentProvider { public class GetterSetterContext implements ITreeContentProvider {
final List<IASTSimpleDeclaration> existingFields = new ArrayList<IASTSimpleDeclaration>(); final List<IASTDeclarator> existingFields = new ArrayList<IASTDeclarator>();
final List<IASTFunctionDefinition> existingFunctionDefinitions = new ArrayList<IASTFunctionDefinition>(); final List<IASTFunctionDefinition> existingFunctionDefinitions = new ArrayList<IASTFunctionDefinition>();
final List<IASTSimpleDeclaration> existingFunctionDeclarations = new ArrayList<IASTSimpleDeclaration>(); final List<IASTSimpleDeclaration> existingFunctionDeclarations = new ArrayList<IASTSimpleDeclaration>();
final SortedSet<AccessorDescriptor> selectedAccessors = new TreeSet<AccessorDescriptor>(); final SortedSet<AccessorDescriptor> selectedAccessors = new TreeSet<AccessorDescriptor>();
@ -110,7 +110,7 @@ public class GetterSetterContext implements ITreeContentProvider {
private List<FieldDescriptor> getFieldDescriptors() { private List<FieldDescriptor> getFieldDescriptors() {
if (fieldDescriptors == null) { if (fieldDescriptors == null) {
fieldDescriptors = new ArrayList<FieldDescriptor>(); fieldDescriptors = new ArrayList<FieldDescriptor>();
for (IASTSimpleDeclaration field : existingFields) { for (IASTDeclarator field : existingFields) {
FieldDescriptor descriptor = new FieldDescriptor(field, this); FieldDescriptor descriptor = new FieldDescriptor(field, this);
if (descriptor.missingGetterOrSetter()) { if (descriptor.missingGetterOrSetter()) {
fieldDescriptors.add(descriptor); fieldDescriptors.add(descriptor);
@ -120,11 +120,14 @@ public class GetterSetterContext implements ITreeContentProvider {
return fieldDescriptors; return fieldDescriptors;
} }
static IASTName getDeclarationName(IASTSimpleDeclaration declaration) { static IASTName getDeclaratorName(IASTDeclarator declarator) {
IASTDeclarator declarator = declaration.getDeclarators()[0];
while (declarator.getNestedDeclarator() != null) { while (declarator.getNestedDeclarator() != null) {
declarator = declarator.getNestedDeclarator(); declarator = declarator.getNestedDeclarator();
} }
return declarator.getName(); return declarator.getName();
} }
static IASTName getDeclarationName(IASTSimpleDeclaration declaration) {
return getDeclaratorName(declaration.getDeclarators()[0]);
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik * Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others * Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -197,7 +197,14 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
} }
} }
/**
* @return true if the preview job could still be running, false otherwise
*/
protected boolean cancelPreviewJob() { protected boolean cancelPreviewJob() {
if (delayedPreviewUpdater == null) {
return false;
}
// We cannot rely on getState being accurate in all cases so we only use this // We cannot rely on getState being accurate in all cases so we only use this
// as a hint to change the preview text // as a hint to change the preview text
if (delayedPreviewUpdater.getState() != Job.NONE) { if (delayedPreviewUpdater.getState() != Job.NONE) {
@ -207,6 +214,10 @@ public class ParameterNamesInputPage extends UserInputWizardPage {
} }
protected void joinPreviewJob() { protected void joinPreviewJob() {
if (delayedPreviewUpdater == null) {
return;
}
try { try {
delayedPreviewUpdater.join(); delayedPreviewUpdater.join();
} catch (InterruptedException e1) { } catch (InterruptedException e1) {

View file

@ -57,6 +57,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
@ -321,15 +322,26 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
} }
private IName[] findDeclarations(IIndex index, IASTTranslationUnit ast, IBinding binding) throws CoreException { private IName[] findDeclarations(IIndex index, IASTTranslationUnit ast, IBinding binding) throws CoreException {
IName[] declNames= ast.getDeclarationsInAST(binding); IASTName[] astNames= ast.getDeclarationsInAST(binding);
for (int i = 0; i < declNames.length; i++) { ArrayList<IASTName> usingDeclarations = null;
IName name = declNames[i]; for (int i = 0; i < astNames.length; i++) {
if (name.isDefinition()) IASTName name = astNames[i];
declNames[i]= null; if (name.isDefinition()) {
astNames[i]= null;
} else if (CPPVisitor.findAncestorWithType(name, ICPPASTUsingDeclaration.class) != null) {
if (usingDeclarations == null)
usingDeclarations = new ArrayList<IASTName>(1);
usingDeclarations.add(name);
astNames[i]= null;
}
} }
declNames= ArrayUtil.removeNulls(IName.class, declNames); IName[] declNames= ArrayUtil.removeNulls(astNames);
if (declNames.length == 0) { if (declNames.length == 0) {
declNames= index.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES); declNames = index.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
}
// 'using' declarations are considered only when there are no other declarations.
if (declNames.length == 0 && usingDeclarations != null) {
declNames = usingDeclarations.toArray(new IName[usingDeclarations.size()]);
} }
return declNames; return declNames;
} }

View file

@ -151,7 +151,7 @@ public class CBreakIterator extends BreakIterator {
private int fState; private int fState;
private final static int[][] MATRIX= new int[][] { private static final int[][] MATRIX= new int[][] {
// K_INVALID, K_LOWER, K_UPPER, K_UNDERSCORE, K_OTHER // K_INVALID, K_LOWER, K_UPPER, K_UNDERSCORE, K_OTHER
{ S_EXIT, S_LOWER, S_ONE_CAP, S_UNDERSCORE, S_LOWER }, // S_INIT { S_EXIT, S_LOWER, S_ONE_CAP, S_UNDERSCORE, S_LOWER }, // S_INIT
{ S_EXIT, S_LOWER, S_EXIT, S_UNDERSCORE, S_LOWER }, // S_LOWER { S_EXIT, S_LOWER, S_EXIT, S_UNDERSCORE, S_LOWER }, // S_LOWER

View file

@ -262,7 +262,7 @@ public final class CHeuristicScanner implements Symbols {
/* preset stop conditions */ /* preset stop conditions */
private final StopCondition fNonWSDefaultPart= new NonWhitespaceDefaultPartition(); private final StopCondition fNonWSDefaultPart= new NonWhitespaceDefaultPartition();
private final static StopCondition fNonWS= new NonWhitespace(); private static final StopCondition fNonWS= new NonWhitespace();
private final StopCondition fNonIdent= new NonJavaIdentifierPartDefaultPartition(); private final StopCondition fNonIdent= new NonJavaIdentifierPartDefaultPartition();
/** /**

View file

@ -31,18 +31,19 @@ import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.cdt.utils.spawner.ProcessFactory; import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.ILaunchManager;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule; import org.junit.Rule;
import org.junit.rules.TestName; import org.junit.rules.TestName;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
/** /**
* This is the base class for the GDB/MI Unit tests. * This is the base class for the GDB/MI Unit tests.
@ -53,19 +54,22 @@ import org.junit.rules.TestName;
* code is to be run. * code is to be run.
*/ */
public class BaseTestCase { public class BaseTestCase {
// Timeout value for each individual test
private final static int TEST_TIMEOUT = 5 * 60 * 1000; // 5 minutes in milliseconds
// Make the current test naem available through testName.getMethodName() // Make the current test naem available through testName.getMethodName()
@Rule public TestName testName = new TestName(); @Rule public TestName testName = new TestName();
// Add a timeout for each test, to make sure no test hangs
@Rule public TestRule timeout = new Timeout(TEST_TIMEOUT);
public static final String ATTR_DEBUG_SERVER_NAME = TestsPlugin.PLUGIN_ID + ".DEBUG_SERVER_NAME"; public static final String ATTR_DEBUG_SERVER_NAME = TestsPlugin.PLUGIN_ID + ".DEBUG_SERVER_NAME";
private static final String DEFAULT_TEST_APP = "data/launch/bin/GDBMIGenericTestApp.exe"; private static final String DEFAULT_TEST_APP = "data/launch/bin/GDBMIGenericTestApp.exe";
private static GdbLaunch fLaunch; private static GdbLaunch fLaunch;
// The set of attributes used for the launch // The set of attributes used for the launch of a single test.
// These are seset to their default whenever a new class private Map<String, Object> launchAttributes;
// of tests is started.
private static Map<String, Object> launchAttributes;
// A set of global launch attributes which are not // A set of global launch attributes which are not
// reset when we load a new class of tests. // reset when we load a new class of tests.
@ -87,11 +91,11 @@ public class BaseTestCase {
public GdbLaunch getGDBLaunch() { return fLaunch; } public GdbLaunch getGDBLaunch() { return fLaunch; }
public static void setLaunchAttribute(String key, Object value) { public void setLaunchAttribute(String key, Object value) {
launchAttributes.put(key, value); launchAttributes.put(key, value);
} }
public static void removeLaunchAttribute(String key) { public void removeLaunchAttribute(String key) {
launchAttributes.remove(key); launchAttributes.remove(key);
} }
@ -105,7 +109,7 @@ public class BaseTestCase {
public synchronized MIStoppedEvent getInitialStoppedEvent() { return fInitialStoppedEvent; } public synchronized MIStoppedEvent getInitialStoppedEvent() { return fInitialStoppedEvent; }
public static boolean isRemoteSession() { public boolean isRemoteSession() {
return launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE) return launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE)
.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); .equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
} }
@ -174,12 +178,16 @@ public class BaseTestCase {
} }
} }
@BeforeClass @Before
public static void baseBeforeClassMethod() { public void doBeforeTest() throws Exception {
// Clear all launch attributes before starting a new class of tests setLaunchAttributes();
doLaunch();
}
protected void setLaunchAttributes() {
// Clear all launch attributes before starting a new test
launchAttributes = new HashMap<String, Object>(); launchAttributes = new HashMap<String, Object>();
// Setup information for the launcher
launchAttributes.put(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, DEFAULT_TEST_APP); launchAttributes.put(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, DEFAULT_TEST_APP);
launchAttributes.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true); launchAttributes.put(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
@ -196,14 +204,21 @@ public class BaseTestCase {
launchAttributes.put(IGDBLaunchConfigurationConstants.ATTR_HOST, "localhost"); launchAttributes.put(IGDBLaunchConfigurationConstants.ATTR_HOST, "localhost");
launchAttributes.put(IGDBLaunchConfigurationConstants.ATTR_PORT, "9999"); launchAttributes.put(IGDBLaunchConfigurationConstants.ATTR_PORT, "9999");
setGdbVersion();
// Set the global launch attributes // Set the global launch attributes
launchAttributes.putAll(globalLaunchAttributes); launchAttributes.putAll(globalLaunchAttributes);
} }
@Before /**
public void baseBeforeMethod() throws Exception { * Launch GDB. The launch attributes must have been set already.
*/
protected void doLaunch() throws Exception {
boolean remote = launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE).equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
System.out.println("===================================================================================================="); System.out.println("====================================================================================================");
System.out.println("Running test: " + testName.getMethodName() + " using GDB: " + launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME)); System.out.println(String.format("Running test: %s using GDB: %s remote %s",
testName.getMethodName(), launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME), remote ? "on" : "off"));
System.out.println("===================================================================================================="); System.out.println("====================================================================================================");
boolean postMortemLaunch = launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE) boolean postMortemLaunch = launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE)
@ -272,22 +287,22 @@ public class BaseTestCase {
} }
@After @After
public void baseAfterMethod() throws Exception { public void doAfterTest() throws Exception {
if (fLaunch != null) { if (fLaunch != null) {
fLaunch.terminate(); try {
fLaunch.terminate();
} catch (DebugException e) {
assert false : "Could not terminate launch";
}
fLaunch = null; fLaunch = null;
} }
} }
@AfterClass
public static void baseAfterClassMehod() throws Exception {
}
/** /**
* This method start gdbserver on the localhost. * This method start gdbserver on the localhost.
* If the user specified a different host, things won't work. * If the user specified a different host, things won't work.
*/ */
private static void launchGdbServer() { private void launchGdbServer() {
if (launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE) if (launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE)
.equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE)) { .equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE)) {
if (launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP).equals(Boolean.TRUE)) { if (launchAttributes.get(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP).equals(Boolean.TRUE)) {
@ -331,11 +346,15 @@ public class BaseTestCase {
* string that contains the major and minor version number, e.g., * string that contains the major and minor version number, e.g.,
* "6.8" * "6.8"
*/ */
protected static void setGdbProgramNamesLaunchAttributes(String version) { public static void setGdbProgramNamesLaunchAttributes(String version) {
// See bugzilla 303811 for why we have to append ".exe" on Windows // See bugzilla 303811 for why we have to append ".exe" on Windows
boolean isWindows = Platform.getOS().equals(Platform.OS_WIN32); boolean isWindows = Platform.getOS().equals(Platform.OS_WIN32);
BaseTestCase.setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb." + version + (isWindows ? ".exe" : "")); setGlobalLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb." + version + (isWindows ? ".exe" : ""));
BaseTestCase.setLaunchAttribute(ATTR_DEBUG_SERVER_NAME, "gdbserver." + version + (isWindows ? ".exe" : "")); setGlobalLaunchAttribute(ATTR_DEBUG_SERVER_NAME, "gdbserver." + version + (isWindows ? ".exe" : ""));
}
protected void setGdbVersion() {
// Leave empty for the base class
} }
/** /**

View file

@ -22,8 +22,6 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -35,8 +33,7 @@ public class CommandTimeoutTest extends BaseTestCase {
private static int fgTimeout = IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT; private static int fgTimeout = IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT;
@BeforeClass @BeforeClass
public static void beforeClassMethod() { public static void doBeforeClass() throws Exception {
// Save the original values of the timeout-related preferences
fgTimeoutEnabled = Platform.getPreferencesService().getBoolean( fgTimeoutEnabled = Platform.getPreferencesService().getBoolean(
GdbPlugin.PLUGIN_ID, GdbPlugin.PLUGIN_ID,
IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT,
@ -49,20 +46,31 @@ public class CommandTimeoutTest extends BaseTestCase {
null ); null );
} }
@Before @Override
@Override public void doBeforeTest() throws Exception {
public void baseBeforeMethod() throws Exception { setLaunchAttributes();
} // Can't run the launch right away because each test needs to first set some
// parameters. The individual tests will be responsible for starting the launch.
// Save the original values of the timeout-related preferences
}
@After
@Override @Override
public void baseAfterMethod() throws Exception { public void doAfterTest() throws Exception {
// Don't call super here, as the launch is already terminated
// Restore the timeout preferences // Restore the timeout preferences
IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID ); IEclipsePreferences node = InstanceScope.INSTANCE.getNode( GdbPlugin.PLUGIN_ID );
node.putBoolean( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, fgTimeoutEnabled ); node.putBoolean( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, fgTimeoutEnabled );
node.putInt( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, fgTimeout ); node.putInt( IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, fgTimeout );
} }
protected void performLaunchAndTerminate() throws Exception {
// perform the launch
doLaunch();
// terminate the launch right away
super.doAfterTest();
}
@Override @Override
protected boolean reallyLaunchGDBServer() { protected boolean reallyLaunchGDBServer() {
return false; return false;
@ -109,11 +117,6 @@ public class CommandTimeoutTest extends BaseTestCase {
} }
} }
private void performLaunchAndTerminate() throws Exception {
super.baseBeforeMethod();
super.baseAfterMethod();
}
/** /**
* Checks whether the given exception is an instance of {@link CoreException} * Checks whether the given exception is an instance of {@link CoreException}
* with the status code 20100 which indicates that a gdb command has been timed out. * with the status code 20100 which indicates that a gdb command has been timed out.

View file

@ -1,117 +0,0 @@
/*******************************************************************************
* Copyright (c) 2007, 2009 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Ericsson - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests;
import static org.junit.Assert.assertTrue;
import java.io.FileNotFoundException;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
/*
* This is an example of how to write new JUnit test cases
* for services of DSF.
*
* Each test class should extend BaseTestCase
* so as to automatically launch the application before
* each testcase and tear it down after.
*
* Also, each new test class must be added to the list within AllTest.
*
* Finally, each testcase should be @RunWith(BackgroundRunner.class)
* so as to release the UI thread and allow things such as
* timeouts to work in JUnit
*/
// Each test must run with the BackgroundRunner so as
// to release the UI thread
@RunWith(BackgroundRunner.class)
public class ExampleTest extends BaseTestCase {
@BeforeClass
public static void beforeClassMethod() {
// Things to run once specifically for this class,
// before starting this set of tests.
// Any method name can be used
// To choose your own test application, use the following form
// You must make sure the compiled binary is available in the
// specified location.
// If this method call is not made, the default GDBMIGenericTestApp
// will be used
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
"data/launch/bin/SpecialTestApp.exe");
// Other attributes can be changed here
}
@AfterClass
public static void afterClassMethod() {
// Things to run once specifically for this class,
// after the launch has been performed
// Any method name can be used
}
@Before
public void beforeMethod() {
// Things to run specifically for this class,
// before each test but after the launch has been performed
// The Launched used is for the default test application
// Any method name can be used
}
@After
public void afterMethod() {
// Things to run specifically for this class
// after each test but before the launch has been torn down
// Any method name can be used
}
// @Override
// public void baseBeforeMethod() {
// // Can be used to override and prevent the baseSetup from being run
// // The name baseBeforeMethod must be used
// }
// @Override
// public void baseAfterMethod() {
// // Can be used to override and prevent the baseTeardown from being run
// // The name baseAfterMethod must be used
// }
@Test
public void basicTest() {
// First test to run
assertTrue("", true);
}
@Test(timeout=5000)
public void timeoutTest() {
// Second test to run, which will timeout if not finished on time
assertTrue("", true);
}
@Test(expected=FileNotFoundException.class)
public void exceptionTest() throws FileNotFoundException {
// Third test to run which expects an exception
throw new FileNotFoundException("Just testing");
}
}

View file

@ -32,10 +32,7 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase; import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -62,8 +59,10 @@ public class GDBProcessesTest extends BaseTestCase {
*/ */
private final AsyncCompletionWaitor fWait = new AsyncCompletionWaitor(); private final AsyncCompletionWaitor fWait = new AsyncCompletionWaitor();
@Before @Override
public void init() throws Exception { public void doBeforeTest() throws Exception {
super.doBeforeTest();
fSession = getGDBLaunch().getSession(); fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
@ -75,14 +74,18 @@ public class GDBProcessesTest extends BaseTestCase {
fSession.getExecutor().submit(runnable).get(); fSession.getExecutor().submit(runnable).get();
} }
@After @Override
public void tearDown() { public void doAfterTest() throws Exception {
super.doAfterTest();
fProcService = null; fProcService = null;
fServicesTracker.dispose(); fServicesTracker.dispose();
} }
@BeforeClass @Override
public static void beforeClassMethod() { protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
EXEC_PATH + EXEC_NAME); EXEC_PATH + EXEC_NAME);
} }

View file

@ -45,8 +45,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.ILaunchManager;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -71,29 +69,27 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
protected boolean fRestart; protected boolean fRestart;
@Override @Override
@Before public void doBeforeTest() throws Exception {
public void baseBeforeMethod() throws Exception { setLaunchAttributes();
// The class BaseTestCase sets up the launch in its @BeforeClass method. // Can't run the launch right away because each test needs to first set some
// Usually this is ok, because every test uses the same launch configuration. // parameters. The individual tests will be responsible for starting the launch.
// However, for the tests of this class, we are changing the launch }
// configuration every time. Therefore, we need to reset it to the default
// before every test; that means in the @Before method instead of @BeforeClass @Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Reset the launch configuration
super.baseBeforeClassMethod();
// Set the binary // Set the binary
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, PROGRAM); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, PROGRAM);
// Can't run the launch right away because each test needs to first set some
// parameters. The individual tests will be responsible for starting the launch.
} }
// This method cannot be tagged as @Before, because the launch is not // This method cannot be tagged as @Before, because the launch is not
// running yet. We have to call this manually after all the proper // running yet. We have to call this manually after all the proper
// parameters have been set for the launch // parameters have been set for the launch
public void performLaunch() throws Exception { @Override
protected void doLaunch() throws Exception {
// perform the launch // perform the launch
super.baseBeforeMethod(); super.doLaunch();
fSession = getGDBLaunch().getSession(); fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@ -121,8 +117,10 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
} }
} }
@After @Override
public void shutdown() throws Exception { public void doAfterTest() throws Exception {
super.doAfterTest();
if (fServicesTracker != null) fServicesTracker.dispose(); if (fServicesTracker != null) fServicesTracker.dispose();
} }
@ -132,7 +130,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
private static String fFullProgramPath; private static String fFullProgramPath;
@Test @Test
public void getFullPath() throws Throwable { public void getFullPath() throws Throwable {
performLaunch(); doLaunch();
MIStoppedEvent stopped = getInitialStoppedEvent(); MIStoppedEvent stopped = getInitialStoppedEvent();
fFullProgramPath = stopped.getFrame().getFullname(); fFullProgramPath = stopped.getFrame().getFullname();
} }
@ -153,7 +151,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, dir); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, dir);
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, dir + PROGRAM_NAME); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, dir + PROGRAM_NAME);
performLaunch(); doLaunch();
Query<MIInfo> query = new Query<MIInfo>() { Query<MIInfo> query = new Query<MIInfo>() {
@Override @Override
@ -185,7 +183,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT,
"gdbinitThatDoesNotExist"); "gdbinitThatDoesNotExist");
try { try {
performLaunch(); doLaunch();
} catch (CoreException e) { } catch (CoreException e) {
// Success of the test // Success of the test
return; return;
@ -203,7 +201,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT,
".gdbinit"); ".gdbinit");
try { try {
performLaunch(); doLaunch();
} catch (CoreException e) { } catch (CoreException e) {
fail("Launch has failed even though the gdbinit file has the default name of .gdbinit"); fail("Launch has failed even though the gdbinit file has the default name of .gdbinit");
} }
@ -219,7 +217,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
public void testSourceGdbInit() throws Throwable { public void testSourceGdbInit() throws Throwable {
setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT,
"data/launch/src/launchConfigTestGdbinit"); "data/launch/src/launchConfigTestGdbinit");
performLaunch(); doLaunch();
MIStoppedEvent stoppedEvent = getInitialStoppedEvent(); MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
@ -286,7 +284,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
@Test @Test
public void testClearingEnvironment() throws Throwable { public void testClearingEnvironment() throws Throwable {
setLaunchAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, false); setLaunchAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, false);
performLaunch(); doLaunch();
SyncUtil.runToLocation("envTest"); SyncUtil.runToLocation("envTest");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
@ -335,7 +333,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
Map<String, String> map = new HashMap<String, String>(1); Map<String, String> map = new HashMap<String, String>(1);
map.put("LAUNCHTEST", "IS SET"); map.put("LAUNCHTEST", "IS SET");
setLaunchAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map); setLaunchAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
performLaunch(); doLaunch();
SyncUtil.runToLocation("envTest"); SyncUtil.runToLocation("envTest");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
@ -409,7 +407,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
Map<String, String> map = new HashMap<String, String>(1); Map<String, String> map = new HashMap<String, String>(1);
map.put("LAUNCHTEST", "IS SET"); map.put("LAUNCHTEST", "IS SET");
setLaunchAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map); setLaunchAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
performLaunch(); doLaunch();
SyncUtil.runToLocation("envTest"); SyncUtil.runToLocation("envTest");
MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
@ -477,7 +475,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
@Test @Test
public void testSettingArguments() throws Throwable { public void testSettingArguments() throws Throwable {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "1 2 3\n4 5 6"); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "1 2 3\n4 5 6");
performLaunch(); doLaunch();
MIStoppedEvent stoppedEvent = getInitialStoppedEvent(); MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
@ -544,7 +542,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
public void testStopAtMain() throws Throwable { public void testStopAtMain() throws Throwable {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "main"); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "main");
performLaunch(); doLaunch();
MIStoppedEvent stoppedEvent = getInitialStoppedEvent(); MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
assertTrue("Expected to stop at main:27 but got " + assertTrue("Expected to stop at main:27 but got " +
@ -571,7 +569,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
public void testStopAtOther() throws Throwable { public void testStopAtOther() throws Throwable {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "stopAtOther"); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "stopAtOther");
performLaunch(); doLaunch();
MIStoppedEvent stoppedEvent = getInitialStoppedEvent(); MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
assertTrue("Expected to stop at stopAtOther but got " + assertTrue("Expected to stop at stopAtOther but got " +
@ -608,7 +606,7 @@ public class LaunchConfigurationAndRestartTest extends BaseTestCase {
IFile fakeFile = null; IFile fakeFile = null;
CDIDebugModel.createLineBreakpoint(PROGRAM, fakeFile, ICBreakpointType.REGULAR, LAST_LINE_IN_MAIN + 1, true, 0, "", true); //$NON-NLS-1$ CDIDebugModel.createLineBreakpoint(PROGRAM, fakeFile, ICBreakpointType.REGULAR, LAST_LINE_IN_MAIN + 1, true, 0, "", true); //$NON-NLS-1$
performLaunch(); doLaunch();
MIStoppedEvent stoppedEvent = getInitialStoppedEvent(); MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
assertTrue("Expected to stop at envTest but got " + assertTrue("Expected to stop at envTest but got " +

View file

@ -55,10 +55,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -167,18 +163,17 @@ public class MIBreakpointsTest extends BaseTestCase {
// Housekeeping stuff // Housekeeping stuff
// ======================================================================== // ========================================================================
@BeforeClass @Override
public static void testSuiteInitialization() { protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Select the binary to run the tests against // Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, TEST_APPL); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, TEST_APPL);
} }
@AfterClass @Override
public static void testSuiteCleanup() { public void doBeforeTest() throws Exception {
} super.doBeforeTest();
@Before
public void testCaseInitialization() throws Exception {
// Get a reference to the breakpoint service // Get a reference to the breakpoint service
fSession = getGDBLaunch().getSession(); fSession = getGDBLaunch().getSession();
@ -210,8 +205,9 @@ public class MIBreakpointsTest extends BaseTestCase {
assert(fBreakpointsDmc != null); assert(fBreakpointsDmc != null);
} }
@After @Override
public void testCaseCleanup() throws Exception { public void doAfterTest() throws Exception {
super.doAfterTest();
// Clear the references (not strictly necessary) // Clear the references (not strictly necessary)
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {

View file

@ -61,10 +61,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -148,18 +144,9 @@ public class MICatchpointsTest extends BaseTestCase {
// Housekeeping stuff // Housekeeping stuff
// ======================================================================== // ========================================================================
@BeforeClass @Override
public static void testSuiteInitialization() { public void doBeforeTest() throws Exception {
// Select the binary to run the tests against super.doBeforeTest();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, TEST_APPL);
}
@AfterClass
public static void testSuiteCleanup() {
}
@Before
public void testCaseInitialization() throws Exception {
// Get a reference to the breakpoint service // Get a reference to the breakpoint service
fSession = getGDBLaunch().getSession(); fSession = getGDBLaunch().getSession();
@ -190,11 +177,20 @@ public class MICatchpointsTest extends BaseTestCase {
IContainerDMContext containerDmc = SyncUtil.getContainerContext(); IContainerDMContext containerDmc = SyncUtil.getContainerContext();
fBreakpointsDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class); fBreakpointsDmc = DMContexts.getAncestorOfType(containerDmc, IBreakpointsTargetDMContext.class);
assertNotNull(fBreakpointsDmc); assertNotNull(fBreakpointsDmc);
} }
@After @Override
public void testCaseCleanup() throws Exception { protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, TEST_APPL);
}
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public void run() { public void run() {

View file

@ -40,10 +40,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.cdt.utils.Addr64; import org.eclipse.cdt.utils.Addr64;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -78,18 +74,10 @@ public class MIDisassemblyTest extends BaseTestCase {
// Housekeeping stuff // Housekeeping stuff
// ======================================================================== // ========================================================================
@BeforeClass @Override
public static void testSuiteInitialization() { public void doBeforeTest() throws Exception {
// Select the binary to run the tests against super.doBeforeTest();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/MemoryTestApp.exe");
}
@AfterClass
public static void testSuiteCleanup() {
}
@Before
public void testCaseInitialization() throws Exception {
fSession = getGDBLaunch().getSession(); fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
@ -113,8 +101,18 @@ public class MIDisassemblyTest extends BaseTestCase {
} }
@After @Override
public void testCaseCleanup() { protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/MemoryTestApp.exe");
}
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
fExpressionService = null; fExpressionService = null;
fDisassembly = null; fDisassembly = null;
fServicesTracker.dispose(); fServicesTracker.dispose();

View file

@ -10,8 +10,8 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests; package org.eclipse.cdt.tests.dsf.gdb.tests;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -52,9 +52,6 @@ import org.eclipse.cdt.utils.Addr32;
import org.eclipse.cdt.utils.Addr64; import org.eclipse.cdt.utils.Addr64;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -75,15 +72,18 @@ public class MIExpressionsTest extends BaseTestCase {
private IExpressionDMContext globalExpressionCtx1 = null; private IExpressionDMContext globalExpressionCtx1 = null;
private IExpressionDMContext globalExpressionCtx2 = null; private IExpressionDMContext globalExpressionCtx2 = null;
@Override
protected void setLaunchAttributes() {
super.setLaunchAttributes();
@BeforeClass setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/ExpressionTestApp.exe");
public static void beforeClassMethod() {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/ExpressionTestApp.exe");
} }
@Before @Override
public void init() throws Exception { public void doBeforeTest() throws Exception {
fSession = getGDBLaunch().getSession(); super.doBeforeTest();
fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public void run() { public void run() {
@ -97,8 +97,10 @@ public class MIExpressionsTest extends BaseTestCase {
fSession.getExecutor().submit(runnable).get(); fSession.getExecutor().submit(runnable).get();
} }
@After @Override
public void shutdown() throws Exception { public void doAfterTest() throws Exception {
super.doAfterTest();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public void run() { public void run() {

View file

@ -40,10 +40,6 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.cdt.utils.Addr64; import org.eclipse.cdt.utils.Addr64;
import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.core.model.MemoryByte;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -81,18 +77,12 @@ public class MIMemoryTest extends BaseTestCase {
// Housekeeping stuff // Housekeeping stuff
// ======================================================================== // ========================================================================
@BeforeClass
public static void testSuiteInitialization() {
// Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/MemoryTestApp.exe");
}
@AfterClass
public static void testSuiteCleanup() {
}
@Before @Override
public void testCaseInitialization() throws Throwable { public void doBeforeTest() throws Exception {
super.doBeforeTest();
fSession = getGDBLaunch().getSession(); fSession = getGDBLaunch().getSession();
fMemoryDmc = (IMemoryDMContext)SyncUtil.getContainerContext(); fMemoryDmc = (IMemoryDMContext)SyncUtil.getContainerContext();
assert(fMemoryDmc != null); assert(fMemoryDmc != null);
@ -121,8 +111,18 @@ public class MIMemoryTest extends BaseTestCase {
fSession.getExecutor().submit(runnable).get(); fSession.getExecutor().submit(runnable).get();
} }
@After @Override
public void testCaseCleanup() throws Exception { protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Select the binary to run the tests against
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/MemoryTestApp.exe");
}
@Override
public void doAfterTest() throws Exception {
super.doAfterTest();
// Clear the references (not strictly necessary) // Clear the references (not strictly necessary)
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override

View file

@ -55,16 +55,12 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class) @RunWith(BackgroundRunner.class)
public class MIRegistersTest extends BaseTestCase { public class MIRegistersTest extends BaseTestCase {
protected List<String> get_X86_REGS() { protected List<String> get_X86_REGS() {
@ -90,16 +86,16 @@ public class MIRegistersTest extends BaseTestCase {
private static final String EXEC_NAME = "MultiThread.exe"; private static final String EXEC_NAME = "MultiThread.exe";
private static final String SRC_NAME = "MultiThread.cc"; private static final String SRC_NAME = "MultiThread.cc";
// Will be used to wait for asynchronous call to complete
//private final AsyncCompletionWaitor fWait = new AsyncCompletionWaitor();
private DsfSession fSession; private DsfSession fSession;
private DsfServicesTracker fServicesTracker; private DsfServicesTracker fServicesTracker;
private IContainerDMContext fContainerDmc; private IContainerDMContext fContainerDmc;
private IRegisters fRegService; private IRegisters fRegService;
private IRunControl fRunControl; private IRunControl fRunControl;
@Before @Override
public void init() throws Exception { public void doBeforeTest() throws Exception {
super.doBeforeTest();
fSession = getGDBLaunch().getSession(); fSession = getGDBLaunch().getSession();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@ -121,15 +117,19 @@ public class MIRegistersTest extends BaseTestCase {
fSession.getExecutor().submit(runnable).get(); fSession.getExecutor().submit(runnable).get();
} }
@BeforeClass @Override
public static void beforeClassMethod() { protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
EXEC_PATH + EXEC_NAME); EXEC_PATH + EXEC_NAME);
} }
@After @Override
public void tearDown() { public void doAfterTest() throws Exception {
super.doAfterTest();
fServicesTracker.dispose(); fServicesTracker.dispose();
fRegService = null; fRegService = null;
} }

View file

@ -37,10 +37,7 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor; import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -70,8 +67,10 @@ public class MIRunControlTargetAvailableTest extends BaseTestCase {
private static final String EXEC_NAME = "TargetAvail.exe"; private static final String EXEC_NAME = "TargetAvail.exe";
private static final String SOURCE_NAME = "TargetAvail.cc"; private static final String SOURCE_NAME = "TargetAvail.cc";
@Before @Override
public void init() throws Exception { public void doBeforeTest() throws Exception {
super.doBeforeTest();
final DsfSession session = getGDBLaunch().getSession(); final DsfSession session = getGDBLaunch().getSession();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@ -91,13 +90,17 @@ public class MIRunControlTargetAvailableTest extends BaseTestCase {
} }
@After @Override
public void tearDown() { public void doAfterTest() throws Exception {
super.doAfterTest();
fServicesTracker.dispose(); fServicesTracker.dispose();
} }
@BeforeClass @Override
public static void beforeClassMethod() { protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
EXEC_PATH + EXEC_NAME); EXEC_PATH + EXEC_NAME);
} }

View file

@ -52,10 +52,7 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -98,8 +95,10 @@ public class MIRunControlTest extends BaseTestCase {
private static final String EXEC_NAME = "MultiThread.exe"; private static final String EXEC_NAME = "MultiThread.exe";
private static final String SOURCE_NAME = "MultiThread.cc"; private static final String SOURCE_NAME = "MultiThread.cc";
@Before @Override
public void init() throws Exception { public void doBeforeTest() throws Exception {
super.doBeforeTest();
final DsfSession session = getGDBLaunch().getSession(); final DsfSession session = getGDBLaunch().getSession();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@ -123,13 +122,17 @@ public class MIRunControlTest extends BaseTestCase {
} }
@After @Override
public void tearDown() { public void doAfterTest() throws Exception {
super.doAfterTest();
fServicesTracker.dispose(); fServicesTracker.dispose();
} }
@BeforeClass @Override
public static void beforeClassMethod() { protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
EXEC_PATH + EXEC_NAME); EXEC_PATH + EXEC_NAME);

View file

@ -38,10 +38,7 @@ import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor;
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.core.runtime.preferences.DefaultScope;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.osgi.service.prefs.Preferences; import org.osgi.service.prefs.Preferences;
@ -70,8 +67,10 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
*/ */
private static final String EXEC_NAME = "TargetAvail.exe"; private static final String EXEC_NAME = "TargetAvail.exe";
@Before @Override
public void init() throws Exception { public void doBeforeTest() throws Exception {
super.doBeforeTest();
final DsfSession session = getGDBLaunch().getSession(); final DsfSession session = getGDBLaunch().getSession();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@ -92,13 +91,17 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
} }
@After @Override
public void tearDown() { public void doAfterTest() throws Exception {
super.doAfterTest();
fServicesTracker.dispose(); fServicesTracker.dispose();
} }
@BeforeClass @Override
public static void beforeClassMethod() { protected void setLaunchAttributes() {
super.setLaunchAttributes();
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME,
EXEC_PATH + EXEC_NAME); EXEC_PATH + EXEC_NAME);
} }
@ -110,7 +113,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
@Test @Test
public void restartWhileTargetRunningKillGDB() throws Throwable { public void restartWhileTargetRunningKillGDB() throws Throwable {
// Restart is not supported for a remote session // Restart is not supported for a remote session
if (BaseTestCase.isRemoteSession()) { if (isRemoteSession()) {
Assert.assertFalse("Restart operation should not be allowed for a remote session", Assert.assertFalse("Restart operation should not be allowed for a remote session",
SyncUtil.canRestart()); SyncUtil.canRestart());
return; return;
@ -140,7 +143,7 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
@Test @Test
public void restartWhileTargetRunningGDBAlive() throws Throwable { public void restartWhileTargetRunningGDBAlive() throws Throwable {
// Restart is not supported for a remote session // Restart is not supported for a remote session
if (BaseTestCase.isRemoteSession()) { if (isRemoteSession()) {
Assert.assertFalse("Restart operation should not be allowed for a remote session", Assert.assertFalse("Restart operation should not be allowed for a remote session",
SyncUtil.canRestart()); SyncUtil.canRestart());
return; return;

View file

@ -51,9 +51,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.core.model.MemoryByte;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -70,22 +67,16 @@ public class PostMortemCoreTest extends BaseTestCase {
private IMemoryDMContext fMemoryDmc; private IMemoryDMContext fMemoryDmc;
@BeforeClass
public static void beforeClassMethod() {
}
@Override @Override
@Before public void doBeforeTest() throws Exception {
public void baseBeforeMethod() throws Exception { setLaunchAttributes();
// The class BaseTestCase sets up the launch in its @BeforeClass method. // Can't run the launch right away because each test needs to first set some
// Usually this is ok, because every test uses the same launch configuration. // parameters. The individual tests will be responsible for starting the launch.
// However, for some of the tests of this class, we are changing the launch }
// configuration. Therefore, we need to reset it to the default
// before every test; that means in the @Before method instead of @BeforeClass
// Reset the launch configuration @Override
super.baseBeforeClassMethod(); protected void setLaunchAttributes() {
super.setLaunchAttributes();
// Set a working directory for GDB that is different than eclipse's directory. // Set a working directory for GDB that is different than eclipse's directory.
// This allows us to make sure we properly handle finding the core file, // This allows us to make sure we properly handle finding the core file,
@ -103,18 +94,15 @@ public class PostMortemCoreTest extends BaseTestCase {
IGDBLaunchConfigurationConstants.DEBUGGER_POST_MORTEM_CORE_FILE); IGDBLaunchConfigurationConstants.DEBUGGER_POST_MORTEM_CORE_FILE);
// Set default core file path // Set default core file path
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, "data/launch/bin/core"); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, "data/launch/bin/core");
// Can't run the launch right away because each test needs to first set some
// parameters. The individual tests will be responsible for starting the launch.
} }
// This method cannot be tagged as @Before, because the launch is not // This method cannot be tagged as @Before, because the launch is not
// running yet. We have to call this manually after all the proper // running yet. We have to call this manually after all the proper
// parameters have been set for the launch // parameters have been set for the launch
public void performLaunch() throws Exception { @Override
protected void doLaunch() throws Exception {
// perform the launch // perform the launch
super.baseBeforeMethod(); super.doLaunch();
fSession = getGDBLaunch().getSession(); fSession = getGDBLaunch().getSession();
@ -132,8 +120,10 @@ public class PostMortemCoreTest extends BaseTestCase {
fSession.getExecutor().submit(runnable).get(); fSession.getExecutor().submit(runnable).get();
} }
@After @Override
public void shutdown() throws Exception { public void doAfterTest() throws Exception {
super.doAfterTest();
if (fSession != null) { if (fSession != null) {
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
@ -161,7 +151,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, absoluteCoreFile); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, absoluteCoreFile);
performLaunch(); doLaunch();
// If the launch passed, we are ok, nothing more to check // If the launch passed, we are ok, nothing more to check
} }
@ -178,7 +168,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, relativeCoreFile); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, relativeCoreFile);
performLaunch(); doLaunch();
// If the launch passed, we are ok, nothing more to check // If the launch passed, we are ok, nothing more to check
} }
@ -196,7 +186,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, absoluteCoreFile); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, absoluteCoreFile);
try { try {
performLaunch(); doLaunch();
} catch (DebugException e) { } catch (DebugException e) {
// Success of the test // Success of the test
return; return;
@ -218,7 +208,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, relativeCoreFile); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, relativeCoreFile);
try { try {
performLaunch(); doLaunch();
} catch (CoreException e) { } catch (CoreException e) {
// Success of the test // Success of the test
return; return;
@ -240,7 +230,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, absoluteCoreFile); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, absoluteCoreFile);
try { try {
performLaunch(); doLaunch();
} catch (CoreException e) { } catch (CoreException e) {
// Success of the test // Success of the test
return; return;
@ -262,7 +252,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, relativeCoreFile); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, relativeCoreFile);
try { try {
performLaunch(); doLaunch();
} catch (CoreException e) { } catch (CoreException e) {
// Success of the test // Success of the test
return; return;
@ -319,7 +309,7 @@ public class PostMortemCoreTest extends BaseTestCase {
setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, coreFile); setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, coreFile);
performLaunch(); doLaunch();
} }
/** /**
@ -327,7 +317,7 @@ public class PostMortemCoreTest extends BaseTestCase {
*/ */
@Test @Test
public void testLiteralIntegerExpressions() throws Throwable { public void testLiteralIntegerExpressions() throws Throwable {
performLaunch(); doLaunch();
// Create a map of expressions and their expected values. // Create a map of expressions and their expected values.
Map<String, String[]> tests = new HashMap<String, String[]>(); Map<String, String[]> tests = new HashMap<String, String[]>();
@ -350,7 +340,7 @@ public class PostMortemCoreTest extends BaseTestCase {
*/ */
@Test @Test
public void testLiteralFloatingPointExpressions() throws Throwable { public void testLiteralFloatingPointExpressions() throws Throwable {
performLaunch(); doLaunch();
// Create a map of expressions and their expected values. // Create a map of expressions and their expected values.
Map<String, String[]> tests = new HashMap<String, String[]>(); Map<String, String[]> tests = new HashMap<String, String[]>();
@ -374,7 +364,7 @@ public class PostMortemCoreTest extends BaseTestCase {
*/ */
@Test @Test
public void testLocalVariables() throws Throwable { public void testLocalVariables() throws Throwable {
performLaunch(); doLaunch();
// Create a map of expressions to expected values. // Create a map of expressions to expected values.
Map<String, String[]> tests1 = new HashMap<String, String[]>(); Map<String, String[]> tests1 = new HashMap<String, String[]>();
@ -406,7 +396,7 @@ public class PostMortemCoreTest extends BaseTestCase {
@Test @Test
public void readMemoryArray() throws Throwable { public void readMemoryArray() throws Throwable {
performLaunch(); doLaunch();
IAddress address = evaluateExpression(SyncUtil.getStackFrame(SyncUtil.getExecutionContext(0), 0), "&lBoolPtr2"); IAddress address = evaluateExpression(SyncUtil.getStackFrame(SyncUtil.getExecutionContext(0), 0), "&lBoolPtr2");

View file

@ -14,13 +14,12 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest; import org.eclipse.cdt.tests.dsf.gdb.tests.CommandTimeoutTest;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class) @RunWith(BackgroundRunner.class)
public class CommandTimeoutTest_6_6 extends CommandTimeoutTest { public class CommandTimeoutTest_6_6 extends CommandTimeoutTest {
@BeforeClass @Override
public static void beforeClassMethod_6_6() { protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6); setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
} }
} }

View file

@ -13,13 +13,12 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.GDBProcessesTest; import org.eclipse.cdt.tests.dsf.gdb.tests.GDBProcessesTest;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.junit.BeforeClass;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class) @RunWith(BackgroundRunner.class)
public class GDBProcessesTest_6_6 extends GDBProcessesTest { public class GDBProcessesTest_6_6 extends GDBProcessesTest {
@BeforeClass @Override
public static void beforeClassMethod_6_6() { protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6); setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
} }
} }

View file

@ -13,17 +13,12 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.LaunchConfigurationAndRestartTest; import org.eclipse.cdt.tests.dsf.gdb.tests.LaunchConfigurationAndRestartTest;
import org.junit.Before;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class) @RunWith(BackgroundRunner.class)
public class LaunchConfigurationAndRestartTest_6_6 extends LaunchConfigurationAndRestartTest { public class LaunchConfigurationAndRestartTest_6_6 extends LaunchConfigurationAndRestartTest {
@Override
// For the launch config test, we must set the attributes in the @Before method protected void setGdbVersion() {
// instead of the @BeforeClass method. This is because the attributes are overwritten
// by the tests themselves
@Before
public void beforeMethod_6_6() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6); setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
} }
} }

View file

@ -13,13 +13,12 @@ package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner; import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
import org.eclipse.cdt.tests.dsf.gdb.tests.MIBreakpointsTest; import org.eclipse.cdt.tests.dsf.gdb.tests.MIBreakpointsTest;
import org.junit.BeforeClass;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@RunWith(BackgroundRunner.class) @RunWith(BackgroundRunner.class)
public class MIBreakpointsTest_6_6 extends MIBreakpointsTest { public class MIBreakpointsTest_6_6 extends MIBreakpointsTest {
@BeforeClass @Override
public static void beforeClassMethod_6_6() { protected void setGdbVersion() {
setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6); setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
} }
} }

Some files were not shown because too many files have changed in this diff Show more