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:
parent
3c69bad0a7
commit
b16d7061a2
6 changed files with 45 additions and 10 deletions
|
@ -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
|
2004-06-17 Alain Magloire
|
||||||
|
|
||||||
Changes from Chris Wiebe to deal
|
Changes from Chris Wiebe to deal
|
||||||
|
|
|
@ -145,6 +145,11 @@ public interface ITypeInfo extends Comparable {
|
||||||
*/
|
*/
|
||||||
public ITypeReference getResolvedReference();
|
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.
|
* Returns true if the type can be substituted.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -59,9 +59,10 @@ public interface ITypeReference {
|
||||||
public int getLength();
|
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.
|
* Returns a translation unit for this location.
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.core.browser;
|
package org.eclipse.cdt.core.browser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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.cache.ITypeCache;
|
||||||
import org.eclipse.cdt.internal.core.browser.util.ArrayUtil;
|
import org.eclipse.cdt.internal.core.browser.util.ArrayUtil;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -24,7 +25,7 @@ public class TypeInfo implements ITypeInfo
|
||||||
protected int fSourceRefsCount = 0;
|
protected int fSourceRefsCount = 0;
|
||||||
|
|
||||||
protected final static int INITIAL_REFS_SIZE = 1;
|
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];
|
protected final static ITypeInfo[] EMPTY_TYPES = new ITypeInfo[0];
|
||||||
|
|
||||||
public TypeInfo(int elementType, IQualifiedTypeName typeName) {
|
public TypeInfo(int elementType, IQualifiedTypeName typeName) {
|
||||||
|
@ -53,6 +54,29 @@ public class TypeInfo implements ITypeInfo
|
||||||
}
|
}
|
||||||
return null;
|
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() {
|
public ITypeReference getResolvedReference() {
|
||||||
for (int i = 0; i < fSourceRefsCount; ++i) {
|
for (int i = 0; i < fSourceRefsCount; ++i) {
|
||||||
|
|
|
@ -173,11 +173,11 @@ public class TypeReference implements ITypeReference {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICElement getCElement() {
|
public ICElement[] getCElements() {
|
||||||
ITranslationUnit unit = getTranslationUnit();
|
ITranslationUnit unit = getTranslationUnit();
|
||||||
if (unit != null) {
|
if (unit != null) {
|
||||||
try {
|
try {
|
||||||
return unit.getElementAtOffset(fOffset);
|
return unit.getElementsAtOffset(fOffset);
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,15 +284,15 @@ public class TypeParser implements ISourceElementRequestor {
|
||||||
CodeReader reader = null;
|
CodeReader reader = null;
|
||||||
Object stackObject = null;
|
Object stackObject = null;
|
||||||
|
|
||||||
|
IResource resource = null;
|
||||||
if (workingCopy != null) {
|
if (workingCopy != null) {
|
||||||
reader = createWorkingCopyReader(workingCopy);
|
reader = createWorkingCopyReader(workingCopy);
|
||||||
IResource resource = workingCopy.getResource();
|
resource = workingCopy.getResource();
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
path = resource.getLocation();
|
path = resource.getLocation();
|
||||||
}
|
}
|
||||||
stackObject = workingCopy;
|
stackObject = workingCopy;
|
||||||
} else {
|
} else {
|
||||||
IResource resource = null;
|
|
||||||
IWorkspace workspace = CCorePlugin.getWorkspace();
|
IWorkspace workspace = CCorePlugin.getWorkspace();
|
||||||
if (workspace != null) {
|
if (workspace != null) {
|
||||||
IWorkspaceRoot wsRoot = workspace.getRoot();
|
IWorkspaceRoot wsRoot = workspace.getRoot();
|
||||||
|
@ -314,7 +314,7 @@ public class TypeParser implements ISourceElementRequestor {
|
||||||
fResourceStack.clear();
|
fResourceStack.clear();
|
||||||
fScopeStack.clear();
|
fScopeStack.clear();
|
||||||
fResourceStack.push(stackObject);
|
fResourceStack.push(stackObject);
|
||||||
parseContents(path, project, reader, language, progressMonitor);
|
parseContents(path, resource, project, reader, language, progressMonitor);
|
||||||
fResourceStack.pop();
|
fResourceStack.pop();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -393,7 +393,7 @@ public class TypeParser implements ISourceElementRequestor {
|
||||||
return reader;
|
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;
|
IScannerInfo scanInfo = null;
|
||||||
|
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
|
@ -401,7 +401,7 @@ public class TypeParser implements ISourceElementRequestor {
|
||||||
try {
|
try {
|
||||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
|
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
IScannerInfo buildScanInfo = provider.getScannerInformation(project);
|
IScannerInfo buildScanInfo = provider.getScannerInformation(resource != null ? resource : project);
|
||||||
if (buildScanInfo != null)
|
if (buildScanInfo != null)
|
||||||
scanInfo = new ScannerInfo(buildScanInfo.getDefinedSymbols(), buildScanInfo.getIncludePaths());
|
scanInfo = new ScannerInfo(buildScanInfo.getDefinedSymbols(), buildScanInfo.getIncludePaths());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue