mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 02:05:39 +02:00
Added C++ functions to the list of PDOM Bindings.
This commit is contained in:
parent
3851ae5ee1
commit
e10de4fc65
3 changed files with 133 additions and 7 deletions
|
@ -14,7 +14,10 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
/**
|
||||
* This is the general purpose exception that is thrown for resolving semantic
|
||||
|
@ -22,7 +25,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
|||
*
|
||||
* @author aniefer
|
||||
*/
|
||||
public class DOMException extends Exception {
|
||||
public class DOMException extends CoreException {
|
||||
|
||||
private static final long serialVersionUID = 0;
|
||||
|
||||
IProblemBinding problemBinding;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +37,8 @@ public class DOMException extends Exception {
|
|||
*
|
||||
*/
|
||||
public DOMException(IProblemBinding problem) {
|
||||
super(CPPSemantics.EMPTY_NAME);
|
||||
super(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID,
|
||||
0, "DOMException", new Exception()));
|
||||
problemBinding = problem;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ 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.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
|
@ -31,7 +32,10 @@ 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.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;
|
||||
|
@ -40,6 +44,7 @@ import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfigur
|
|||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
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.cpp.PDOMCPPFunction;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPVariable;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -100,16 +105,24 @@ public class GPPLanguage implements ILanguage {
|
|||
|
||||
// Binding types
|
||||
public static final int CPPVARIABLE = 1;
|
||||
public static final int CPPFUNCTION = 2;
|
||||
|
||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, IASTName name) throws CoreException {
|
||||
IBinding binding = name.resolveBinding();
|
||||
if (binding == null)
|
||||
return null;
|
||||
|
||||
if (binding instanceof CPPField)
|
||||
|
||||
if (binding instanceof CPPField) {
|
||||
return null;
|
||||
if (binding instanceof CPPVariable)
|
||||
return new PDOMCPPVariable(pdom, name, (CPPVariable)binding);
|
||||
} else if (binding instanceof CPPVariable) {
|
||||
IScope scope = binding.getScope();
|
||||
if (!(scope instanceof CPPBlockScope))
|
||||
return new PDOMCPPVariable(pdom, name, (CPPVariable)binding);
|
||||
} else if (binding instanceof CPPMethod) {
|
||||
return null;
|
||||
} else if (binding instanceof CPPFunction) {
|
||||
return new PDOMCPPFunction(pdom, name, (CPPFunction)binding);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -118,6 +131,8 @@ public class GPPLanguage implements ILanguage {
|
|||
switch (binding.getBindingType()) {
|
||||
case CPPVARIABLE:
|
||||
return new PDOMCPPVariable(pdom, binding.getRecord());
|
||||
case CPPFUNCTION:
|
||||
return new PDOMCPPFunction(pdom, binding.getRecord());
|
||||
}
|
||||
|
||||
return binding;
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 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.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
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.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||
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.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPFunction extends PDOMBinding implements ICPPFunction {
|
||||
|
||||
/**
|
||||
* @param pdom
|
||||
* @param name
|
||||
* @param language
|
||||
* @param type
|
||||
* @throws CoreException
|
||||
*/
|
||||
public PDOMCPPFunction(PDOMDatabase pdom, IASTName name, CPPFunction binding) throws CoreException {
|
||||
super(pdom, name, GPPLanguage.GPP_ID, GPPLanguage.CPPFUNCTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pdom
|
||||
* @param bindingRecord
|
||||
*/
|
||||
public PDOMCPPFunction(PDOMDatabase pdom, int bindingRecord) {
|
||||
super(pdom, bindingRecord);
|
||||
}
|
||||
|
||||
public boolean isInline() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isMutable() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IScope getFunctionScope() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IParameter[] getParameters() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IFunctionType getType() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isAuto() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isExtern() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isRegister() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isStatic() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean takesVarArgs() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue