本文整理匯總了Java中org.eclipse.jdt.core.dom.SingleVariableDeclaration.resolveBinding方法的典型用法代碼示例。如果您正苦於以下問題:Java SingleVariableDeclaration.resolveBinding方法的具體用法?Java SingleVariableDeclaration.resolveBinding怎麽用?Java SingleVariableDeclaration.resolveBinding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.SingleVariableDeclaration
的用法示例。
在下文中一共展示了SingleVariableDeclaration.resolveBinding方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ensureParameterFromSingleVariableDeclaration
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
public Parameter ensureParameterFromSingleVariableDeclaration(SingleVariableDeclaration variableDeclaration,
Method method) {
String name = variableDeclaration.getName().toString();
String qualifiedName = Famix.qualifiedNameOf(method) + NAME_SEPARATOR + name;
if (parameters.has(qualifiedName))
return parameters.named(qualifiedName);
Parameter parameter = new Parameter();
parameters.add(qualifiedName, parameter);
parameter.setName(name);
parameter.setParentBehaviouralEntity(method);
parameter.setDeclaredType(ensureTypeFromDomType(variableDeclaration.getType()));
IVariableBinding binding = variableDeclaration.resolveBinding();
if (binding != null) {
createAnnotationInstancesToEntityFromAnnotationBinding(parameter, binding.getAnnotations());
//We only recover the final modifier
if (Modifier.isFinal(binding.getModifiers())) parameter.addModifiers("final");
}
return parameter;
}
示例2: isExceptionCaught
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
boolean isExceptionCaught(ITypeBinding excpetionType) {
for (Iterator<List<CatchClause>> exceptions= fExceptionStack.iterator(); exceptions.hasNext(); ) {
for (Iterator<CatchClause> catchClauses= exceptions.next().iterator(); catchClauses.hasNext(); ) {
SingleVariableDeclaration caughtException= catchClauses.next().getException();
IVariableBinding binding= caughtException.resolveBinding();
if (binding == null) {
continue;
}
ITypeBinding caughtype= binding.getType();
while (caughtype != null) {
if (caughtype == excpetionType) {
return true;
}
caughtype= caughtype.getSuperclass();
}
}
}
return false;
}
示例3: extractParametersFromSource
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
private void extractParametersFromSource(List<Variable> parametersVarList,
IMethod javaElement) {
Option<MethodDeclaration> mDecl = WorkspaceUtilities.getMethodDeclFromModel(javaElement);
MethodDeclaration mmDecl = mDecl.unwrap();
List<SingleVariableDeclaration> parameters = mmDecl.parameters();
for (SingleVariableDeclaration param : parameters) {
IVariableBinding paramBinding = param.resolveBinding();
if(!paramBinding.getType().isPrimitive()){
Variable paramVariable = this.tm.getVariableFromBindingKey(paramBinding.getKey());
if(paramVariable!=null){
parametersVarList.add(paramVariable);
}
}
}
}
示例4: isExceptionCaught
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
boolean isExceptionCaught(ITypeBinding excpetionType) {
for (Iterator<List<CatchClause>> exceptions = fExceptionStack.iterator();
exceptions.hasNext(); ) {
for (Iterator<CatchClause> catchClauses = exceptions.next().iterator();
catchClauses.hasNext(); ) {
SingleVariableDeclaration caughtException = catchClauses.next().getException();
IVariableBinding binding = caughtException.resolveBinding();
if (binding == null) continue;
ITypeBinding caughtype = binding.getType();
while (caughtype != null) {
if (caughtype == excpetionType) return true;
caughtype = caughtype.getSuperclass();
}
}
}
return false;
}
示例5: visit
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
/**
* This is a data dependency if this is a declaration and the
* variable being declared is in the right hand side of the
* seed assignment expression.
*/
public boolean visit(SingleVariableDeclaration node){
IBinding binding = node.resolveBinding();
if(binding == null){
if(this.aliases.contains((node.getName().getFullyQualifiedName())))
this.result = true;
}
else if(binding instanceof IVariableBinding){
/* If this variable is in the alias list, then this statement
* is a data dependency. */
if(this.aliases.contains(binding.getKey())){
this.result = true;
}
}
return false;
}
示例6: isMainMethod
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
/**
* Returns true iff 'methodDeclaration' represents a void static method named 'main' that takes a
* single String[] parameter.
*/
private static boolean isMainMethod(MethodDeclaration methodDeclaration) {
// Is it static?
if ((methodDeclaration.getModifiers() & Modifier.STATIC) == 0) {
return false;
}
// Does it return void?
Type returnType = methodDeclaration.getReturnType2();
if (!returnType.isPrimitiveType()) {
return false;
}
if (((PrimitiveType) returnType).getPrimitiveTypeCode() != PrimitiveType.VOID) {
return false;
}
// Is it called 'main'?
if (!"main".equals(methodDeclaration.getName().getIdentifier())) {
return false;
}
// Does it have a single parameter?
if (methodDeclaration.parameters().size() != 1) {
return false;
}
// Is the parameter's type String[]?
SingleVariableDeclaration pt =
getOnlyElement((List<SingleVariableDeclaration>) methodDeclaration.parameters());
IVariableBinding vb = pt.resolveBinding();
if (vb == null) {
return false;
}
ITypeBinding tb = vb.getType();
return tb != null && "java.lang.String[]".equals(tb.getQualifiedName());
}
示例7: endVisit
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
@Override
public void endVisit(SingleVariableDeclaration node) {
if (skipNode(node)) {
return;
}
IVariableBinding binding = node.resolveBinding();
LocalFlowInfo nameInfo = null;
Expression initializer = node.getInitializer();
if (binding != null && !binding.isField() && initializer != null) {
nameInfo = new LocalFlowInfo(binding, FlowInfo.WRITE, fFlowContext);
}
GenericSequentialFlowInfo info = processSequential(node, node.getType(), initializer);
info.merge(nameInfo, fFlowContext);
}
示例8: visit
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
@Override
public boolean visit(SingleVariableDeclaration node) {
IVariableBinding variableBinding = node.resolveBinding();
addNewBinding(variableBinding, node);
addNewTypeBinding(variableBinding.getType());
return true;
}
示例9: visit
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
@Override
public boolean visit(CatchClause node) {
SingleVariableDeclaration exception = node.getException();
IVariableBinding variableBinding = exception.resolveBinding();
VariableVariable2 cv = fTCModel.makeDeclaredVariableVariable(variableBinding, fCU);
setConstraintVariable(exception, cv);
return true;
}
示例10: initialize
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
public void initialize() {
Block body = fDeclaration.getBody();
// first collect the static imports. This is necessary to not mark
// static imported fields and methods as implicit visible.
fTypesToImport = new ArrayList<SimpleName>();
fStaticsToImport = new ArrayList<SimpleName>();
ImportReferencesCollector.collect(
body, fTypeRoot.getJavaProject(), null, fTypesToImport, fStaticsToImport);
// Now collect implicit references and name references
body.accept(new UpdateCollector());
int numberOfLocals = LocalVariableIndex.perform(fDeclaration);
FlowContext context = new FlowContext(0, numberOfLocals + 1);
context.setConsiderAccessMode(true);
context.setComputeMode(FlowContext.MERGE);
InOutFlowAnalyzer flowAnalyzer = new InOutFlowAnalyzer(context);
FlowInfo info = flowAnalyzer.perform(getStatements());
for (Iterator<SingleVariableDeclaration> iter = fDeclaration.parameters().iterator();
iter.hasNext(); ) {
SingleVariableDeclaration element = iter.next();
IVariableBinding binding = element.resolveBinding();
ParameterData data = (ParameterData) element.getProperty(ParameterData.PROPERTY);
data.setAccessMode(info.getAccessMode(context, binding));
}
}
示例11: visit
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
/**
* This is a data dependency if this is a declaration and the
* variable being declared is in the right hand side of the
* seed assignment expression.
*/
public boolean visit(SingleVariableDeclaration node){
IBinding binding = node.resolveBinding();
if(binding == null){
this.seedVariables.add(node.getName().getFullyQualifiedName());
}
else if(binding instanceof IVariableBinding){
this.seedVariables.add(binding.getKey());
}
return false;
}
示例12: clearAccessMode
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
private void clearAccessMode(FlowInfo info, SingleVariableDeclaration decl) {
IVariableBinding binding = decl.resolveBinding();
if (binding != null && !binding.isField()) {
info.clearAccessMode(binding, fFlowContext);
}
}
示例13: clearAccessMode
import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
private void clearAccessMode(FlowInfo info, SingleVariableDeclaration decl) {
IVariableBinding binding = decl.resolveBinding();
if (binding != null && !binding.isField()) info.clearAccessMode(binding, fFlowContext);
}