mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 12:25:35 +02:00
PDOM - Started adding elements for C. Fixed index view so that it updates, despite a current bug in the JFace Virtual Trees that prohibits nice updating.
This commit is contained in:
parent
d440fd11f0
commit
0623b903f8
10 changed files with 538 additions and 63 deletions
|
@ -14,9 +14,7 @@ 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.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
|
@ -36,11 +34,12 @@ import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
|||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
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.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
@ -50,10 +49,18 @@ import org.eclipse.core.runtime.PlatformObject;
|
|||
public class GCCLanguage extends PlatformObject implements ILanguage {
|
||||
|
||||
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
|
||||
// Must match the id in the extension
|
||||
public static final String ID = CCorePlugin.PLUGIN_ID + ".gcc"; //$NON-NLS-1$
|
||||
|
||||
public String getId() {
|
||||
// Must match the id in the extension
|
||||
return CCorePlugin.PLUGIN_ID + ".gcc"; //$NON-NLS-1$
|
||||
return ID;
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == IPDOMLinkageFactory.class)
|
||||
return new PDOMCLinkageFactory();
|
||||
else
|
||||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(ITranslationUnit tu, int style) {
|
||||
|
@ -71,8 +78,13 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
|
|||
|
||||
// TODO - use different factories if we are working copy, or style
|
||||
// is skip headers.
|
||||
ICodeReaderFactory fileCreator = SavedCodeReaderFactory.getInstance();
|
||||
CodeReader reader = fileCreator.createCodeReaderForTranslationUnit(tu.getElementName());
|
||||
ICodeReaderFactory fileCreator;
|
||||
if ((style & ILanguage.AST_SKIP_INDEXED_HEADERS) != 0)
|
||||
fileCreator = new PDOMCodeReaderFactory((PDOMDatabase)tu.getCProject().getIndex());
|
||||
else
|
||||
fileCreator = SavedCodeReaderFactory.getInstance();
|
||||
|
||||
CodeReader reader = fileCreator.createCodeReaderForTranslationUnit(tu);
|
||||
if( reader == null )
|
||||
return null;
|
||||
|
||||
|
@ -98,16 +110,4 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
|
|||
return null;
|
||||
}
|
||||
|
||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, int languageId, IASTName name) throws CoreException {
|
||||
IBinding binding = name.resolveBinding();
|
||||
if (binding == null)
|
||||
return null;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, int record) throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,10 +14,7 @@ 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.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
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.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
|
@ -32,12 +29,6 @@ import org.eclipse.cdt.core.parser.ParserUtil;
|
|||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPField;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
|
||||
|
@ -46,15 +37,9 @@ import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfigurat
|
|||
import org.eclipse.cdt.internal.core.pdom.PDOMCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPClassType;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPField;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPFunction;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPVariable;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
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.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCField extends PDOMMember implements IField {
|
||||
|
||||
public PDOMCField(PDOMDatabase pdom, PDOMMemberOwner parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name, PDOMCLinkage.CFIELD);
|
||||
}
|
||||
|
||||
public PDOMCField(PDOMDatabase pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isStatic() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isExtern() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isAuto() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isRegister() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCFunction extends PDOMBinding implements IFunction {
|
||||
|
||||
public PDOMCFunction(PDOMDatabase pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name, PDOMCLinkage.CFUNCTION);
|
||||
}
|
||||
|
||||
public PDOMCFunction(PDOMDatabase pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
public IParameter[] getParameters() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IScope getFunctionScope() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IFunctionType getType() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isStatic() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isExtern() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isAuto() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isRegister() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isInline() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean takesVarArgs() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
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.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMCLinkage extends PDOMLinkage {
|
||||
|
||||
public PDOMCLinkage(PDOMDatabase pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
public PDOMCLinkage(PDOMDatabase pdom) throws CoreException {
|
||||
super(pdom, GCCLanguage.ID, "C".toCharArray());
|
||||
}
|
||||
|
||||
public static final int CVARIABLE = 1;
|
||||
public static final int CFUNCTION = 2;
|
||||
public static final int CSTRUCTURE = 3;
|
||||
public static final int CFIELD = 4;
|
||||
|
||||
public PDOMNode getParent(IBinding binding) throws CoreException {
|
||||
PDOMNode parent = this;
|
||||
|
||||
IScope scope = binding.getScope();
|
||||
if (scope != null) {
|
||||
IASTName scopeName = scope.getScopeName();
|
||||
if (scopeName != null) {
|
||||
IBinding scopeBinding = scopeName.resolveBinding();
|
||||
PDOMBinding scopePDOMBinding = (PDOMBinding)scopeBinding.getAdapter(PDOMBinding.class);
|
||||
if (scopePDOMBinding != null)
|
||||
parent = scopePDOMBinding;
|
||||
}
|
||||
}
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
public PDOMBinding addName(IASTName name) throws CoreException {
|
||||
if (name == null || name.toCharArray().length == 0)
|
||||
return null;
|
||||
|
||||
IBinding binding = name.resolveBinding();
|
||||
if (binding == null || binding instanceof IProblemBinding)
|
||||
return null;
|
||||
|
||||
PDOMBinding pdomBinding = (PDOMBinding)binding.getAdapter(PDOMBinding.class);
|
||||
if (pdomBinding == null) {
|
||||
PDOMNode parent = getParent(binding);
|
||||
|
||||
if (binding instanceof IParameter)
|
||||
; // skip parameters
|
||||
else if (binding instanceof IField) { // must be before IVariable
|
||||
if (parent instanceof PDOMMemberOwner)
|
||||
pdomBinding = new PDOMCField(pdom, (PDOMMemberOwner)parent, name);
|
||||
} else if (binding instanceof IVariable)
|
||||
pdomBinding = new PDOMCVariable(pdom, parent, name);
|
||||
else if (binding instanceof IFunction)
|
||||
pdomBinding = new PDOMCFunction(pdom, parent, name);
|
||||
else if (binding instanceof ICompositeType)
|
||||
pdomBinding = new PDOMCStructure(pdom, parent, name);
|
||||
}
|
||||
|
||||
if (pdomBinding != null)
|
||||
new PDOMName(pdom, name, pdomBinding);
|
||||
|
||||
return pdomBinding;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
public boolean visit(int record) throws CoreException {
|
||||
if (record == 0)
|
||||
return true;
|
||||
PDOMBinding tBinding = pdom.getBinding(record);
|
||||
if (!tBinding.hasName(name))
|
||||
return false;
|
||||
switch (tBinding.getBindingType()) {
|
||||
case CVARIABLE:
|
||||
if (binding instanceof IVariable)
|
||||
pdomBinding = tBinding;
|
||||
break;
|
||||
case CFUNCTION:
|
||||
if (binding instanceof IFunction)
|
||||
pdomBinding = tBinding;
|
||||
break;
|
||||
case CSTRUCTURE:
|
||||
if (binding instanceof ICompositeType)
|
||||
pdomBinding = tBinding;
|
||||
break;
|
||||
case CFIELD:
|
||||
if (binding instanceof IField)
|
||||
pdomBinding = tBinding;
|
||||
break;
|
||||
}
|
||||
return pdomBinding == null;
|
||||
}
|
||||
}
|
||||
|
||||
public PDOMBinding adaptBinding(IBinding binding) throws CoreException {
|
||||
PDOMNode parent = getParent(binding);
|
||||
if (parent == this) {
|
||||
FindBinding visitor = new FindBinding(pdom, binding);
|
||||
getIndex().visit(visitor);
|
||||
return visitor.pdomBinding;
|
||||
} else if (parent instanceof PDOMMemberOwner) {
|
||||
PDOMMemberOwner owner = (PDOMMemberOwner)parent;
|
||||
PDOMMember[] members = owner.findMembers(binding.getNameCharArray());
|
||||
if (members.length > 0)
|
||||
return members[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage#getBinding(int)
|
||||
*/
|
||||
public PDOMBinding getBinding(int record) throws CoreException {
|
||||
if (record == 0)
|
||||
return null;
|
||||
|
||||
switch (PDOMBinding.getBindingType(pdom, record)) {
|
||||
case CVARIABLE:
|
||||
return new PDOMCVariable(pdom, record);
|
||||
case CFUNCTION:
|
||||
return new PDOMCFunction(pdom, record);
|
||||
case CSTRUCTURE:
|
||||
return new PDOMCStructure(pdom, record);
|
||||
case CFIELD:
|
||||
return new PDOMCField(pdom, record);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMCLinkageFactory implements IPDOMLinkageFactory {
|
||||
|
||||
public PDOMLinkage getLinkage(PDOMDatabase pdom, int record) {
|
||||
return new PDOMCLinkage(pdom, record);
|
||||
}
|
||||
|
||||
public PDOMLinkage createLinkage(PDOMDatabase pdom) throws CoreException {
|
||||
return new PDOMCLinkage(pdom);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
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.internal.core.pdom.PDOMDatabase;
|
||||
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;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCStructure extends PDOMMemberOwner implements ICompositeType {
|
||||
|
||||
public PDOMCStructure(PDOMDatabase pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name, PDOMCLinkage.CSTRUCTURE);
|
||||
}
|
||||
|
||||
public PDOMCStructure(PDOMDatabase pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public int getKey() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IField[] getFields() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IField findField(String name) throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IScope getCompositeScope() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCVariable extends PDOMBinding implements IVariable {
|
||||
|
||||
public PDOMCVariable(PDOMDatabase pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name, PDOMCLinkage.CVARIABLE);
|
||||
}
|
||||
|
||||
public PDOMCVariable(PDOMDatabase pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isStatic() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isExtern() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isAuto() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isRegister() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
}
|
|
@ -88,9 +88,7 @@ public class PDOMCPPLinkage extends PDOMLinkage {
|
|||
if (pdomBinding == null) {
|
||||
PDOMNode parent = getParent(binding);
|
||||
|
||||
if (binding instanceof PDOMBinding)
|
||||
pdomBinding = (PDOMBinding)binding;
|
||||
else if (binding instanceof CPPField && parent instanceof PDOMCPPClassType)
|
||||
if (binding instanceof CPPField && parent instanceof PDOMCPPClassType)
|
||||
pdomBinding = new PDOMCPPField(pdom, (PDOMCPPClassType)parent, name);
|
||||
else if (binding instanceof CPPVariable) {
|
||||
if (!(binding.getScope() instanceof CPPBlockScope))
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
package org.eclipse.cdt.internal.ui.indexview;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.PDOM;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
|
@ -216,6 +216,9 @@ public class IndexView extends ViewPart implements PDOMDatabase.IListener {
|
|||
else if (element instanceof ICPPClassType)
|
||||
return CUIPlugin.getImageDescriptorRegistry().get(
|
||||
CElementImageProvider.getClassImageDescriptor());
|
||||
else if (element instanceof ICompositeType)
|
||||
return CUIPlugin.getImageDescriptorRegistry().get(
|
||||
CElementImageProvider.getStructImageDescriptor());
|
||||
else if (element instanceof IBinding)
|
||||
return PlatformUI.getWorkbench().getSharedImages().getImage(
|
||||
ISharedImages.IMG_OBJ_ELEMENT);
|
||||
|
@ -407,33 +410,52 @@ public class IndexView extends ViewPart implements PDOMDatabase.IListener {
|
|||
}
|
||||
|
||||
public void handleChange(PDOMDatabase pdom) {
|
||||
try {
|
||||
final ICModel model = (ICModel)viewer.getInput();
|
||||
if (model == null)
|
||||
return;
|
||||
ICProject[] cprojects = model.getCProjects();
|
||||
int n = -1;
|
||||
for (int i = 0; i < cprojects.length; ++i) {
|
||||
final ICProject cproject = cprojects[i];
|
||||
IPDOM pp = PDOM.getPDOM(cproject.getProject());
|
||||
if (pp != null) {
|
||||
++n;
|
||||
if (pp == pdom){
|
||||
final int index = n;
|
||||
viewer.getControl().getDisplay().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
viewer.replace(model, index, cproject);
|
||||
viewer.getControl().redraw();
|
||||
viewer.getControl().update();
|
||||
};
|
||||
});
|
||||
return;
|
||||
viewer.getControl().getDisplay().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
ICModel model = CoreModel.getDefault().getCModel();
|
||||
viewer.setInput(model);
|
||||
try {
|
||||
ICProject[] cprojects = model.getCProjects();
|
||||
int n = 0;
|
||||
for (int i = 0; i < cprojects.length; ++i) {
|
||||
PDOMDatabase pdom = (PDOMDatabase)PDOM.getPDOM(cprojects[i].getProject());
|
||||
if (pdom != null)
|
||||
++n;
|
||||
}
|
||||
viewer.setChildCount(model, n);
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
});
|
||||
|
||||
// try {
|
||||
// final ICModel model = (ICModel)viewer.getInput();
|
||||
// if (model == null)
|
||||
// return;
|
||||
// ICProject[] cprojects = model.getCProjects();
|
||||
// int n = -1;
|
||||
// for (int i = 0; i < cprojects.length; ++i) {
|
||||
// final ICProject cproject = cprojects[i];
|
||||
// IPDOM pp = PDOM.getPDOM(cproject.getProject());
|
||||
// if (pp != null) {
|
||||
// ++n;
|
||||
// if (pp == pdom){
|
||||
// final int index = n;
|
||||
// viewer.getControl().getDisplay().asyncExec(new Runnable() {
|
||||
// public void run() {
|
||||
// viewer.replace(model, index, cproject);
|
||||
// viewer.getControl().redraw();
|
||||
// viewer.getControl().update();
|
||||
// };
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (CoreException e) {
|
||||
// CUIPlugin.getDefault().log(e);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue