List of usage examples for org.eclipse.jdt.core.dom SimpleName isDeclaration
public boolean isDeclaration()
From source file:java5totext.input.JDTVisitor.java
License:Open Source License
@Override public boolean visit(org.eclipse.jdt.core.dom.SimpleName node) { if (this.isQualifierChildAsName(node)) { return true; } else//w w w.j a v a2 s. c om // UTIL ? if (node.isDeclaration()) { // binding.put(node, node.getIdentifier()); // } // else { if (!node.isDeclaration()) { NamedElementRef element = this.factory.createNamedElementRef(); this.binding.put(node, element); } return true; }
From source file:java5totext.input.JDTVisitor.java
License:Open Source License
@Override public void endVisit(org.eclipse.jdt.core.dom.SimpleName node) { if (this.isQualifierChildAsName(node)) { return;/*from ww w . j ava 2s.c o m*/ } else if (!node.isDeclaration()) { NamedElementRef element = (NamedElementRef) this.binding.get(node); this.initializeNode(element, node); JDTVisitorUtils.manageBindingRef(element, node, this); } }
From source file:org.eclipse.modisco.java.discoverer.internal.io.java.JDTVisitor.java
License:Open Source License
@Override public boolean visit(final org.eclipse.jdt.core.dom.SimpleName node) { if (isConstructorDeclaration(node)) { return false; } else if (!node.isDeclaration()) { PendingElement pending = new PendingElement(this.factory); this.binding.put(node, pending); }//from w ww . j av a 2 s . c o m return true; }
From source file:org.eclipse.modisco.java.discoverer.internal.io.java.JDTVisitor.java
License:Open Source License
@Override public void endVisit(final org.eclipse.jdt.core.dom.SimpleName node) { if (JDTVisitor.isArrayLengthAccess(node)) { return;/*from w w w.j av a 2 s . c o m*/ } else if (isConstructorDeclaration(node)) { return; // Misc case of constructor answering node.isDeclaration = // false. See javadoc of // org.eclipse.jdt.core.dom.SimpleName#isDeclaration() } else if (isNameChildOfMemberRef(node)) { // @see #isNameChildOfMemberRef(org.eclipse.jdt.core.dom.SimpleName) NamedElement target = JDTVisitorUtils.manageBindingRef((PendingElement) this.binding.get(node), node, this); if (target != null) { this.binding.put(node, target); } } else if (!node.isDeclaration()) { PendingElement pending = (PendingElement) this.binding.get(node); IBinding jdtBinding = node.resolveBinding(); if (jdtBinding == null) { // unresolved item, // we cannot decide if it will be a TypeAccess or PackageAccess // or ... etc // keep pending element here. Visiting the container will decide // the final access type NamedElement target = JDTVisitorUtils.manageBindingRef(pending, node, this); if (target != null) { // do something ? } } else if (jdtBinding.getKind() == IBinding.METHOD) { // no MethodAccess NamedElement target = JDTVisitorUtils.manageBindingRef(pending, node, this); if (target != null) { this.binding.put(node, target); } } else if (jdtBinding.getKind() == IBinding.PACKAGE) { PackageAccess pckAcc = this.factory.createPackageAccess(); pending.setClientNode(pckAcc); pending.setLinkName("package"); //$NON-NLS-1$ this.binding.put(node, pckAcc); NamedElement target = JDTVisitorUtils.manageBindingRef(pending, node, this); if (target != null) { pckAcc.setPackage((Package) target); } } else if (jdtBinding.getKind() == IBinding.TYPE) { TypeAccess typAcc = this.factory.createTypeAccess(); pending.setClientNode(typAcc); pending.setLinkName("type"); //$NON-NLS-1$ this.binding.put(node, typAcc); NamedElement target = JDTVisitorUtils.manageBindingRef(pending, node, this); if (target != null) { typAcc.setType((Type) target); } } else if (jdtBinding.getKind() == IBinding.VARIABLE) { SingleVariableAccess varAcc = this.factory.createSingleVariableAccess(); pending.setClientNode(varAcc); pending.setLinkName("variable"); //$NON-NLS-1$ this.binding.put(node, varAcc); NamedElement target = JDTVisitorUtils.manageBindingRef(pending, node, this); if (target != null) { varAcc.setVariable((VariableDeclaration) target); } } else { MoDiscoLogger.logError("Unknown binding type for " + node + " : " + jdtBinding, //$NON-NLS-1$//$NON-NLS-2$ JavaActivator.getDefault()); } } }
From source file:org.eclipse.scout.sdk.saml.importer.internal.jdt.imports.ImportReferencesCollector.java
License:Open Source License
private void possibleStaticImportFound(Name name) { if (fStaticImports == null || fASTRoot == null) { return;// w ww. j av a 2 s .co m } while (name.isQualifiedName()) { name = ((QualifiedName) name).getQualifier(); } if (!isAffected(name)) { return; } IBinding binding = name.resolveBinding(); SimpleName simpleName = (SimpleName) name; if (binding == null || binding instanceof ITypeBinding || !Modifier.isStatic(binding.getModifiers()) || simpleName.isDeclaration()) { return; } if (binding instanceof IVariableBinding) { IVariableBinding varBinding = (IVariableBinding) binding; if (varBinding.isField()) { varBinding = varBinding.getVariableDeclaration(); ITypeBinding declaringClass = varBinding.getDeclaringClass(); if (declaringClass != null && !declaringClass.isLocal()) { if (new ScopeAnalyzer(fASTRoot).isDeclaredInScope(varBinding, simpleName, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY)) return; fStaticImports.add(simpleName); } } } else if (binding instanceof IMethodBinding) { IMethodBinding methodBinding = ((IMethodBinding) binding).getMethodDeclaration(); ITypeBinding declaringClass = methodBinding.getDeclaringClass(); if (declaringClass != null && !declaringClass.isLocal()) { if (new ScopeAnalyzer(fASTRoot).isDeclaredInScope(methodBinding, simpleName, ScopeAnalyzer.METHODS | ScopeAnalyzer.CHECK_VISIBILITY)) return; fStaticImports.add(simpleName); } } }