本文整理汇总了Java中org.eclipse.jdt.core.dom.ImportDeclaration.resolveBinding方法的典型用法代码示例。如果您正苦于以下问题:Java ImportDeclaration.resolveBinding方法的具体用法?Java ImportDeclaration.resolveBinding怎么用?Java ImportDeclaration.resolveBinding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.ImportDeclaration
的用法示例。
在下文中一共展示了ImportDeclaration.resolveBinding方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: endVisit
import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
@Override
public void endVisit(ImportDeclaration node) {
boolean filtered = false;
if (!node.isOnDemand()) { // if it is not x.y.*
ITypeBinding tb = (ITypeBinding) node.resolveBinding();
String qualifiedName = tb.getQualifiedName();
for (String filter : filters) {
Pattern patternJava = Pattern.compile(filter);
Matcher matcherJava = patternJava.matcher(qualifiedName);
if (matcherJava.matches()) {
filtered = true;
}
}
/*
* if (!model.hasMapping(qualifiedName) && !filtered) {
* model.addMapping(new Entry(qualifiedName)); }
*/
}
}
示例2: updateReferenceInImport
import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
private void updateReferenceInImport(ImportDeclaration enclosingImport, ASTNode node, CompilationUnitRewrite rewrite) {
final IBinding binding= enclosingImport.resolveBinding();
if (binding instanceof ITypeBinding) {
final ITypeBinding type= (ITypeBinding) binding;
final ImportRewrite rewriter= rewrite.getImportRewrite();
if (enclosingImport.isStatic()) {
final String oldImport= ASTNodes.asString(node);
final StringBuffer buffer= new StringBuffer(oldImport);
final String typeName= fType.getDeclaringType().getElementName();
final int index= buffer.indexOf(typeName);
if (index >= 0) {
buffer.delete(index, index + typeName.length() + 1);
final String newImport= buffer.toString();
if (enclosingImport.isOnDemand()) {
rewriter.removeStaticImport(oldImport + ".*"); //$NON-NLS-1$
rewriter.addStaticImport(newImport, "*", false); //$NON-NLS-1$
} else {
rewriter.removeStaticImport(oldImport);
final int offset= newImport.lastIndexOf('.');
if (offset >= 0 && offset < newImport.length() - 1) {
rewriter.addStaticImport(newImport.substring(0, offset), newImport.substring(offset + 1), false);
}
}
}
} else
rewriter.removeImport(type.getQualifiedName());
}
}
示例3: visit
import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
public boolean visit(ImportDeclaration node) {
if (found(node, node) && this.resolveBinding)
this.foundBinding = node.resolveBinding();
return true;
}