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

Merge remote branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2011-10-04 00:13:14 -04:00
commit 3e55f72c10
23 changed files with 347 additions and 471 deletions

View file

@ -9526,4 +9526,16 @@ public class AST2CPPTests extends AST2BaseTest {
ICPPClassType c= bh.assertNonProblem("A", 1); ICPPClassType c= bh.assertNonProblem("A", 1);
assertEquals(0, ClassTypeHelper.getPureVirtualMethods(c).length); assertEquals(0, ClassTypeHelper.getPureVirtualMethods(c).length);
} }
// template <typename T> struct CT1 {};
// template <typename T> struct CT2 {};
// typedef char Tdef;
// template<> struct CT1< CT2<int> > {
// CT1<Tdef> x; // Ambiguity causes lookup in CT1< CT2<int> >
// };
// template<> struct CT2<Tdef> { // Accessed before ambiguity is resolved
// };
public void testAmbiguityResolution_Bug359364() throws Exception {
parseAndCheckBindings();
}
} }

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.internal.index.tests; package org.eclipse.cdt.internal.index.tests;
@ -48,8 +48,8 @@ public class IndexIncludeTest extends IndexTestBase {
return suite; return suite;
} }
private ICProject fProject= null; private ICProject fProject;
private IIndex fIndex= null; private IIndex fIndex;
public IndexIncludeTest(String name) { public IndexIncludeTest(String name) {
super(name); super(name);
@ -61,8 +61,8 @@ public class IndexIncludeTest extends IndexTestBase {
if (fProject == null) { if (fProject == null) {
fProject= createProject(true, "resources/indexTests/includes"); fProject= createProject(true, "resources/indexTests/includes");
IPathEntry[] entries= new IPathEntry[] { IPathEntry[] entries= new IPathEntry[] {
CoreModel.newIncludeEntry(fProject.getPath(), CoreModel.newIncludeEntry(fProject.getPath(), null,
null, fProject.getResource().getLocation())}; fProject.getResource().getLocation()) };
fProject.setRawPathEntries(entries, npm()); fProject.setRawPathEntries(entries, npm());
} }
fIndex= CCorePlugin.getIndexManager().getIndex(fProject); fIndex= CCorePlugin.getIndexManager().getIndex(fProject);
@ -141,7 +141,7 @@ public class IndexIncludeTest extends IndexTestBase {
// #include <system20061107.h> // #include <system20061107.h>
public void testIncludeProperties() throws Exception { public void testIncludeProperties() throws Exception {
waitForIndexer(); waitForIndexer();
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()}; TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
String content= readTaggedComment("source20061107"); String content= readTaggedComment("source20061107");
TestSourceReader.createFile(fProject.getProject(), "user20061107.h", ""); TestSourceReader.createFile(fProject.getProject(), "user20061107.h", "");
TestSourceReader.createFile(fProject.getProject(), "system20061107.h", ""); TestSourceReader.createFile(fProject.getProject(), "system20061107.h", "");
@ -163,7 +163,7 @@ public class IndexIncludeTest extends IndexTestBase {
} }
public void testIncludeProperties_2() throws Exception { public void testIncludeProperties_2() throws Exception {
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()}; TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
TestSourceReader.createFile(fProject.getProject(), "header20061107.h", ""); TestSourceReader.createFile(fProject.getProject(), "header20061107.h", "");
String content = "// comment \n#include \"header20061107.h\"\n"; String content = "// comment \n#include \"header20061107.h\"\n";
IFile file= TestSourceReader.createFile(fProject.getProject(), "intermed20061107.h", content); IFile file= TestSourceReader.createFile(fProject.getProject(), "intermed20061107.h", content);
@ -186,7 +186,7 @@ public class IndexIncludeTest extends IndexTestBase {
} }
public void testInactiveInclude() throws Exception { public void testInactiveInclude() throws Exception {
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()}; TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
String content = "#if 0\n#include \"inactive20070213.h\"\n#endif\n"; String content = "#if 0\n#include \"inactive20070213.h\"\n#endif\n";
IFile file= TestSourceReader.createFile(fProject.getProject(), "source20070213.cpp", content); IFile file= TestSourceReader.createFile(fProject.getProject(), "source20070213.cpp", content);
CCorePlugin.getIndexManager().reindex(fProject); CCorePlugin.getIndexManager().reindex(fProject);
@ -207,7 +207,7 @@ public class IndexIncludeTest extends IndexTestBase {
} }
public void testUnresolvedInclude() throws Exception { public void testUnresolvedInclude() throws Exception {
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()}; TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
String content = "#include \"unresolved20070213.h\"\n"; String content = "#include \"unresolved20070213.h\"\n";
IFile file= TestSourceReader.createFile(fProject.getProject(), "source20070214.cpp", content); IFile file= TestSourceReader.createFile(fProject.getProject(), "source20070214.cpp", content);
CCorePlugin.getIndexManager().reindex(fProject); CCorePlugin.getIndexManager().reindex(fProject);
@ -318,7 +318,7 @@ public class IndexIncludeTest extends IndexTestBase {
// #include "resolved20070426.h" // #include "resolved20070426.h"
public void testFixedContext() throws Exception { public void testFixedContext() throws Exception {
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()}; TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
String source= getContentsForTest(1)[0].toString(); String source= getContentsForTest(1)[0].toString();
IFile header= TestSourceReader.createFile(fProject.getProject(), "resolved20070426.h", ""); IFile header= TestSourceReader.createFile(fProject.getProject(), "resolved20070426.h", "");
IFile s1= TestSourceReader.createFile(fProject.getProject(), "s1.cpp", source); IFile s1= TestSourceReader.createFile(fProject.getProject(), "s1.cpp", source);
@ -404,7 +404,7 @@ public class IndexIncludeTest extends IndexTestBase {
// #include "unesolved20070427.h" // #include "unesolved20070427.h"
public void testUpdateIncludes() throws Exception { public void testUpdateIncludes() throws Exception {
waitForIndexer(); waitForIndexer();
TestScannerProvider.sIncludes= new String[]{fProject.getProject().getLocation().toOSString()}; TestScannerProvider.sIncludes= new String[] { fProject.getProject().getLocation().toOSString() };
CharSequence[] source= getContentsForTest(4); CharSequence[] source= getContentsForTest(4);
IFile header= TestSourceReader.createFile(fProject.getProject(), "resolved20070427.h", ""); IFile header= TestSourceReader.createFile(fProject.getProject(), "resolved20070427.h", "");
IFile s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp", IFile s1= TestSourceReader.createFile(fProject.getProject(), "s20070427.cpp",
@ -446,7 +446,6 @@ public class IndexIncludeTest extends IndexTestBase {
source[0].toString() + "\nint h20070427;"); source[0].toString() + "\nint h20070427;");
TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_WAIT_TIME); TestSourceReader.waitUntilFileIsIndexed(fIndex, s1, INDEXER_WAIT_TIME);
standardCheckUpdateIncludes(header, s1, "h20070427"); standardCheckUpdateIncludes(header, s1, "h20070427");
} }
private void standardCheckUpdateIncludes(IFile header, IFile s1, String tag) throws Exception { private void standardCheckUpdateIncludes(IFile header, IFile s1, String tag) throws Exception {

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.internal.index.tests; package org.eclipse.cdt.internal.index.tests;
import java.io.IOException; import java.io.IOException;
@ -129,8 +128,7 @@ public class IndexNamesTests extends BaseTestCase {
enclosing= enclosed[1].getEnclosingDefinition(); enclosing= enclosed[1].getEnclosingDefinition();
assertNotNull(enclosing); assertNotNull(enclosing);
assertName("main", enclosing); assertName("main", enclosing);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -223,8 +221,7 @@ public class IndexNamesTests extends BaseTestCase {
enclosing= enclosed[2].getEnclosingDefinition(); enclosing= enclosed[2].getEnclosingDefinition();
assertNotNull(enclosing); assertNotNull(enclosing);
assertName("func", enclosing); assertName("func", enclosing);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
@ -274,8 +271,7 @@ public class IndexNamesTests extends BaseTestCase {
assertEquals(couldbepolymorphic[j], indexName.couldBePolymorphicMethodCall()); assertEquals(couldbepolymorphic[j], indexName.couldBePolymorphicMethodCall());
assertEquals(container[j], CPPVisitor.getQualifiedName(fIndex.findBinding(indexName))[0]); assertEquals(container[j], CPPVisitor.getQualifiedName(fIndex.findBinding(indexName))[0]);
j++; j++;
} } else {
else {
assertEquals(false, indexName.couldBePolymorphicMethodCall()); assertEquals(false, indexName.couldBePolymorphicMethodCall());
} }
} }
@ -285,7 +281,6 @@ public class IndexNamesTests extends BaseTestCase {
} }
} }
// int _i, ri, wi, rwi; // int _i, ri, wi, rwi;
// int* rp; int* wp; int* rwp; // int* rp; int* wp; int* rwp;
// const int* cip= &ri; // const int* cip= &ri;
@ -339,14 +334,12 @@ public class IndexNamesTests extends BaseTestCase {
assertEquals("Read access for " + msg, isRead, indexName.isReadAccess()); assertEquals("Read access for " + msg, isRead, indexName.isReadAccess());
assertEquals("Write access for " + msg, isWrite, indexName.isWriteAccess()); assertEquals("Write access for " + msg, isWrite, indexName.isWriteAccess());
j++; j++;
} } else {
else {
assertEquals(false, indexName.couldBePolymorphicMethodCall()); assertEquals(false, indexName.couldBePolymorphicMethodCall());
} }
} }
assertEquals(count, j); assertEquals(count, j);
} } finally {
finally {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }

View file

@ -1432,5 +1432,36 @@ public class IndexUpdateTests extends IndexTestBase {
fIndex.releaseReadLock(); fIndex.releaseReadLock();
} }
} }
// struct S {};
// struct S {S(int){}};
public void testImplicitDefaultCtor_Bug359376() throws Exception {
setupFile(2, true);
fIndex.acquireReadLock();
try {
final ICPPClassType s = (ICPPClassType) findBinding("S");
assertNotNull(s);
final ICPPConstructor[] ctors = s.getConstructors();
assertEquals(2, ctors.length); // 2 implicit ctors
assertTrue(ctors[0].isImplicit());
assertTrue(ctors[1].isImplicit());
} finally {
fIndex.releaseReadLock();
}
updateFile();
fIndex.acquireReadLock();
try {
final ICPPClassType s = (ICPPClassType) findBinding("S");
assertNotNull(s);
final ICPPConstructor[] ctors = s.getConstructors();
assertEquals(2, ctors.length); // 1 explicit and one implicit ctor
assertTrue(ctors[0].isImplicit() != ctors[1].isImplicit());
} finally {
fIndex.releaseReadLock();
}
}
} }

