本文整理匯總了Java中org.eclipse.jdt.core.dom.VariableDeclarationFragment.resolveBinding方法的典型用法代碼示例。如果您正苦於以下問題:Java VariableDeclarationFragment.resolveBinding方法的具體用法?Java VariableDeclarationFragment.resolveBinding怎麽用?Java VariableDeclarationFragment.resolveBinding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.VariableDeclarationFragment
的用法示例。
在下文中一共展示了VariableDeclarationFragment.resolveBinding方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visit
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
@Override
public boolean visit(FieldDeclaration node) {
int modifiers = node.getModifiers();
if (Modifier.isPrivate(modifiers) || Modifier.isProtected(modifiers)) {
List<VariableDeclarationFragment> fragments = node.fragments();
for (VariableDeclarationFragment varDeclFrag : fragments) {
IVariableBinding varBinding = varDeclFrag.resolveBinding();
String enclosingClass = varBinding.getDeclaringClass().getQualifiedName();
if(!varBinding.getType().isPrimitive() && !varBinding.getType().getQualifiedName().equals("java.lang.String")){
final TACVariable fieldVar = new TACVariable(varBinding);
if(!enclosingClass.equals(Config.MAINCLASS)){
context.addEncapsulatedVariable(fieldVar);
}
}
}
}
return super.visit(node);
}
示例2: visit
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
@Override
public boolean visit(VariableDeclarationFragment node) {
if (isDeclarationTarget(DeclarationType.FIELD_DECLARATION)) {
IVariableBinding variableBinding = node.resolveBinding();
if (variableBinding != null) {
if (variableBinding.isField()) {
variableFound = variableBinding.getName();
if (matchTypeDeclaration()
&& TraceUtility
.match(variableToFind, variableFound)) {
TraceUtility.selectInEditor(node);
setEnclosingDeclaration(node);
}
}
}
}
return super.visit(node);
}
示例3: getConstraintsForHiding
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
private Collection<ITypeConstraint> getConstraintsForHiding(
VariableDeclarationFragment fragment) {
Collection<ITypeConstraint> result = new ArrayList<ITypeConstraint>();
IVariableBinding fieldBinding = fragment.resolveBinding();
Assert.isTrue(fieldBinding.isField());
Set<ITypeBinding> declaringTypes = getDeclaringSuperTypes(fieldBinding);
ConstraintVariable hiddingFieldVar =
fConstraintVariableFactory.makeDeclaringTypeVariable(fieldBinding);
for (Iterator<ITypeBinding> iter = declaringTypes.iterator(); iter.hasNext(); ) {
ITypeBinding declaringSuperType = iter.next();
IVariableBinding hiddenField = findField(fieldBinding, declaringSuperType);
Assert.isTrue(hiddenField.isField());
ConstraintVariable hiddenFieldVar =
fConstraintVariableFactory.makeDeclaringTypeVariable(hiddenField);
result.addAll(
Arrays.asList(
fTypeConstraintFactory.createStrictSubtypeConstraint(
hiddingFieldVar, hiddenFieldVar)));
}
return result;
}
示例4: retrieveVariableReference
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
private VariableReference retrieveVariableReference(
VariableDeclarationFragment varDeclFrgmnt) {
IVariableBinding variableBinding = varDeclFrgmnt.resolveBinding();
Class<?> clazz = retrieveTypeClass(variableBinding.getType());
if (clazz.isArray()) {
ArrayReference arrayReference = new ValidArrayReference(
testCase.getReference(), clazz);
arrayReference.setOriginalCode(varDeclFrgmnt.toString());
testCase.addVariable(varDeclFrgmnt.resolveBinding(), arrayReference);
return arrayReference;
}
VariableReference result = new BoundVariableReferenceImpl(testCase, clazz,
variableBinding.getName());
testCase.addVariable(variableBinding, result);
return result;
}
示例5: visit
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的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(VariableDeclarationFragment 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: endVisit
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
@Override
public void endVisit(VariableDeclarationFragment 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, initializer);
info.merge(nameInfo, fFlowContext);
}
示例7: visit
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
@Override
public boolean visit(VariableDeclarationFragment node) {
IVariableBinding variableBinding = node.resolveBinding();
addNewBinding(variableBinding, node);
addNewTypeBinding(variableBinding.getType());
return true;
}
示例8: visit
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
@Override
public boolean visit(FieldDeclaration fieldDeclaration) {
List<VariableDeclarationFragment> fragments = fieldDeclaration.fragments();
for (VariableDeclarationFragment fragment : fragments) {
IVariableBinding binding = fragment.resolveBinding();
if (binding == null)
continue;
IField field = (IField) binding.getJavaElement();
FieldDetails fieldDetails = new FieldDetails();
fieldDetails.setModifiers(fieldDeclaration.getModifiers());
allDetails.put(field.getHandleIdentifier(), fieldDetails);
}
return true;
}
示例9: getForInitializedVariables
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
private static List<IVariableBinding> getForInitializedVariables(
VariableDeclarationExpression variableDeclarations) {
List<IVariableBinding> forInitializerVariables = new ArrayList<IVariableBinding>(1);
for (Iterator<VariableDeclarationFragment> iter = variableDeclarations.fragments().iterator();
iter.hasNext(); ) {
VariableDeclarationFragment fragment = iter.next();
IVariableBinding binding = fragment.resolveBinding();
if (binding != null) forInitializerVariables.add(binding);
}
return forInitializerVariables;
}
示例10: getConstraintsForFieldDeclaringTypes
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
private Collection<ITypeConstraint> getConstraintsForFieldDeclaringTypes(FieldDeclaration fd) {
Collection<ITypeConstraint> result = new ArrayList<ITypeConstraint>(fd.fragments().size());
for (Iterator<VariableDeclarationFragment> iter = fd.fragments().iterator(); iter.hasNext(); ) {
VariableDeclarationFragment varDecl = iter.next();
IVariableBinding binding = varDecl.resolveBinding();
Assert.isTrue(binding.isField());
result.addAll(
Arrays.asList(
fTypeConstraintFactory.createDefinesConstraint(
fConstraintVariableFactory.makeDeclaringTypeVariable(binding),
fConstraintVariableFactory.makeRawBindingVariable(binding.getDeclaringClass()))));
}
return result;
}
示例11: checkInitialConditions
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
if (fVisibility < 0)
fVisibility = (fField.getFlags() & (Flags.AccPublic | Flags.AccProtected | Flags.AccPrivate));
RefactoringStatus result = new RefactoringStatus();
result.merge(Checks.checkAvailability(fField));
if (result.hasFatalError()) return result;
fRoot =
new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL)
.parse(fField.getCompilationUnit(), true, pm);
ISourceRange sourceRange = fField.getNameRange();
ASTNode node = NodeFinder.perform(fRoot, sourceRange.getOffset(), sourceRange.getLength());
if (node == null) {
return mappingErrorFound(result, node);
}
fFieldDeclaration =
(VariableDeclarationFragment) ASTNodes.getParent(node, VariableDeclarationFragment.class);
if (fFieldDeclaration == null) {
return mappingErrorFound(result, node);
}
if (fFieldDeclaration.resolveBinding() == null) {
if (!processCompilerError(result, node))
result.addFatalError(RefactoringCoreMessages.SelfEncapsulateField_type_not_resolveable);
return result;
}
computeUsedNames();
return result;
}
示例12: visit
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的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(VariableDeclarationFragment 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;
}
示例13: ensureAttributeForFragment
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
/**
* We pass both the fragment and the field because we need the field type when the binding cannot be resolved
*/
public Attribute ensureAttributeForFragment(VariableDeclarationFragment fragment, FieldDeclaration field) {
IVariableBinding binding = fragment.resolveBinding();
Attribute attribute;
if (binding == null)
attribute = ensureAttributeFromFragmentIntoParentType(fragment, field, this.topFromContainerStack(Type.class));
else {
attribute = ensureAttributeForVariableBinding(binding);
extractBasicModifiersFromBinding(binding.getModifiers(), attribute);
if (Modifier.isStatic(binding.getModifiers()))
attribute.setHasClassScope(true);
}
attribute.setIsStub(true);
return attribute;
}
示例14: clearAccessMode
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
private void clearAccessMode(FlowInfo info, VariableDeclarationFragment fragment) {
IVariableBinding binding = fragment.resolveBinding();
if (binding != null && !binding.isField()) {
info.clearAccessMode(binding, fFlowContext);
}
}
示例15: visit
import org.eclipse.jdt.core.dom.VariableDeclarationFragment; //導入方法依賴的package包/類
@Override
public boolean visit(VariableDeclarationFragment node) {
IVariableBinding resolveBinding = node.resolveBinding();
varDeclaration.add(resolveBinding);
return super.visit(node);
}