Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2006-01-18 17:59:29 +0000
committerDoug Schaefer2006-01-18 17:59:29 +0000
commit314113adb0514e4b50b8a2603d9b28c7a4ff57c4 (patch)
tree6dfe776b648ae820e5ea67da645664fb6ac23a8e
parent1849e12a3803a18c0c3bab670df2f05f9d8cbe2c (diff)
downloadorg.eclipse.cdt-314113adb0514e4b50b8a2603d9b28c7a4ff57c4.tar.gz
org.eclipse.cdt-314113adb0514e4b50b8a2603d9b28c7a4ff57c4.tar.xz
org.eclipse.cdt-314113adb0514e4b50b8a2603d9b28c7a4ff57c4.zip
PDOM - Hooked up resolveBinding and OpenDeclarations.
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java28
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ICodeReaderFactory.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java44
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java42
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMDatabase.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMTranslationUnit.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java67
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPField.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java85
-rw-r--r--core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java21
16 files changed, 284 insertions, 74 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java
index 688425b02e6..c8c8c0e4ee6 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILanguage.java
@@ -12,11 +12,10 @@
package org.eclipse.cdt.core.model;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
-import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.IAdaptable;
/**
@@ -55,15 +54,32 @@ public interface ILanguage extends IAdaptable {
public String getId();
/**
- * Create the AST for the given translation unit with the given style.
+ * Create the AST for the given file with the given style.
*
* @param file
* @param style
* @return
*/
- public IASTTranslationUnit getTranslationUnit(ITranslationUnit file, int style);
+ public IASTTranslationUnit getTranslationUnit(IFile file, int style);
/**
+ * Create the AST for the given external file with the given style.
+ *
+ * @param file
+ * @param style
+ * @return
+ */
+ public IASTTranslationUnit getTranslationUnit(IStorage file, IProject project, int style);
+
+ /**
+ * Return the ASt for the given working copy
+ * @param workingCopy
+ * @param style
+ * @return
+ */
+ public IASTTranslationUnit getTranslationUnit(IWorkingCopy workingCopy, int style);
+
+ /**
* Return the AST Completion Node for the given working copy at the given
* offset.
*
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ICodeReaderFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ICodeReaderFactory.java
index e1c36f7dfac..71eb306c22b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ICodeReaderFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ICodeReaderFactory.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom;
-import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache;
@@ -37,8 +36,6 @@ public interface ICodeReaderFactory {
*/
public CodeReader createCodeReaderForTranslationUnit(String path);
- public CodeReader createCodeReaderForTranslationUnit(ITranslationUnit tu);
-
/**
* Create CodeReader for inclusion.
*
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
index a43dea25690..d25e8159eb1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
@@ -11,6 +11,7 @@
package org.eclipse.cdt.core.dom.ast;
import org.eclipse.cdt.core.dom.IPDOM;
+import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ParserLanguage;
/**
@@ -202,5 +203,12 @@ public interface IASTTranslationUnit extends IASTNode {
* @param index
*/
public void setIndex(IPDOM index);
+
+ /**
+ * Returns the language for this translation unit.
+ *
+ * @return language for this translation unit
+ */
+ public ILanguage getLanguage();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java
index 9d6f056efe2..4dea6698f91 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/c/GCCLanguage.java
@@ -13,10 +13,11 @@ package org.eclipse.cdt.core.dom.ast.gnu.c;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.IPDOM;
+import org.eclipse.cdt.core.dom.PDOM;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IScanner;
@@ -40,6 +41,8 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkageFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -63,31 +66,46 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
return super.getAdapter(adapter);
}
- public IASTTranslationUnit getTranslationUnit(ITranslationUnit tu, int style) {
- IFile file = (IFile)tu.getResource();
- IProject project = file.getProject();
+ public IASTTranslationUnit getTranslationUnit(IStorage file, IProject project, int style) {
+ return getTranslationUnit(file.getFullPath().toOSString(), project, project, style, null);
+ }
+
+ public IASTTranslationUnit getTranslationUnit(IFile file, int style) {
+ return getTranslationUnit(file.getLocation().toOSString(), file.getProject(), file, style, null);
+ }
+
+ public IASTTranslationUnit getTranslationUnit(IWorkingCopy workingCopy, int style) {
+ IFile file = (IFile)workingCopy.getResource();
+ String path = file.getLocation().toOSString();
+ CodeReader reader = new CodeReader(path, workingCopy.getContents());
+ return getTranslationUnit(path, file.getProject(), file, style, reader);
+ }
+
+ protected IASTTranslationUnit getTranslationUnit(String path, IProject project, IResource infoResource, int style,
+ CodeReader reader) {
IScannerInfo scanInfo = null;
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
if (provider != null){
- IScannerInfo buildScanInfo = provider.getScannerInformation(file);
+ IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
if (buildScanInfo != null)
scanInfo = buildScanInfo;
else
scanInfo = new ScannerInfo();
}
- // TODO - use different factories if we are working copy, or style
- // is skip headers.
+ IPDOM pdom = PDOM.getPDOM(project);
ICodeReaderFactory fileCreator;
if ((style & ILanguage.AST_SKIP_INDEXED_HEADERS) != 0)
- fileCreator = new PDOMCodeReaderFactory((PDOMDatabase)tu.getCProject().getIndex());
+ fileCreator = new PDOMCodeReaderFactory((PDOMDatabase)pdom);
else
fileCreator = SavedCodeReaderFactory.getInstance();
- CodeReader reader = fileCreator.createCodeReaderForTranslationUnit(tu);
- if( reader == null )
- return null;
-
+ if (reader == null) {
+ reader = fileCreator.createCodeReaderForTranslationUnit(path);
+ if( reader == null )
+ return null;
+ }
+
IScannerExtensionConfiguration scannerExtensionConfiguration =
scannerExtensionConfiguration = C_GNU_SCANNER_EXTENSION;
@@ -101,7 +119,7 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
IASTTranslationUnit ast = parser.parse();
if ((style & AST_USE_INDEX) != 0)
- ast.setIndex(tu.getCProject().getIndex());
+ ast.setIndex(pdom);
return ast;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java
index 920c5d2e211..0c79f192c35 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/gnu/cpp/GPPLanguage.java
@@ -13,10 +13,11 @@ package org.eclipse.cdt.core.dom.ast.gnu.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
+import org.eclipse.cdt.core.dom.IPDOM;
+import org.eclipse.cdt.core.dom.PDOM;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IScanner;
@@ -40,6 +41,8 @@ import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.PlatformObject;
/**
@@ -62,30 +65,45 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
return super.getAdapter(adapter);
}
- public IASTTranslationUnit getTranslationUnit(ITranslationUnit tu, int style) {
- IFile file = (IFile)tu.getResource();
- IProject project = file.getProject();
+ public IASTTranslationUnit getTranslationUnit(IStorage file, IProject project, int style) {
+ return getTranslationUnit(file.getFullPath().toOSString(), project, project, style, null);
+ }
+
+ public IASTTranslationUnit getTranslationUnit(IFile file, int style) {
+ return getTranslationUnit(file.getLocation().toOSString(), file.getProject(), file, style, null);
+ }
+
+ public IASTTranslationUnit getTranslationUnit(IWorkingCopy workingCopy, int style) {
+ IFile file = (IFile)workingCopy.getResource();
+ String path = file.getLocation().toOSString();
+ CodeReader reader = new CodeReader(path, workingCopy.getContents());
+ return getTranslationUnit(path, file.getProject(), file, style, reader);
+ }
+
+ protected IASTTranslationUnit getTranslationUnit(String path, IProject project, IResource infoResource, int style,
+ CodeReader reader) {
IScannerInfo scanInfo = null;
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
if (provider != null){
- IScannerInfo buildScanInfo = provider.getScannerInformation(file);
+ IScannerInfo buildScanInfo = provider.getScannerInformation(infoResource);
if (buildScanInfo != null)
scanInfo = buildScanInfo;
else
scanInfo = new ScannerInfo();
}
- // TODO - use different factories if we are working copy, or style
- // is skip headers.
+ IPDOM pdom = PDOM.getPDOM(project);
ICodeReaderFactory fileCreator;
if ((style & ILanguage.AST_SKIP_INDEXED_HEADERS) != 0)
- fileCreator = new PDOMCodeReaderFactory((PDOMDatabase)tu.getCProject().getIndex());
+ fileCreator = new PDOMCodeReaderFactory((PDOMDatabase)pdom);
else
fileCreator = SavedCodeReaderFactory.getInstance();
- CodeReader reader = fileCreator.createCodeReaderForTranslationUnit(tu);
- if( reader == null )
- return null;
+ if (reader == null) {
+ reader = fileCreator.createCodeReaderForTranslationUnit(path);
+ if( reader == null )
+ return null;
+ }
IScannerExtensionConfiguration scannerExtensionConfiguration = CPP_GNU_SCANNER_EXTENSION;
@@ -98,7 +116,7 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
IASTTranslationUnit ast = parser.parse();
if ((style & AST_USE_INDEX) != 0)
- ast.setIndex(tu.getCProject().getIndex());
+ ast.setIndex(pdom);
return ast;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
index ab2474f92ca..ecbd6cfdef8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
@@ -37,6 +37,8 @@ import org.eclipse.cdt.core.dom.ast.IMacroBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
+import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@@ -521,6 +523,11 @@ public class CASTTranslationUnit extends CASTNode implements
return ParserLanguage.C;
}
+ public ILanguage getLanguage() {
+ // Assuming gnu C for now.
+ return new GCCLanguage();
+ }
+
public IPDOM getIndex() {
return pdom;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
index ee44469ea26..8f3c97d479d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
@@ -51,6 +51,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
+import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
+import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@@ -573,6 +575,11 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
return ParserLanguage.CPP;
}
+ public ILanguage getLanguage() {
+ // Assuming gnu C++ for now.
+ return new GPPLanguage();
+ }
+
public IPDOM getIndex() {
return pdom;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMDatabase.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMDatabase.java
index c71e7506542..ff9f88ef7a2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMDatabase.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMDatabase.java
@@ -118,7 +118,7 @@ public class PDOMDatabase implements IPDOM {
if (linkage == null)
return;
- IASTTranslationUnit ast = language.getTranslationUnit(tu,
+ IASTTranslationUnit ast = language.getTranslationUnit((IFile)tu.getResource(),
ILanguage.AST_USE_INDEX |
ILanguage.AST_SKIP_INDEXED_HEADERS);
if (ast == null)
@@ -180,6 +180,13 @@ public class PDOMDatabase implements IPDOM {
}
public IBinding resolveBinding(IASTName name) {
+ try {
+ ILanguage language = name.getTranslationUnit().getLanguage();
+ return getLinkage(language).resolveBinding(name);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+
return null;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java
index 4acb08cde71..8fc671b72f2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java
@@ -87,4 +87,6 @@ public abstract class PDOMLinkage extends PDOMNode {
public abstract PDOMBinding getBinding(int record) throws CoreException;
+ public abstract PDOMBinding resolveBinding(IASTName name) throws CoreException;
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMTranslationUnit.java
index 99a5b3ebaf0..b64e651f627 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMTranslationUnit.java
@@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IScope2;
+import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ParserLanguage;
/**
@@ -160,5 +161,9 @@ public class PDOMTranslationUnit implements IASTTranslationUnit {
public IScope2 getScope(IASTNode child, ASTNodeProperty childProperty) {
throw new PDOMNotImplementedError();
}
+
+ public ILanguage getLanguage() {
+ throw new PDOMNotImplementedError();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
index 84e1ffa0df8..cad6925eca9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
@@ -178,4 +178,8 @@ public class PDOMCLinkage extends PDOMLinkage {
return null;
}
+ public PDOMBinding resolveBinding(IASTName name) throws CoreException {
+ return null;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
index 54d989a4fca..e90b280f1de 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java
@@ -11,18 +11,22 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
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.ICPPClassType;
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.ICPPMethod;
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMMember;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
@@ -32,7 +36,7 @@ import org.eclipse.core.runtime.CoreException;
* @author Doug Schaefer
*
*/
-public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType {
+public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType, ICPPClassScope {
protected static final int RECORD_SIZE = PDOMMemberOwner.RECORD_SIZE + 0;
@@ -97,7 +101,7 @@ public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType {
}
public IScope getCompositeScope() throws DOMException {
- throw new PDOMNotImplementedError();
+ return this;
}
public int getKey() throws DOMException {
@@ -116,4 +120,63 @@ public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType {
throw new PDOMNotImplementedError();
}
+ public ICPPClassType getClassType() {
+ throw new PDOMNotImplementedError();
+ }
+
+ public ICPPMethod[] getImplicitMethods() {
+ throw new PDOMNotImplementedError();
+ }
+
+ public void addBinding(IBinding binding) throws DOMException {
+ throw new PDOMNotImplementedError();
+ }
+
+ public void addName(IASTName name) throws DOMException {
+ throw new PDOMNotImplementedError();
+ }
+
+ public IBinding[] find(String name) throws DOMException {
+ throw new PDOMNotImplementedError();
+ }
+
+ public void flushCache() throws DOMException {
+ throw new PDOMNotImplementedError();
+ }
+
+ public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
+ try {
+ PDOMMember[] matches = findMembers(name.toCharArray());
+ // TODO - need to check for overloads
+ return matches[0];
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ return null;
+ }
+ }
+
+ public IScope getParent() throws DOMException {
+ throw new PDOMNotImplementedError();
+ }
+
+ public IASTNode getPhysicalNode() throws DOMException {
+ throw new PDOMNotImplementedError();
+ }
+
+ public IASTName getScopeName() throws DOMException {
+ throw new PDOMNotImplementedError();
+ }
+
+ public boolean isFullyCached() throws DOMException {
+ return true;
+ }
+
+ public void removeBinding(IBinding binding) throws DOMException {
+ throw new PDOMNotImplementedError();
+ }
+
+ public void setFullyCached(boolean b) throws DOMException {
+ throw new PDOMNotImplementedError();
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPField.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPField.java
index 7515a347893..c65fe749eca 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPField.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPField.java
@@ -17,9 +17,9 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMember;
-import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
@@ -52,7 +52,7 @@ public class PDOMCPPField extends PDOMMember implements ICPPField {
}
public String[] getQualifiedName() throws DOMException {
- throw new PDOMNotImplementedError();
+ return CPPVisitor.getQualifiedName( this );
}
public char[][] getQualifiedNameCharArray() throws DOMException {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
index 5ee64a1bd10..b21d585cee8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
@@ -11,7 +11,11 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
@@ -112,43 +116,43 @@ public class PDOMCPPLinkage extends PDOMLinkage {
}
private static final class FindBinding extends PDOMNode.NodeVisitor {
- private final IBinding binding;
- public PDOMBinding pdomBinding;
- public FindBinding(PDOMDatabase pdom, IBinding binding) {
- super(pdom, binding.getNameCharArray());
- this.binding = binding;
+ PDOMBinding pdomBinding;
+ final int desiredType;
+ public FindBinding(PDOMDatabase pdom, char[] name, int desiredType) {
+ super(pdom, name);
+ this.desiredType = desiredType;
}
public boolean visit(int record) throws CoreException {
if (record == 0)
return true;
PDOMBinding tBinding = pdom.getBinding(record);
if (!tBinding.hasName(name))
+ // no more bindings with our desired name
return false;
- switch (tBinding.getBindingType()) {
- case CPPVARIABLE:
- if (binding instanceof ICPPVariable)
- pdomBinding = tBinding;
- break;
- case CPPFUNCTION:
- if (binding instanceof ICPPFunction)
- pdomBinding = tBinding;
- break;
- case CPPCLASSTYPE:
- if (binding instanceof ICPPClassType)
- pdomBinding = tBinding;
- break;
- case CPPFIELD:
- if (binding instanceof ICPPField)
- pdomBinding = tBinding;
- break;
- case CPPMETHOD:
- if (binding instanceof ICPPMethod)
- pdomBinding = tBinding;
- break;
- }
- return pdomBinding == null;
+ if (tBinding.getBindingType() != desiredType)
+ // wrong type, try again
+ return true;
+
+ // got it
+ pdomBinding = tBinding;
+ return false;
}
}
+
+ public int getBindingType(IBinding binding) {
+ if (binding instanceof ICPPVariable)
+ return CPPVARIABLE;
+ else if (binding instanceof ICPPFunction)
+ return CPPFUNCTION;
+ else if (binding instanceof ICPPClassType)
+ return CPPCLASSTYPE;
+ else if (binding instanceof ICPPField)
+ return CPPFIELD;
+ else if (binding instanceof ICPPMethod)
+ return CPPMETHOD;
+ else
+ return 0;
+ }
public PDOMBinding adaptBinding(IBinding binding) throws CoreException {
if (binding == null)
@@ -156,7 +160,7 @@ public class PDOMCPPLinkage extends PDOMLinkage {
PDOMNode parent = getParent(binding);
if (parent == this) {
- FindBinding visitor = new FindBinding(pdom, binding);
+ FindBinding visitor = new FindBinding(pdom, binding.getNameCharArray(), getBindingType(binding));
getIndex().visit(visitor);
return visitor.pdomBinding;
} else if (parent instanceof PDOMMemberOwner) {
@@ -187,4 +191,27 @@ public class PDOMCPPLinkage extends PDOMLinkage {
return null;
}
+
+ public PDOMBinding resolveBinding(IASTName name) throws CoreException {
+ IASTNode parent = name.getParent();
+ if (parent instanceof IASTIdExpression) {
+ // reference
+ IASTNode eParent = parent.getParent();
+ if (eParent instanceof IASTFunctionCallExpression) {
+ FindBinding visitor = new FindBinding(pdom, name.toCharArray(), CPPFUNCTION);
+ getIndex().visit(visitor);
+ return visitor.pdomBinding;
+ } else {
+ FindBinding visitor = new FindBinding(pdom, name.toCharArray(), CPPVARIABLE);
+ getIndex().visit(visitor);
+ return visitor.pdomBinding;
+ }
+ } else if (parent instanceof IASTNamedTypeSpecifier) {
+ FindBinding visitor = new FindBinding(pdom, name.toCharArray(), CPPCLASSTYPE);
+ getIndex().visit(visitor);
+ return visitor.pdomBinding;
+ }
+ return null;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java
index 2b2dc8543d1..bb23cae5a74 100644
--- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java
+++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java
@@ -52,9 +52,12 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
import org.eclipse.cdt.core.search.ICSearchConstants.SearchFor;
import org.eclipse.cdt.internal.core.index.domsourceindexer.IndexVisitorUtil;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.content.IContentType;
@@ -356,6 +359,25 @@ public class DOMSearchUtil {
&& binding.getScope() instanceof ICPPClassScope) {
binding = ((ICPPClassScope)binding.getScope()).getClassType();
names = getNames(tu, binding, limitTo);
+ } else if (binding instanceof PDOMBinding) {
+ try {
+ ArrayList pdomNames = new ArrayList();
+ // First decls
+ PDOMName name = ((PDOMBinding)binding).getFirstDeclaration();
+ while (name != null) {
+ pdomNames.add(name);
+ name = name.getNextInBinding();
+ }
+ // Next defs
+ name = ((PDOMBinding)binding).getFirstDefinition();
+ while (name != null) {
+ pdomNames.add(name);
+ name = name.getNextInBinding();
+ }
+ names = (IASTName[])pdomNames.toArray(new IASTName[pdomNames.size()]);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
}
} catch (DOMException e) {}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
index aa235dc4b1c..7ba2c62f2eb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
@@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserUtil;
@@ -40,6 +41,7 @@ import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -125,13 +127,20 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
IWorkingCopy workingCopy = (IWorkingCopy)fEditor.getInputCElement();
IFile resourceFile = (IFile)workingCopy.getResource();
project = new CProject(null, resourceFile.getProject());
- IPDOM pdom = null; //PDOM.getPDOM(resourceFile.getProject());
+ IPDOM pdom = PDOM.getPDOM(resourceFile.getProject());
try {
- if (pdom != null)
- tu = CDOM.getInstance().getASTService().getTranslationUnit(
- resourceFile,
- pdom.getCodeReaderFactory(workingCopy));
- else
+ if (pdom != null) {
+ try {
+ ILanguage language = workingCopy.getLanguage();
+ tu = language.getTranslationUnit(workingCopy,
+ ILanguage.AST_USE_INDEX |
+ ILanguage.AST_SKIP_INDEXED_HEADERS);
+ } catch (CoreException e) {
+ CUIPlugin.getDefault().log(e);
+ operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
+ return;
+ }
+ } else
tu = CDOM.getInstance().getASTService().getTranslationUnit(
resourceFile);
} catch (IASTServiceProvider.UnsupportedDialectException e) {

Back to the top