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

- fix for bug #66108 (C++ browser cannot show members of class)

- TypeParser now uses resource to get scanner info
This commit is contained in:
Alain Magloire 2004-06-21 18:48:03 +00:00
parent 3c69bad0a7
commit b16d7061a2
6 changed files with 45 additions and 10 deletions

View file

@ -1,3 +1,8 @@
2004-06-21 Chris Wiebe
- fix for bug #66108 (C++ browser cannot show members of class)
- TypeParser now uses resource to get scanner info
2004-06-17 Alain Magloire
Changes from Chris Wiebe to deal

View file

@ -145,6 +145,11 @@ public interface ITypeInfo extends Comparable {
*/
public ITypeReference getResolvedReference();
/**
* Returns the corresponding CElement or <code>null</code> if not found.
*/
public ICElement getCElement();
/**
* Returns true if the type can be substituted.
*/

View file

@ -59,9 +59,10 @@ public interface ITypeReference {
public int getLength();
/**
* Returns the CElement located at the stored offset and length.
* Returns the CElements located at the stored offset and length,
* or <code>null</code> if not found.
*/
public ICElement getCElement();
public ICElement[] getCElements();
/**
* Returns a translation unit for this location.

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.core.browser;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITypeDef;
import org.eclipse.cdt.internal.core.browser.cache.ITypeCache;
import org.eclipse.cdt.internal.core.browser.util.ArrayUtil;
import org.eclipse.core.resources.IProject;
@ -24,7 +25,7 @@ public class TypeInfo implements ITypeInfo
protected int fSourceRefsCount = 0;
protected final static int INITIAL_REFS_SIZE = 1;
protected final static int REFS_GROW_BY = 10;
protected final static int REFS_GROW_BY = 2;
protected final static ITypeInfo[] EMPTY_TYPES = new ITypeInfo[0];
public TypeInfo(int elementType, IQualifiedTypeName typeName) {
@ -53,6 +54,29 @@ public class TypeInfo implements ITypeInfo
}
return null;
}
public ICElement getCElement() {
ITypeReference ref = getResolvedReference();
if (ref != null) {
ICElement[] elems = ref.getCElements();
if (elems.length > 1) {
for (int i = 0; i < elems.length; ++i) {
ICElement elem = elems[i];
if (elem.getElementType() == fElementType && elem.getElementName().equals(getName())) {
//TODO should check fully qualified name
return elem;
}
if (elem instanceof ITypeDef && ((ITypeDef)elem).getTypeName().equals(getName())) {
//TODO should check fully qualified name
return elem;
}
}
} else if (elems.length == 1) {
return elems[0];
}
}
return null;
}
public ITypeReference getResolvedReference() {
for (int i = 0; i < fSourceRefsCount; ++i) {

View file

@ -173,11 +173,11 @@ public class TypeReference implements ITypeReference {
return null;
}
public ICElement getCElement() {
public ICElement[] getCElements() {
ITranslationUnit unit = getTranslationUnit();
if (unit != null) {
try {
return unit.getElementAtOffset(fOffset);
return unit.getElementsAtOffset(fOffset);
} catch (CModelException e) {
}
}

View file

@ -284,15 +284,15 @@ public class TypeParser implements ISourceElementRequestor {
CodeReader reader = null;
Object stackObject = null;
IResource resource = null;
if (workingCopy != null) {
reader = createWorkingCopyReader(workingCopy);
IResource resource = workingCopy.getResource();
resource = workingCopy.getResource();
if (resource != null) {
path = resource.getLocation();
}
stackObject = workingCopy;
} else {
IResource resource = null;
IWorkspace workspace = CCorePlugin.getWorkspace();
if (workspace != null) {
IWorkspaceRoot wsRoot = workspace.getRoot();
@ -314,7 +314,7 @@ public class TypeParser implements ISourceElementRequestor {
fResourceStack.clear();
fScopeStack.clear();
fResourceStack.push(stackObject);
parseContents(path, project, reader, language, progressMonitor);
parseContents(path, resource, project, reader, language, progressMonitor);
fResourceStack.pop();
}
} finally {
@ -393,7 +393,7 @@ public class TypeParser implements ISourceElementRequestor {
return reader;
}
private void parseContents(IPath realPath, IProject project, CodeReader reader, ParserLanguage language, IProgressMonitor progressMonitor) throws InterruptedException {
private void parseContents(IPath realPath, IResource resource, IProject project, CodeReader reader, ParserLanguage language, IProgressMonitor progressMonitor) throws InterruptedException {
IScannerInfo scanInfo = null;
if (project != null) {
@ -401,7 +401,7 @@ public class TypeParser implements ISourceElementRequestor {
try {
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
if (provider != null) {
IScannerInfo buildScanInfo = provider.getScannerInformation(project);
IScannerInfo buildScanInfo = provider.getScannerInformation(resource != null ? resource : project);
if (buildScanInfo != null)
scanInfo = new ScannerInfo(buildScanInfo.getDefinedSymbols(), buildScanInfo.getIncludePaths());
}