View file

@ -6,10 +6,9 @@
* 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
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.testplugin.util; package org.eclipse.cdt.core.testplugin.util;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -69,21 +68,22 @@ public class TestSourceReader {
* test in the source code. * test in the source code.
* @throws IOException * @throws IOException
*/ */
public static StringBuilder[] getContentsForTest(Bundle bundle, String srcRoot, Class clazz, final String testName, int sections) throws IOException { public static StringBuilder[] getContentsForTest(Bundle bundle, String srcRoot, Class clazz,
final String testName, int sections) throws IOException {
String fqn = clazz.getName().replace('.', '/'); String fqn = clazz.getName().replace('.', '/');
fqn = fqn.indexOf("$")==-1 ? fqn : fqn.substring(0,fqn.indexOf("$")); fqn = fqn.indexOf("$") == -1 ? fqn : fqn.substring(0, fqn.indexOf("$"));
String classFile = fqn + ".java"; String classFile = fqn + ".java";
IPath filePath= new Path(srcRoot + '/' + classFile); IPath filePath= new Path(srcRoot + '/' + classFile);
InputStream in; InputStream in;
try { try {
if (bundle != null) if (bundle != null) {
in = FileLocator.openStream(bundle, filePath, false); in = FileLocator.openStream(bundle, filePath, false);
else { } else {
in = clazz.getResourceAsStream('/'+classFile); in = clazz.getResourceAsStream('/' + classFile);
} }
} catch(IOException e) { } catch (IOException e) {
if(clazz.getSuperclass()!=null && !clazz.equals(TestCase.class)) { if (clazz.getSuperclass() != null && !clazz.equals(TestCase.class)) {
return getContentsForTest(bundle, srcRoot, clazz.getSuperclass(), testName, sections); return getContentsForTest(bundle, srcRoot, clazz.getSuperclass(), testName, sections);
} }
throw e; throw e;
@ -91,30 +91,30 @@ public class TestSourceReader {
BufferedReader br = new BufferedReader(new InputStreamReader(in)); BufferedReader br = new BufferedReader(new InputStreamReader(in));
List contents = new ArrayList(); List<StringBuilder> contents = new ArrayList<StringBuilder>();
StringBuilder content = new StringBuilder(); StringBuilder content = new StringBuilder();
for(String line = br.readLine(); line!=null; line = br.readLine()) { for (String line = br.readLine(); line != null; line = br.readLine()) {
line = line.replaceFirst("^\\s*", ""); // replace leading whitespace, preserve trailing line = line.replaceFirst("^\\s*", ""); // replace leading whitespace, preserve trailing
if(line.startsWith("//")) { if (line.startsWith("//")) {
content.append(line.substring(2)+"\n"); content.append(line.substring(2) + "\n");
} else { } else {
if(content.length()>0) { if (content.length() > 0) {
contents.add(content); contents.add(content);
if(contents.size()==sections+1) if (contents.size() == sections + 1)
contents.remove(0); contents.remove(0);
content = new StringBuilder(); content = new StringBuilder();
} }
int idx= line.indexOf(testName); int idx= line.indexOf(testName);
if( idx != -1 && !Character.isJavaIdentifierPart(line.charAt(idx+testName.length()))) { if (idx != -1 && !Character.isJavaIdentifierPart(line.charAt(idx + testName.length()))) {
return (StringBuilder[]) contents.toArray(new StringBuilder[contents.size()]); return contents.toArray(new StringBuilder[contents.size()]);
} }
} }
} }
if(clazz.getSuperclass()!=null && !clazz.equals(TestCase.class)) { if (clazz.getSuperclass() != null && !clazz.equals(TestCase.class)) {
return getContentsForTest(bundle, srcRoot, clazz.getSuperclass(), testName, sections); return getContentsForTest(bundle, srcRoot, clazz.getSuperclass(), testName, sections);
} }
throw new IOException("Test data not found for "+clazz+" "+testName); throw new IOException("Test data not found for " + clazz + " " + testName);
} }
/** /**
@ -139,15 +139,15 @@ public class TestSourceReader {
if (c == '\n') { if (c == '\n') {
int idx= buf.indexOf(lookfor); int idx= buf.indexOf(lookfor);
if (idx >= 0) { if (idx >= 0) {
return idx+offset; return idx + offset;
} }
offset+=buf.length(); offset += buf.length();
buf.setLength(0); buf.setLength(0);
} }
} }
int idx= buf.indexOf(lookfor); int idx= buf.indexOf(lookfor);
if (idx >= 0) { if (idx >= 0) {
return idx+offset; return idx + offset;
} }
return -1; return -1;
} finally { } finally {
@ -196,8 +196,8 @@ public class TestSourceReader {
} else { } else {
line= line.trim(); line= line.trim();
if (line.startsWith("{" + tag)) { if (line.startsWith("{" + tag)) {
if (line.length() == tag.length()+1 || if (line.length() == tag.length() + 1 ||
!Character.isJavaIdentifierPart(line.charAt(tag.length()+1))) { !Character.isJavaIdentifierPart(line.charAt(tag.length() + 1))) {
found= true; found= true;
} }
} }
@ -207,8 +207,7 @@ public class TestSourceReader {
} }
line= reader.readLine(); line= reader.readLine();
} }
} } finally {
finally {
reader.close(); reader.close();
} }
Assert.assertTrue("Tag '" + tag + "' is not defined inside of '" + filePath + "'.", found); Assert.assertTrue("Tag '" + tag + "' is not defined inside of '" + filePath + "'.", found);
@ -239,7 +238,7 @@ public class TestSourceReader {
long timestamp= file.getLocalTimeStamp(); long timestamp= file.getLocalTimeStamp();
file.setContents(stream, false, false, new NullProgressMonitor()); file.setContents(stream, false, false, new NullProgressMonitor());
if (file.getLocalTimeStamp() == timestamp) { if (file.getLocalTimeStamp() == timestamp) {
file.setLocalTimeStamp(timestamp+1000); file.setLocalTimeStamp(timestamp + 1000);
} }
} else { } else {
createFolders(file); createFolders(file);

View file

@ -71,8 +71,8 @@ final class DeltaProcessor {
CModelInfo rootInfo = (CModelInfo)manager.peekAtInfo(root); CModelInfo rootInfo = (CModelInfo)manager.peekAtInfo(root);
if (rootInfo != null) { if (rootInfo != null) {
ICElement[] celements = rootInfo.getChildren(); ICElement[] celements = rootInfo.getChildren();
for (int i = 0; i < celements.length; i++) { for (ICElement celement : celements) {
IResource r = celements[i].getResource(); IResource r = celement.getResource();
if (project.equals(r)) { if (project.equals(r)) {
shouldProcess = true; shouldProcess = true;
} }
@ -97,10 +97,10 @@ final class DeltaProcessor {
IBinaryContainer bin = cproj.getBinaryContainer(); IBinaryContainer bin = cproj.getBinaryContainer();
if (bin.isOpen()) { if (bin.isOpen()) {
children = ((CElement)bin).getElementInfo().getChildren(); children = ((CElement)bin).getElementInfo().getChildren();
for (int i = 0; i < children.length; i++) { for (ICElement element : children) {
IResource res = children[i].getResource(); IResource res = element.getResource();
if (resource.equals(res)) { if (resource.equals(res)) {
celement = children[i]; celement = element;
break; break;
} }
} }
@ -116,10 +116,10 @@ final class DeltaProcessor {
IArchiveContainer ar = cproj.getArchiveContainer(); IArchiveContainer ar = cproj.getArchiveContainer();
if (ar.isOpen()) { if (ar.isOpen()) {
children = ((CElement)ar).getElementInfo().getChildren(); children = ((CElement)ar).getElementInfo().getChildren();
for (int i = 0; i < children.length; i++) { for (ICElement element : children) {
IResource res = children[i].getResource(); IResource res = element.getResource();
if (resource.equals(res)) { if (resource.equals(res)) {
celement = children[i]; celement = element;
break; break;
} }
} }
@ -192,8 +192,8 @@ final class DeltaProcessor {
if (pinfo != null && pinfo.vBin != null) { if (pinfo != null && pinfo.vBin != null) {
if (factory.peekAtInfo(pinfo.vBin) != null) { if (factory.peekAtInfo(pinfo.vBin) != null) {
ICElement[] bins = pinfo.vBin.getChildren(); ICElement[] bins = pinfo.vBin.getChildren();
for (int i = 0; i < bins.length; i++) { for (ICElement bin : bins) {
if (celement.getPath().isPrefixOf(bins[i].getPath())) { if (celement.getPath().isPrefixOf(bin.getPath())) {
fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED); fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED);
} }
} }
@ -202,8 +202,8 @@ final class DeltaProcessor {
if (pinfo != null && pinfo.vLib != null) { if (pinfo != null && pinfo.vLib != null) {
if (factory.peekAtInfo(pinfo.vLib) != null) { if (factory.peekAtInfo(pinfo.vLib) != null) {
ICElement[] ars = pinfo.vLib.getChildren(); ICElement[] ars = pinfo.vLib.getChildren();
for (int i = 0; i < ars.length; i++) { for (ICElement ar : ars) {
if (celement.getPath().isPrefixOf(ars[i].getPath())) { if (celement.getPath().isPrefixOf(ar.getPath())) {
fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED); fCurrentDelta.changed(pinfo.vBin, ICElementDelta.CHANGED);
} }
} }
@ -468,8 +468,8 @@ final class DeltaProcessor {
} }
if (updateChildren){ if (updateChildren){
IResourceDelta [] children = delta.getAffectedChildren(); IResourceDelta [] children = delta.getAffectedChildren();
for (int i = 0; i < children.length; i++) { for (IResourceDelta element : children) {
traverseDelta(parent, children[i]); traverseDelta(parent, element);
} }
} }
} }
@ -506,10 +506,10 @@ final class DeltaProcessor {
} }
// deal with project == sourceroot. For that case the parent could have been the sourceroot // deal with project == sourceroot. For that case the parent could have been the sourceroot
// so we must update the sourceroot nonCResource array also. // so we must update the sourceroot nonCResource array also.
for (int i = 0; i < roots.length; i++) { for (ISourceRoot root : roots) {
IResource r = roots[i].getResource(); IResource r = root.getResource();
if (r instanceof IProject) { if (r instanceof IProject) {
CElementInfo cinfo = (CElementInfo) CModelManager.getDefault().peekAtInfo(roots[i]); CElementInfo cinfo = (CElementInfo) CModelManager.getDefault().peekAtInfo(root);
if (cinfo instanceof CContainerInfo) { if (cinfo instanceof CContainerInfo) {
((CContainerInfo)cinfo).setNonCResources(null); ((CContainerInfo)cinfo).setNonCResources(null);
} }
@ -546,8 +546,8 @@ final class DeltaProcessor {
if (delta.getKind() == IResourceDelta.ADDED) if (delta.getKind() == IResourceDelta.ADDED)
return true; return true;
IResourceDelta[] children= delta.getAffectedChildren(); IResourceDelta[] children= delta.getAffectedChildren();
for (int i = 0; i < children.length; i++) { for (IResourceDelta element : children) {
if (isFolderAddition(children[i])) { if (isFolderAddition(element)) {
return true; return true;
} }
} }
@ -571,14 +571,18 @@ final class DeltaProcessor {
if (element instanceof ICContainer) { if (element instanceof ICContainer) {
ICContainer container = (ICContainer) element; ICContainer container = (ICContainer) element;
ICProject cProject = container.getCProject(); ICProject cProject = container.getCProject();
// Always check whether the container is open.
if (container.isOpen())
return true;
// Check binary container, if the new folder is on an output entry,
// there may be new binaries to add
if (cProject.isOnOutputEntry(resource)) { if (cProject.isOnOutputEntry(resource)) {
// if new folder is on output entry there might be new binaries to add
IBinaryContainer bin = cProject.getBinaryContainer(); IBinaryContainer bin = cProject.getBinaryContainer();
IArchiveContainer archive = cProject.getArchiveContainer(); IArchiveContainer archive = cProject.getArchiveContainer();
// traverse further if a binary container is open
return bin.isOpen() || archive.isOpen(); return bin.isOpen() || archive.isOpen();
} }
return container.isOpen(); return false;
} else if (element instanceof ICProject) { } else if (element instanceof ICProject) {
return ((ICProject) element).isOpen(); return ((ICProject) element).isOpen();
} else if (element instanceof IBinary) { } else if (element instanceof IBinary) {

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
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;
@ -29,7 +30,10 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode; import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
@ -101,6 +105,14 @@ final class CPPASTAmbiguityResolver extends ASTVisitor {
public int leave(IASTDeclSpecifier declSpec) { public int leave(IASTDeclSpecifier declSpec) {
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) { if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
fDeferFunctions--; fDeferFunctions--;
// Resolve class type definitions, such that the scope is available
// during ambiguity resolution.
((ICPPASTCompositeTypeSpecifier) declSpec).getName().resolveBinding();
// Trigger computation of implicit members.
if (declSpec instanceof CPPASTCompositeTypeSpecifier)
((CPPASTCompositeTypeSpecifier) declSpec).setAmbiguitiesResolved();
} }
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }
@ -128,17 +140,30 @@ final class CPPASTAmbiguityResolver extends ASTVisitor {
if (fRepopulate.remove(declaration)) { if (fRepopulate.remove(declaration)) {
repopulateScope(declaration); repopulateScope(declaration);
} }
// Explicit and partial class template specializations need to be resolved right away, // We need to create class bindings for all definitions and for the specializations.
// otherwise we fail to correctly resolve qualified names that depend on a partial specialization. // Otherwise, name resolution cannot access members or correct specialization.
if (declaration instanceof IASTSimpleDeclaration) { if (declaration instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration sdecl= (IASTSimpleDeclaration) declaration; IASTSimpleDeclaration sdecl= (IASTSimpleDeclaration) declaration;
IASTName name= null;
IASTDeclSpecifier declspec = sdecl.getDeclSpecifier(); IASTDeclSpecifier declspec = sdecl.getDeclSpecifier();
if (declspec instanceof IASTCompositeTypeSpecifier && sdecl.getDeclarators().length == 0) { if (declspec instanceof IASTCompositeTypeSpecifier) {
IASTName name= ((IASTCompositeTypeSpecifier) declspec).getName().getLastName(); // Definition of a class[template[specialization]]
if (name instanceof ICPPASTTemplateId) { name= ((IASTCompositeTypeSpecifier) declspec).getName().getLastName();
name.resolveBinding(); } else if (declspec instanceof ICPPASTElaboratedTypeSpecifier
&& sdecl.getDeclarators().length == 0) {
ASTNodeProperty prop = declaration.getPropertyInParent();
if (prop == ICPPASTTemplateDeclaration.OWNED_DECLARATION
|| prop == ICPPASTTemplateSpecialization.OWNED_DECLARATION) {
ICPPASTElaboratedTypeSpecifier elab= (ICPPASTElaboratedTypeSpecifier) declspec;
if (!elab.isFriend()) {
// Declaration of a class template specialization.
name= elab.getName().getLastName();
}
} }
} }
if (name instanceof ICPPASTTemplateId) {
name.resolveBinding();
}
} }
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
} }

View file

@ -30,12 +30,13 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
private int fKey; private int fKey;
private IASTName fName; private IASTName fName;
private ICPPClassScope fScope; private CPPClassScope fScope;
private IASTDeclaration[] fAllDeclarations; private IASTDeclaration[] fAllDeclarations;
private IASTDeclaration[] fActiveDeclarations; private IASTDeclaration[] fActiveDeclarations;
private int fDeclarationsPos=-1; private int fDeclarationsPos=-1;
private ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[] baseSpecs = null; private ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[] baseSpecs = null;
private int baseSpecsPos = -1; private int baseSpecsPos = -1;
private boolean fAmbiguitiesResolved= false;
public CPPASTCompositeTypeSpecifier() { public CPPASTCompositeTypeSpecifier() {
@ -46,6 +47,13 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
setName(n); setName(n);
} }
public void setAmbiguitiesResolved() {
if (!fAmbiguitiesResolved && fScope != null) {
fScope.createImplicitMembers();
}
fAmbiguitiesResolved= true;
}
public CPPASTCompositeTypeSpecifier copy() { public CPPASTCompositeTypeSpecifier copy() {
return copy(CopyStyle.withoutLocations); return copy(CopyStyle.withoutLocations);
} }
@ -140,15 +148,15 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
} }
public ICPPClassScope getScope() { public ICPPClassScope getScope() {
if (fScope == null) if (fScope == null) {
fScope = new CPPClassScope(this); fScope = new CPPClassScope(this);
if (fAmbiguitiesResolved) {
fScope.createImplicitMembers();
}
}
return fScope; return fScope;
} }
public void setScope(ICPPClassScope scope) {
this.fScope = scope;
}
@Override @Override
public boolean accept(ASTVisitor action) { public boolean accept(ASTVisitor action) {
if (action.shouldVisitDeclSpecifiers) { if (action.shouldVisitDeclSpecifiers) {

View file

@ -15,8 +15,10 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.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.IASTNodeLocation;
import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
@ -128,7 +130,11 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
if (needComma) if (needComma)
buf.append(", "); //$NON-NLS-1$ buf.append(", "); //$NON-NLS-1$
needComma= true; needComma= true;
if (arg instanceof IASTExpression) { IASTNodeLocation[] nodeLocs = arg.getNodeLocations();
if (nodeLocs.length == 1 && nodeLocs[0] instanceof IASTFileLocation) {
buf.append(arg.getRawSignature());
cleanupWhitespace= true;
} else if (arg instanceof IASTExpression) {
IValue value= Value.create((IASTExpression) arg, Value.MAX_RECURSION_DEPTH); IValue value= Value.create((IASTExpression) arg, Value.MAX_RECURSION_DEPTH);
if (value != Value.UNKNOWN && !Value.isDependentValue(value)) { if (value != Value.UNKNOWN && !Value.isDependentValue(value)) {
buf.append(value.getSignature()); buf.append(value.getSignature());

View file

@ -71,18 +71,18 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
public CPPClassScope(ICPPASTCompositeTypeSpecifier physicalNode) { public CPPClassScope(ICPPASTCompositeTypeSpecifier physicalNode) {
super(physicalNode); super(physicalNode);
((CPPASTCompositeTypeSpecifier) physicalNode).setScope(this);
createImplicitMembers();
} }
public EScopeKind getKind() { public EScopeKind getKind() {
return EScopeKind.eClassType; return EScopeKind.eClassType;
} }
// 12.1 The default constructor, copy constructor, copy assignment operator, and destructor are /**
//special member functions. The implementation will implicitly declare these member functions * Add in default constructor, copy constructor, copy assignment operator and destructor,
//for a class type when the program does not declare them. * if appropriate.
private void createImplicitMembers() { * Method will be called after ambiguity resolution.
*/
public void createImplicitMembers() {
//create bindings for the implicit members, if the user declared them then those declarations //create bindings for the implicit members, if the user declared them then those declarations
//will resolve to these bindings. //will resolve to these bindings.
ICPPASTCompositeTypeSpecifier compTypeSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); ICPPASTCompositeTypeSpecifier compTypeSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();

View file

@ -12,22 +12,15 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.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.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IProblemBinding; 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.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
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.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
@ -35,7 +28,6 @@ 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.ICPPField; 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.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
@ -51,7 +43,6 @@ public class CPPClassSpecialization extends CPPSpecialization
private ICPPClassSpecializationScope specScope; private ICPPClassSpecializationScope specScope;
private ObjectMap specializationMap= ObjectMap.EMPTY_MAP; private ObjectMap specializationMap= ObjectMap.EMPTY_MAP;
private boolean checked;
public CPPClassSpecialization(ICPPClassType specialized, IBinding owner, ICPPTemplateParameterMap argumentMap) { public CPPClassSpecialization(ICPPClassType specialized, IBinding owner, ICPPTemplateParameterMap argumentMap) {
super(specialized, owner, argumentMap); super(specialized, owner, argumentMap);
@ -82,84 +73,8 @@ public class CPPClassSpecialization extends CPPSpecialization
} }
} }
private class FindDeclarationDefinitionAction extends ASTVisitor {
private char [] nameArray = CPPClassSpecialization.this.getNameCharArray();
public IASTName foundDef = null;
public IASTName foundDecl = null;
{
shouldVisitNames = true;
shouldVisitDeclarations = true;
shouldVisitDeclSpecifiers = true;
shouldVisitDeclarators = true;
}
@Override
public int visit(IASTName name) {
final IASTNode parent = name.getParent();
final boolean isDef = parent instanceof ICPPASTCompositeTypeSpecifier;
final boolean isDecl = !isDef && parent instanceof ICPPASTElaboratedTypeSpecifier
&& parent.getParent() instanceof IASTSimpleDeclaration;
if (isDef || isDecl) {
name= name.getLastName();
if (CharArrayUtils.equals(name.getLookupKey(), nameArray)) {
IBinding binding = name.resolveBinding();
if (binding == CPPClassSpecialization.this) {
if (isDef) {
foundDef= name;
return PROCESS_ABORT;
}
if (foundDecl == null)
foundDecl= name;
}
}
}
// Don't look at members of qualified names or template ids.
return PROCESS_SKIP;
}
@Override
public int visit( IASTDeclaration declaration ){
if(declaration instanceof IASTSimpleDeclaration || declaration instanceof ICPPASTTemplateDeclaration)
return PROCESS_CONTINUE;
return PROCESS_SKIP;
}
@Override
public int visit( IASTDeclSpecifier declSpec ){
return (declSpec instanceof ICPPASTCompositeTypeSpecifier ) ? PROCESS_CONTINUE : PROCESS_SKIP;
}
@Override
public int visit( IASTDeclarator declarator ) { return PROCESS_SKIP; }
}
public void checkForDefinition() { public void checkForDefinition() {
if( !checked && definition == null ) { // Ambiguity resolution ensures that declarations and definitions are resolved.
IBinding orig= getSpecializedBinding();
IASTTranslationUnit tu= null;
while (orig != null) {
if (orig instanceof ICPPInternalBinding) {
IASTNode node= ((ICPPInternalBinding) orig).getDefinition();
if (node != null) {
tu= node.getTranslationUnit();
if (tu != null)
break;
}
}
if (!(orig instanceof ICPPSpecialization))
break;
orig= ((ICPPSpecialization) orig).getSpecializedBinding();
}
if (tu != null) {
FindDeclarationDefinitionAction action= new FindDeclarationDefinitionAction();
tu.accept( action );
definition = action.foundDef;
if (definition == null && action.foundDecl != null) {
addDeclaration(action.foundDecl);
}
}
checked = true;
}
return;
} }
public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier() { public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier() {

View file

@ -14,14 +14,9 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
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.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
@ -31,8 +26,6 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
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.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
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.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
@ -46,9 +39,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/** /**
* Represents a class template. * Represents a class template.
@ -58,56 +49,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
private ICPPClassTemplate fIndexBinding= null; private ICPPClassTemplate fIndexBinding= null;
private boolean checkedIndex= false; private boolean checkedIndex= false;
private boolean checkedDefinition= false;
private class FindDefinitionAction extends ASTVisitor {
private char[] nameArray = CPPClassTemplate.this.getNameCharArray();
public IASTName result = null;
FindDefinitionAction() {
shouldVisitNames = true;
shouldVisitDeclarations = true;
shouldVisitDeclSpecifiers = true;
shouldVisitDeclarators = true;
}
@Override
public int visit(IASTName name) {
if (name instanceof ICPPASTTemplateId || name instanceof ICPPASTQualifiedName)
return PROCESS_CONTINUE;
char[] c = name.getLookupKey();
if (name.getParent() instanceof ICPPASTTemplateId)
name = (IASTName) name.getParent();
if (name.getParent() instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName) name.getParent()).getNames();
if (ns[ns.length - 1] != name)
return PROCESS_CONTINUE;
name = (IASTName) name.getParent();
}
if (name.getParent() instanceof ICPPASTCompositeTypeSpecifier && CharArrayUtils.equals(c, nameArray)) {
IBinding binding = name.resolveBinding();
if (binding == CPPClassTemplate.this) {
result = name.getLastName();
return PROCESS_ABORT;
}
}
return PROCESS_CONTINUE;
}
@Override
public int visit(IASTDeclaration declaration) {
if (declaration instanceof IASTSimpleDeclaration || declaration instanceof ICPPASTTemplateDeclaration)
return PROCESS_CONTINUE;
return PROCESS_SKIP;
}
@Override
public int visit(IASTDeclSpecifier declSpec) {
return (declSpec instanceof ICPPASTCompositeTypeSpecifier) ? PROCESS_CONTINUE : PROCESS_SKIP;
}
@Override
public int visit(IASTDeclarator declarator) { return PROCESS_SKIP; }
}
private ICPPClassTemplatePartialSpecialization[] partialSpecializations = null; private ICPPClassTemplatePartialSpecialization[] partialSpecializations = null;
private ICPPDeferredClassInstance fDeferredInstance; private ICPPDeferredClassInstance fDeferredInstance;
@ -117,24 +59,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
} }
public void checkForDefinition() { public void checkForDefinition() {
if (checkedDefinition) // Ambiguity resolution ensures that definitions are resolved.
return;
checkedDefinition= true;
if (definition != null)
return;
FindDefinitionAction action = new FindDefinitionAction();
IASTNode node = CPPVisitor.getContainingBlockItem(declarations[0]).getParent();
while (node instanceof ICPPASTTemplateDeclaration)
node = node.getParent();
node.accept(action);
definition = action.result;
if (definition == null) {
node.getTranslationUnit().accept(action);
definition = action.result;
}
} }
public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) { public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {

View file

@ -15,16 +15,11 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
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.IASTDeclaration;
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.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
@ -33,8 +28,6 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
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.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
@ -46,7 +39,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
@ -103,58 +95,6 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
} }
} }
private class FindDefinitionAction extends ASTVisitor {
private char[] nameArray = CPPClassType.this.getNameCharArray();
public IASTName result = null;
{
shouldVisitNames = true;
shouldVisitDeclarations = true;
shouldVisitDeclSpecifiers = true;
shouldVisitDeclarators = true;
}
@Override
public int visit(IASTName name) {
if (name instanceof ICPPASTTemplateId)
return PROCESS_SKIP;
if (name instanceof ICPPASTQualifiedName)
return PROCESS_CONTINUE;
char[] c = name.getLookupKey();
if (name.getParent() instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName) name.getParent()).getNames();
if (ns[ns.length - 1] != name)
return PROCESS_CONTINUE;
name = (IASTName) name.getParent();
}
if (name.getParent() instanceof ICPPASTCompositeTypeSpecifier && CharArrayUtils.equals(c, nameArray)) {
IBinding binding = name.resolveBinding();
if (binding == CPPClassType.this) {
result= name.getLastName();
return PROCESS_ABORT;
}
}
return PROCESS_CONTINUE;
}
@Override
public int visit(IASTDeclaration declaration) {
if (declaration instanceof IASTSimpleDeclaration || declaration instanceof ICPPASTTemplateDeclaration)
return PROCESS_CONTINUE;
return PROCESS_SKIP;
}
@Override
public int visit(IASTDeclSpecifier declSpec) {
return (declSpec instanceof ICPPASTCompositeTypeSpecifier) ? PROCESS_CONTINUE : PROCESS_SKIP;
}
@Override
public int visit(IASTDeclarator declarator) {
return PROCESS_SKIP;
}
}
private IASTName definition; private IASTName definition;
private IASTName[] declarations; private IASTName[] declarations;
private boolean checked = false; private boolean checked = false;
@ -188,30 +128,16 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
} }
public void checkForDefinition() { public void checkForDefinition() {
if (!checked && definition == null) { // Ambiguity resolution ensures that definitions are resolved.
FindDefinitionAction action = new FindDefinitionAction(); if (!checked) {
IASTNode node = CPPVisitor.getContainingBlockItem(getPhysicalNode()).getParent(); if (definition == null && typeInIndex == null) {
IIndex index= getPhysicalNode().getTranslationUnit().getIndex();
if (node instanceof ICPPASTCompositeTypeSpecifier) if (index != null) {
node = CPPVisitor.getContainingBlockItem(node.getParent()); typeInIndex= (ICPPClassType) index.adaptBinding(this);
while(node instanceof ICPPASTTemplateDeclaration)
node = node.getParent();
node.accept(action);
definition = action.result;
if (definition == null) {
final IASTTranslationUnit translationUnit = node.getTranslationUnit();
translationUnit.accept(action);
definition = action.result;
if (definition == null && typeInIndex == null) {
IIndex index= translationUnit.getIndex();
if (index != null) {
typeInIndex= (ICPPClassType) index.adaptBinding(this);
}
} }
} }
checked = true;
} }
checked = true;
} }
public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier() { public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier() {
@ -291,26 +217,30 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
} }
public void addDefinition(IASTNode node) { public void addDefinition(IASTNode node) {
if (node instanceof ICPPASTCompositeTypeSpecifier) if (node instanceof ICPPASTCompositeTypeSpecifier) {
definition = ((ICPPASTCompositeTypeSpecifier)node).getName(); definition = ((ICPPASTCompositeTypeSpecifier)node).getName();
} else {
assert false;
}
} }
public void addDeclaration(IASTNode node) { public void addDeclaration(IASTNode node) {
if (!(node instanceof ICPPASTElaboratedTypeSpecifier)) if (node instanceof ICPPASTElaboratedTypeSpecifier) {
return; IASTName name = ((ICPPASTElaboratedTypeSpecifier) node).getName();
IASTName name = ((ICPPASTElaboratedTypeSpecifier) node).getName(); if (declarations == null) {
declarations = new IASTName[] { name };
return;
}
if (declarations == null) { // Keep the lowest offset declaration in [0]
declarations = new IASTName[] { name }; if (declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode) declarations[0]).getOffset()) {
return; declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, name);
} } else {
declarations = (IASTName[]) ArrayUtil.append(IASTName.class, declarations, name);
// Keep the lowest offset declaration in [0] }
if (declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode) declarations[0]).getOffset()) {
declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, name);
} else { } else {
declarations = (IASTName[]) ArrayUtil.append(IASTName.class, declarations, name); assert false;
} }
} }

View file

@ -222,26 +222,29 @@ public class CPPVisitor extends ASTQueries {
IASTNode parent = name.getParent(); IASTNode parent = name.getParent();
IBinding binding = null; IBinding binding = null;
if (parent instanceof IASTNamedTypeSpecifier || if (parent instanceof IASTNamedTypeSpecifier ||
parent instanceof ICPPASTQualifiedName ||
parent instanceof ICPPASTBaseSpecifier || parent instanceof ICPPASTBaseSpecifier ||
parent instanceof ICPPASTConstructorChainInitializer || parent instanceof ICPPASTConstructorChainInitializer ||
name.getPropertyInParent() == ICPPASTNamespaceAlias.MAPPING_NAME) { name.getPropertyInParent() == ICPPASTNamespaceAlias.MAPPING_NAME) {
if (name.getLookupKey().length == 0) if (name.getLookupKey().length == 0)
return null; return null;
binding = CPPSemantics.resolveBinding(name); return CPPSemantics.resolveBinding(name);
if (binding instanceof IProblemBinding && parent instanceof ICPPASTQualifiedName && } else if (parent instanceof ICPPASTQualifiedName) {
!(parent.getParent() instanceof ICPPASTNamespaceAlias)) { if (name.getLookupKey().length == 0)
final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) parent; return null;
final IASTName[] ns = qname.getNames();
if (ns[ns.length - 1] != name) final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) parent;
return binding; if (name != qname.getLastName())
return CPPSemantics.resolveBinding(name);
if (ns.length > 1 && ns[ns.length - 2].getBinding() instanceof IProblemBinding)
return binding; parent = parent.getParent();
binding = CPPSemantics.resolveBinding(name);
parent = parent.getParent(); if (binding instanceof IProblemBinding && !(parent instanceof ICPPASTNamespaceAlias)) {
if (((IProblemBinding) binding).getID() == IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND) { final IASTName[] ns = qname.getNames();
if (ns.length > 1 && ns[ns.length - 2].getBinding() instanceof IProblemBinding)
return binding;
if (((IProblemBinding) binding).getID() == IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND) {
IASTNode node = getContainingBlockItem(name.getParent()); IASTNode node = getContainingBlockItem(name.getParent());
ASTNodeProperty prop= node.getPropertyInParent(); ASTNodeProperty prop= node.getPropertyInParent();
while (prop == ICPPASTTemplateDeclaration.OWNED_DECLARATION) { while (prop == ICPPASTTemplateDeclaration.OWNED_DECLARATION) {
@ -264,8 +267,13 @@ public class CPPVisitor extends ASTQueries {
return binding; return binding;
} }
} else { } else {
if (binding instanceof ICPPClassType && binding instanceof IIndexBinding && name.isDefinition()) { if (parent instanceof IASTCompositeTypeSpecifier) {
parent= parent.getParent(); // need to create an ast binding. if (binding instanceof IIndexBinding) {
// Need to create an AST binding
} else {
ASTInternal.addDefinition(binding, parent);
return binding;
}
} else { } else {
return binding; return binding;
} }
@ -428,7 +436,7 @@ public class CPPVisitor extends ASTQueries {
(elabType.getName() instanceof ICPPASTQualifiedName || elabType.getKind() == IASTElaboratedTypeSpecifier.k_enum)) { (elabType.getName() instanceof ICPPASTQualifiedName || elabType.getKind() == IASTElaboratedTypeSpecifier.k_enum)) {
return binding; return binding;
} }
try { try {
boolean template = false; boolean template = false;
ICPPScope scope = (ICPPScope) getContainingScope(name); ICPPScope scope = (ICPPScope) getContainingScope(name);
@ -457,21 +465,46 @@ public class CPPVisitor extends ASTQueries {
} }
} }
} }
if (!(binding instanceof ICPPInternalBinding) || !(binding instanceof ICPPClassType) && name.isActive()) { if (binding instanceof ICPPInternalBinding) {
if (elabType.getKind() != IASTElaboratedTypeSpecifier.k_enum) { if (!name.isActive())
if (template) return binding;
binding = new CPPClassTemplate(name);
else if (binding instanceof ICPPClassType) {
binding = new CPPClassType(name, binding); final ICPPInternalBinding ib = (ICPPInternalBinding) binding;
// name may live in a different scope, so make sure to add it to the owner scope, as well. if ((binding instanceof ICPPClassTemplate) == template) {
ASTInternal.addName(scope, elabType.getName()); ib.addDeclaration(elabType);
} return binding;
} else { }
if ((binding instanceof ICPPClassTemplate) == template) { if (CPPSemantics.declaredBefore(binding, name, false)) {
ASTInternal.addDeclaration(binding, elabType); return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
} else { }
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
} // Mark the other declarations as problem and create the binding
final IASTNode[] decls = ib.getDeclarations();
if (decls != null) {
for (IASTNode decl : decls) {
if (decl instanceof IASTName) {
final IASTName n = (IASTName) decl;
n.setBinding(new ProblemBinding(n, IProblemBinding.SEMANTIC_INVALID_REDECLARATION));
}
}
}
IASTNode decl= ib.getDefinition();
if (decl instanceof IASTName) {
final IASTName n = (IASTName) decl;
n.setBinding(new ProblemBinding(n, IProblemBinding.SEMANTIC_INVALID_REDEFINITION));
}
}
}
// Create a binding
if (elabType.getKind() != IASTElaboratedTypeSpecifier.k_enum) {
if (template)
binding = new CPPClassTemplate(name);
else
binding = new CPPClassType(name, binding);
// name may live in a different scope, so make sure to add it to the owner scope, as well.
ASTInternal.addName(scope, elabType.getName());
} }
} catch (DOMException e) { } catch (DOMException e) {
binding = e.getProblem(); binding = e.getProblem();
@ -2314,7 +2347,7 @@ public class CPPVisitor extends ASTQueries {
} }
public static IBinding findNameOwner(IASTName name, boolean allowFunction) { public static IBinding findNameOwner(IASTName name, boolean allowFunction) {
IASTNode node= name; IASTNode node= name.getLastName();
while (node instanceof IASTName) { while (node instanceof IASTName) {
if (node instanceof ICPPASTQualifiedName) { if (node instanceof ICPPASTQualifiedName) {
IASTName[] qn= ((ICPPASTQualifiedName) node).getNames(); IASTName[] qn= ((ICPPASTQualifiedName) node).getNames();

View file

@ -85,6 +85,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
@ -481,6 +482,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
String newid= IndexerPreferences.get(prj, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER); String newid= IndexerPreferences.get(prj, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);
Properties props= IndexerPreferences.getProperties(prj); Properties props= IndexerPreferences.getProperties(prj);
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=359485
synchronized (new ProjectScope(prj).getNode(CCorePlugin.PLUGIN_ID)) {
synchronized (fUpdatePolicies) { synchronized (fUpdatePolicies) {
if (fClosingProjects.contains(prj.getName())) { if (fClosingProjects.contains(prj.getName())) {
return; return;
@ -504,7 +507,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
} }
enqueue(new PDOMRebuildTask(indexer)); enqueue(new PDOMRebuildTask(indexer));
} }
} }}
if (oldIndexer != null) { if (oldIndexer != null) {
stopIndexer(oldIndexer); stopIndexer(oldIndexer);
@ -537,6 +540,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
assert !Thread.holdsLock(fProjectToPDOM); assert !Thread.holdsLock(fProjectToPDOM);
try { try {
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=359485
synchronized (new ProjectScope(prj).getNode(CCorePlugin.PLUGIN_ID)) {
synchronized (fUpdatePolicies) { synchronized (fUpdatePolicies) {
if (fClosingProjects.contains(name)) { if (fClosingProjects.contains(name)) {
if (fTraceIndexerSetup) if (fTraceIndexerSetup)
@ -586,12 +591,14 @@ public class PDOMManager implements IWritableIndexManager, IListener {
} }
return; return;
} }
} }}
// rebuild is required, try import first. // rebuild is required, try import first.
TeamPDOMImportOperation operation= new TeamPDOMImportOperation(project); TeamPDOMImportOperation operation= new TeamPDOMImportOperation(project);
operation.run(pm); operation.run(pm);
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=359485
synchronized (new ProjectScope(prj).getNode(CCorePlugin.PLUGIN_ID)) {
synchronized (fUpdatePolicies) { synchronized (fUpdatePolicies) {
if (fClosingProjects.contains(name)) { if (fClosingProjects.contains(name)) {
if (fTraceIndexerSetup) if (fTraceIndexerSetup)
@ -618,7 +625,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
task= new PDOMRebuildTask(indexer); task= new PDOMRebuildTask(indexer);
} }
enqueue(task); enqueue(task);
} }}
} catch (CoreException e) { } catch (CoreException e) {
// Ignore if project is no longer open // Ignore if project is no longer open
if (prj.isOpen()) { if (prj.isOpen()) {

View file

@ -13,6 +13,8 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -473,6 +475,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
final long fileLocalRec= type.getLocalToFileRec(); final long fileLocalRec= type.getLocalToFileRec();
IScope scope = binding.getCompositeScope(); IScope scope = binding.getCompositeScope();
if (scope instanceof ICPPClassScope) { if (scope instanceof ICPPClassScope) {
List<ICPPMethod> old= new ArrayList<ICPPMethod>();
if (type instanceof ICPPClassType) {
IScope oldScope = ((ICPPClassType)type).getCompositeScope();
if (oldScope instanceof ICPPClassScope) {
old.addAll(Arrays.asList(((ICPPClassScope) oldScope).getImplicitMethods()));
}
}
ICPPMethod[] implicit= ((ICPPClassScope) scope).getImplicitMethods(); ICPPMethod[] implicit= ((ICPPClassScope) scope).getImplicitMethods();
for (ICPPMethod method : implicit) { for (ICPPMethod method : implicit) {
if (!(method instanceof IProblemBinding)) { if (!(method instanceof IProblemBinding)) {
@ -481,9 +490,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
pdomBinding = createBinding(type, method, fileLocalRec); pdomBinding = createBinding(type, method, fileLocalRec);
} else if (!getPDOM().hasLastingDefinition(pdomBinding)) { } else if (!getPDOM().hasLastingDefinition(pdomBinding)) {
pdomBinding.update(this, method); pdomBinding.update(this, method);
old.remove(pdomBinding);
} }
} }
} }
for (ICPPMethod method : old) {
if (method instanceof PDOMBinding)
((PDOMBinding) method).update(this, null);
}
} }
} catch (DOMException e) { } catch (DOMException e) {
CCorePlugin.log(e); CCorePlugin.log(e);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 QNX Software Systems and others. * Copyright (c) 2006, 2011 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
@ -80,7 +80,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
} }
@Override @Override
public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException { public final void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof ICPPMethod) { if (newBinding instanceof ICPPMethod) {
ICPPMethod method= (ICPPMethod) newBinding; ICPPMethod method= (ICPPMethod) newBinding;
super.update(linkage, newBinding); super.update(linkage, newBinding);
@ -92,6 +92,11 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
} catch (DOMException e) { } catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
} }
} else if (newBinding == null && isImplicit()) {
// Clear the implicit flag, such that the binding will no longer be picked up.
byte annot= (byte) (getAnnotation1() ^ (1 << PDOMCPPAnnotation.IMPLICIT_METHOD_OFFSET));
getDB().putByte(record + ANNOTATION1, annot);
annotation1= annot;
} }
} }

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.ui.tests; package org.eclipse.cdt.ui.tests;
@ -125,7 +125,7 @@ public class BaseUITestCase extends BaseTestCase {
while (firstTime || System.currentTimeMillis() < endTime) { while (firstTime || System.currentTimeMillis() < endTime) {
if (!firstTime) { if (!firstTime) {
Thread.sleep(sleep); Thread.sleep(sleep);
sleep= Math.min(250, sleep*2); sleep= Math.min(250, sleep * 2);
} }
firstTime= false; firstTime= false;
@ -143,7 +143,7 @@ public class BaseUITestCase extends BaseTestCase {
} }
} finally { } finally {
index.releaseReadLock(); index.releaseReadLock();
int time= (int) (endTime- System.currentTimeMillis()); int time= (int) (endTime - System.currentTimeMillis());
if (time > 0) { if (time > 0) {
CCorePlugin.getIndexManager().joinIndexer(time, npm()); CCorePlugin.getIndexManager().joinIndexer(time, npm());
} }
@ -153,10 +153,11 @@ public class BaseUITestCase extends BaseTestCase {
} }
protected void runEventQueue(int time) { protected void runEventQueue(int time) {
final long endTime= System.currentTimeMillis()+time; final long endTime= System.currentTimeMillis() + time;
while(true) { while (true) {
while (Display.getCurrent().readAndDispatch()); while (Display.getCurrent().readAndDispatch())
long diff= endTime-System.currentTimeMillis(); ;
long diff= endTime - System.currentTimeMillis();
if (diff <= 0) { if (diff <= 0) {
break; break;
} }
@ -169,18 +170,18 @@ public class BaseUITestCase extends BaseTestCase {
} }
protected void expandTreeItem(Tree tree, int idx) { protected void expandTreeItem(Tree tree, int idx) {
expandTreeItem(tree, new int[] {idx}); expandTreeItem(tree, new int[] { idx });
} }
protected void expandTreeItem(Tree tree, int idx1, int idx2) { protected void expandTreeItem(Tree tree, int idx1, int idx2) {
expandTreeItem(tree, new int[] {idx1, idx2}); expandTreeItem(tree, new int[] { idx1, idx2 });
} }
protected void expandTreeItem(Tree tree, int[] idxs) { protected void expandTreeItem(Tree tree, int[] idxs) {
TreeItem item= tree.getItem(idxs[0]); TreeItem item= tree.getItem(idxs[0]);
assertNotNull(item); assertNotNull(item);
expandTreeItem(item); expandTreeItem(item);
for (int i=1; i < idxs.length; i++) { for (int i= 1; i < idxs.length; i++) {
item= item.getItem(idxs[i]); item= item.getItem(idxs[i]);
assertNotNull(item); assertNotNull(item);
expandTreeItem(item); expandTreeItem(item);
@ -206,7 +207,7 @@ public class BaseUITestCase extends BaseTestCase {
protected void selectTreeItem(Tree tree, int[] idxs) { protected void selectTreeItem(Tree tree, int[] idxs) {
TreeItem item= tree.getItem(idxs[0]); TreeItem item= tree.getItem(idxs[0]);
assertNotNull(item); assertNotNull(item);
for (int i=1; i < idxs.length; i++) { for (int i= 1; i < idxs.length; i++) {
item= item.getItem(idxs[i]); item= item.getItem(idxs[i]);
assertNotNull(item); assertNotNull(item);
} }
@ -317,7 +318,7 @@ public class BaseUITestCase extends BaseTestCase {
final protected TreeItem checkTreeNode(Tree tree, int i0, String label) { final protected TreeItem checkTreeNode(Tree tree, int i0, String label) {
TreeItem root= null; TreeItem root= null;
for (int millis=0; millis < 5000; millis= millis==0 ? 1 : millis*2) { for (int millis= 0; millis < 5000; millis= millis == 0 ? 1 : millis * 2) {
runEventQueue(millis); runEventQueue(millis);
try { try {
root= tree.getItem(i0); root= tree.getItem(i0);
@ -340,7 +341,7 @@ public class BaseUITestCase extends BaseTestCase {
String itemText= null; String itemText= null;
SWTException ex= null; SWTException ex= null;
String firstItemText= null; String firstItemText= null;
for (int millis=0; millis < 5000; millis= millis==0 ? 1 : millis*2) { for (int millis= 0; millis < 5000; millis= millis == 0 ? 1 : millis * 2) {
runEventQueue(millis); runEventQueue(millis);
TreeItem root= tree.getItem(i0); TreeItem root= tree.getItem(i0);
if (!root.getExpanded()) { if (!root.getExpanded()) {

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.ui.tests.includebrowser; package org.eclipse.cdt.ui.tests.includebrowser;
@ -34,13 +34,12 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
return suite(BasicIncludeBrowserTest.class); return suite(BasicIncludeBrowserTest.class);
} }
// // source // // source
// #include "user.h" // #include "user.h"
// #include <system.h> // #include <system.h>
public void testSimpleInclusion() throws Exception { public void testSimpleInclusion() throws Exception {
TestScannerProvider.sIncludes= new String[]{getProject().getProject().getLocation().toOSString()}; TestScannerProvider.sIncludes= new String[] { getProject().getProject().getLocation().toOSString() };
StringBuilder[] contents= getContentsForTest(1); StringBuilder[] contents= getContentsForTest(1);
IProject project= getProject().getProject(); IProject project= getProject().getProject();
@ -55,7 +54,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
checkTreeNode(tree, 0, 0, "user.h"); checkTreeNode(tree, 0, 0, "user.h");
checkTreeNode(tree, 0, 1, "system.h"); checkTreeNode(tree, 0, 1, "system.h");
// the tree has to be reversed // The tree has to be reversed
openIncludeBrowser(user, true); openIncludeBrowser(user, true);
checkTreeNode(tree, 0, "user.h"); checkTreeNode(tree, 0, "user.h");
checkTreeNode(tree, 0, 0, "source.cpp"); checkTreeNode(tree, 0, 0, "source.cpp");
@ -72,9 +71,9 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
public void testInclusionAccrossProjects() throws Exception { public void testInclusionAccrossProjects() throws Exception {
ICProject op= CProjectHelper.createCCProject("__ibTest_other__", "bin", IPDOMManager.ID_FAST_INDEXER); ICProject op= CProjectHelper.createCCProject("__ibTest_other__", "bin", IPDOMManager.ID_FAST_INDEXER);
try { try {
fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] {getProject(), op}); fIndex= CCorePlugin.getIndexManager().getIndex(new ICProject[] { getProject(), op });
TestScannerProvider.sIncludes= new String[]{op.getProject().getLocation().toOSString()}; TestScannerProvider.sIncludes= new String[] { op.getProject().getLocation().toOSString() };
StringBuilder[] contents= getContentsForTest(1); StringBuilder[] contents= getContentsForTest(1);
IFile user= createFile(op.getProject(), "user.h", ""); IFile user= createFile(op.getProject(), "user.h", "");
@ -89,7 +88,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
checkTreeNode(tree, 0, 0, "user.h"); checkTreeNode(tree, 0, 0, "user.h");
checkTreeNode(tree, 0, 1, "system.h"); checkTreeNode(tree, 0, 1, "system.h");
// the tree has to be reversed // The tree has to be reversed
openIncludeBrowser(user, true); openIncludeBrowser(user, true);
checkTreeNode(tree, 0, "user.h"); checkTreeNode(tree, 0, "user.h");
checkTreeNode(tree, 0, 0, "source.cpp"); checkTreeNode(tree, 0, 0, "source.cpp");
@ -97,10 +96,8 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
openIncludeBrowser(system); openIncludeBrowser(system);
checkTreeNode(tree, 0, "system.h"); checkTreeNode(tree, 0, "system.h");
checkTreeNode(tree, 0, 0, "source.cpp"); checkTreeNode(tree, 0, 0, "source.cpp");
} finally { } finally {
CProjectHelper.delete(op); CProjectHelper.delete(op);
} }
} }
} }

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.internal.ui.includebrowser; package org.eclipse.cdt.internal.ui.includebrowser;
@ -34,7 +34,6 @@ import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
* This is the content provider for the include browser. * This is the content provider for the include browser.
*/ */
public class IBContentProvider extends AsyncTreeContentProvider { public class IBContentProvider extends AsyncTreeContentProvider {
private static final IProgressMonitor NPM = new NullProgressMonitor(); private static final IProgressMonitor NPM = new NullProgressMonitor();
private boolean fComputeIncludedBy = true; private boolean fComputeIncludedBy = true;
@ -66,7 +65,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
return NO_CHILDREN; return NO_CHILDREN;
} }
} }
// allow for async computation // Allow for asynchronous computation
return null; return null;
} }
@ -98,8 +97,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
IIndexInclude[] includes; IIndexInclude[] includes;
if (fComputeIncludedBy) { if (fComputeIncludedBy) {
includes= findIncludedBy(index, ifl, NPM); includes= findIncludedBy(index, ifl, NPM);
} } else {
else {
includes= findIncludesTo(index, ifl, NPM); includes= findIncludesTo(index, ifl, NPM);
directiveFile= node.getRepresentedFile(); directiveFile= node.getRepresentedFile();
} }
@ -110,13 +108,11 @@ public class IBContentProvider extends AsyncTreeContentProvider {
try { try {
if (fComputeIncludedBy) { if (fComputeIncludedBy) {
directiveFile= targetFile= new IBFile(project, include.getIncludedByLocation()); directiveFile= targetFile= new IBFile(project, include.getIncludedByLocation());
} } else {
else {
IIndexFileLocation includesPath= include.getIncludesLocation(); IIndexFileLocation includesPath= include.getIncludesLocation();
if (includesPath == null) { if (includesPath == null) {
targetFile= new IBFile(include.getFullName()); targetFile= new IBFile(include.getFullName());
} } else {
else {
targetFile= new IBFile(project, includesPath); targetFile= new IBFile(project, includesPath);
} }
} }
@ -127,24 +123,20 @@ public class IBContentProvider extends AsyncTreeContentProvider {
newnode.setIsActiveCode(include.isActive()); newnode.setIsActiveCode(include.isActive());
newnode.setIsSystemInclude(include.isSystemInclude()); newnode.setIsSystemInclude(include.isSystemInclude());
result.add(newnode); result.add(newnode);
} } catch (CoreException e) {
catch (CoreException e) {
CUIPlugin.log(e); CUIPlugin.log(e);
} }
} }
return result.toArray(); return result.toArray();
} }
} } finally {
finally {
index.releaseReadLock(); index.releaseReadLock();
} }
} }
return NO_CHILDREN; return NO_CHILDREN;
} }
public void setComputeIncludedBy(boolean value) { public void setComputeIncludedBy(boolean value) {
fComputeIncludedBy = value; fComputeIncludedBy = value;
} }
@ -152,8 +144,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
public boolean getComputeIncludedBy() { public boolean getComputeIncludedBy() {
return fComputeIncludedBy; return fComputeIncludedBy;
} }
private IIndexInclude[] findIncludedBy(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) { private IIndexInclude[] findIncludedBy(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
try { try {
if (ifl != null) { if (ifl != null) {
@ -176,8 +167,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
return list.toArray(new IIndexInclude[list.size()]); return list.toArray(new IIndexInclude[list.size()]);
} }
} }
} } catch (CoreException e) {
catch (CoreException e) {
CUIPlugin.log(e); CUIPlugin.log(e);
} }
return new IIndexInclude[0]; return new IIndexInclude[0];
@ -205,8 +195,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
return list.toArray(new IIndexInclude[list.size()]); return list.toArray(new IIndexInclude[list.size()]);
} }
} }
} } catch (CoreException e) {
catch (CoreException e) {
CUIPlugin.log(e); CUIPlugin.log(e);
} }
return new IIndexInclude[0]; return new IIndexInclude[0];

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
* Ed Swartz (Nokia) * Ed Swartz (Nokia)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.includebrowser; package org.eclipse.cdt.internal.ui.includebrowser;
@ -104,9 +104,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
/** /**
* The view part for the include browser. * The view part for the include browser.
*/ */
public class IBViewPart extends ViewPart public class IBViewPart extends ViewPart implements IShowInSource, IShowInTarget, IShowInTargetList {
implements IShowInSource, IShowInTarget, IShowInTargetList {
private static final int MAX_HISTORY_SIZE = 10; private static final int MAX_HISTORY_SIZE = 10;
private static final String TRUE = "true"; //$NON-NLS-1$ private static final String TRUE = "true"; //$NON-NLS-1$
private static final String FALSE = "false"; //$NON-NLS-1$ private static final String FALSE = "false"; //$NON-NLS-1$
@ -183,8 +181,7 @@ public class IBViewPart extends ViewPart
if (CCorePlugin.getIndexManager().isIndexerIdle()) { if (CCorePlugin.getIndexManager().isIndexerIdle()) {
setInputIndexerIdle(input); setInputIndexerIdle(input);
} } else {
else {
setMessage(IBMessages.IBViewPart_waitingOnIndexerMessage); setMessage(IBMessages.IBViewPart_waitingOnIndexerMessage);
fSetInputJob.setInput(input); fSetInputJob.setInput(input);
fSetInputJob.schedule(); fSetInputJob.schedule();
@ -202,8 +199,7 @@ public class IBViewPart extends ViewPart
fIncludesToAction.setChecked(!isHeader); fIncludesToAction.setChecked(!isHeader);
fIncludedByAction.setEnabled(false); fIncludedByAction.setEnabled(false);
updateSorter(); updateSorter();
} } else {
else {
fIncludedByAction.setEnabled(true); fIncludedByAction.setEnabled(true);
} }
fTreeViewer.setInput(input); fTreeViewer.setInput(input);
@ -349,14 +345,12 @@ public class IBViewPart extends ViewPart
} }
} }
@Override @Override
public void init(IViewSite site, IMemento memento) throws PartInitException { public void init(IViewSite site, IMemento memento) throws PartInitException {
fMemento= memento; fMemento= memento;
super.init(site, memento); super.init(site, memento);
} }
@Override @Override
public void saveState(IMemento memento) { public void saveState(IMemento memento) {
putDialogSettings(); putDialogSettings();
@ -501,8 +495,7 @@ public class IBViewPart extends ViewPart
public void run() { public void run() {
if (isChecked()) { if (isChecked()) {
fTreeViewer.addFilter(fInactiveFilter); fTreeViewer.addFilter(fInactiveFilter);
} } else {
else {
fTreeViewer.removeFilter(fInactiveFilter); fTreeViewer.removeFilter(fInactiveFilter);
} }
} }
@ -525,8 +518,7 @@ public class IBViewPart extends ViewPart
public void run() { public void run() {
if (isChecked()) { if (isChecked()) {
fTreeViewer.addFilter(fSystemFilter); fTreeViewer.addFilter(fSystemFilter);
} } else {
else {
fTreeViewer.removeFilter(fSystemFilter); fTreeViewer.removeFilter(fSystemFilter);
} }
} }
@ -675,8 +667,7 @@ public class IBViewPart extends ViewPart
private void updateSorter() { private void updateSorter() {
if (fIncludedByAction.isChecked()) { if (fIncludedByAction.isChecked()) {
fTreeViewer.setComparator(fSorterAlphaNumeric); fTreeViewer.setComparator(fSorterAlphaNumeric);
} } else {
else {
fTreeViewer.setComparator(fSorterReferencePosition); fTreeViewer.setComparator(fSorterReferencePosition);
} }
} }
@ -693,15 +684,13 @@ public class IBViewPart extends ViewPart
file= path.lastSegment() + "(" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$//$NON-NLS-2$ file= path.lastSegment() + "(" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$//$NON-NLS-2$
if (fWorkingSetFilter == null) { if (fWorkingSetFilter == null) {
scope= IBMessages.IBViewPart_workspaceScope; scope= IBMessages.IBViewPart_workspaceScope;
} } else {
else {
scope= fWorkingSetFilter.getLabel(); scope= fWorkingSetFilter.getLabel();
} }
if (fIncludedByAction.isChecked()) { if (fIncludedByAction.isChecked()) {
format= IBMessages.IBViewPart_IncludedByContentDescription; format= IBMessages.IBViewPart_IncludedByContentDescription;
} } else {
else {
format= IBMessages.IBViewPart_IncludesToContentDescription; format= IBMessages.IBViewPart_IncludesToContentDescription;
} }
message= Messages.format(format, file, scope); message= Messages.format(format, file, scope);
@ -717,12 +706,10 @@ public class IBViewPart extends ViewPart
fTreeViewer.removeFilter(fWorkingSetFilter); fTreeViewer.removeFilter(fWorkingSetFilter);
fWorkingSetFilter= null; fWorkingSetFilter= null;
} }
} } else {
else {
if (fWorkingSetFilter != null) { if (fWorkingSetFilter != null) {
fTreeViewer.refresh(); fTreeViewer.refresh();
} } else {
else {
fWorkingSetFilter= new IBWorkingSetFilter(filterUI); fWorkingSetFilter= new IBWorkingSetFilter(filterUI);
fTreeViewer.addFilter(fWorkingSetFilter); fTreeViewer.addFilter(fWorkingSetFilter);
} }
@ -777,7 +764,6 @@ public class IBViewPart extends ViewPart
} }
}); });
} }
} }
} }
m.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS)); m.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
@ -797,8 +783,7 @@ public class IBViewPart extends ViewPart
IFile f= ibf.getResource(); IFile f= ibf.getResource();
if (f != null) { if (f != null) {
EditorOpener.open(page, f, region, timestamp); EditorOpener.open(page, f, region, timestamp);
} } else {
else {
IIndexFileLocation ifl = ibf.getLocation(); IIndexFileLocation ifl = ibf.getLocation();
if (ifl != null) { if (ifl != null) {
IPath location= IndexLocationFactory.getAbsolutePath(ifl); IPath location= IndexLocationFactory.getAbsolutePath(ifl);
@ -807,8 +792,7 @@ public class IBViewPart extends ViewPart
} }
} }
} }
} } else {
else {
ITranslationUnit tu= IBConversions.selectionToTU(selection); ITranslationUnit tu= IBConversions.selectionToTU(selection);
if (tu != null) { if (tu != null) {
IResource r= tu.getResource(); IResource r= tu.getResource();

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.internal.ui.includebrowser; package org.eclipse.cdt.internal.ui.includebrowser;
@ -39,7 +39,7 @@ public class IncludeBrowserUI {
ITranslationUnit tu= convertToTranslationUnit(input); ITranslationUnit tu= convertToTranslationUnit(input);
if (tu != null) { if (tu != null) {
IWorkbenchPage page= window.getActivePage(); IWorkbenchPage page= window.getActivePage();
IBViewPart result= (IBViewPart)page.showView(CUIPlugin.ID_INCLUDE_BROWSER); IBViewPart result= (IBViewPart) page.showView(CUIPlugin.ID_INCLUDE_BROWSER);
result.setInput(tu); result.setInput(tu);
} }
} catch (CoreException e) { } catch (CoreException e) {
@ -52,7 +52,7 @@ public class IncludeBrowserUI {
public static void open(final ITextEditor editor, final ITextSelection sel) { public static void open(final ITextEditor editor, final ITextSelection sel) {
if (editor != null) { if (editor != null) {
ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()); ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
open (editor.getSite().getWorkbenchWindow(), inputCElement); open(editor.getSite().getWorkbenchWindow(), inputCElement);
} }
} }
@ -80,8 +80,7 @@ public class IncludeBrowserUI {
return CoreModelUtil.findTranslationUnitForLocation(loc, project); return CoreModelUtil.findTranslationUnitForLocation(loc, project);
} }
} }
} } finally {
finally {
index.releaseReadLock(); index.releaseReadLock();
} }
} }

View file

@ -423,15 +423,15 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
private String getLanguageName(ICLanguageSetting langSetting) { private String getLanguageName(ICLanguageSetting langSetting) {
String langId = langSetting.getLanguageId(); String langId = langSetting.getLanguageId();
String langName = null; String langName = null;
if (langId != null && !langId.isEmpty()) { if (langId != null && langId.length() != 0) {
// Bug #178033: get language name via LangManager. // Bug #178033: get language name via LangManager.
ILanguageDescriptor langDes = LanguageManager.getInstance().getLanguageDescriptor(langId); ILanguageDescriptor langDes = LanguageManager.getInstance().getLanguageDescriptor(langId);
if (langDes != null) if (langDes != null)
langName = langDes.getName(); langName = langDes.getName();
} }
if (langName == null || langName.isEmpty()) if (langName == null || langName.length() == 0)
langName = langSetting.getName(); langName = langSetting.getName();
if (langName == null || langName.isEmpty()) if (langName == null || langName.length() == 0)
langName = langId; langName = langId;
return langName; return langName;
} }