当前位置: 首页>>代码示例>>Java>>正文


Java ImportDeclaration.isOnDemand方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.ImportDeclaration.isOnDemand方法的典型用法代码示例。如果您正苦于以下问题:Java ImportDeclaration.isOnDemand方法的具体用法?Java ImportDeclaration.isOnDemand怎么用?Java ImportDeclaration.isOnDemand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.ImportDeclaration的用法示例。


在下文中一共展示了ImportDeclaration.isOnDemand方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
public boolean visit(ImportDeclaration node) {
    if (node.isOnDemand()) {
        String pckgName = node.getName().getFullyQualifiedName();
        checkInDir(pckgName);
    } else {
        String importName = node.getName().getFullyQualifiedName();
        if (importName.endsWith("." + nameParts[0])) {
            fullName = importName;
            for (int i = 1; i < nameParts.length; i++) {
                fullName += "." + nameParts[i];
            }
            found = true;
        }
    }
    return true;
}
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:17,代码来源:NameResolver.java

示例2: forCompilationUnit

import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
static UnresolvableImportMatcher forCompilationUnit(CompilationUnit cu) {
	Collection<ImportDeclaration> unresolvableImports= determineUnresolvableImports(cu);

	Map<String, Set<String>> typeImportsBySimpleName= new HashMap<>();
	Map<String, Set<String>> staticImportsBySimpleName= new HashMap<>();
	for (ImportDeclaration importDeclaration : unresolvableImports) {
		String qualifiedName= importDeclaration.isOnDemand()
				? importDeclaration.getName().getFullyQualifiedName() + ".*" //$NON-NLS-1$
						: importDeclaration.getName().getFullyQualifiedName();

		String simpleName= qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1);

		Map<String, Set<String>> importsBySimpleName= importDeclaration.isStatic()
				? staticImportsBySimpleName : typeImportsBySimpleName;
		Set<String> importsWithSimpleName= importsBySimpleName.get(simpleName);
		if (importsWithSimpleName == null) {
			importsWithSimpleName= new HashSet<>();
			importsBySimpleName.put(simpleName, importsWithSimpleName);
		}

		importsWithSimpleName.add(qualifiedName);
	}

	return new UnresolvableImportMatcher(typeImportsBySimpleName, staticImportsBySimpleName);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:26,代码来源:OrganizeImportsOperation.java

示例3: 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)); }
		 */

	}
}
 
开发者ID:aroog,项目名称:code,代码行数:21,代码来源:GenerateDefaultMap.java

示例4: getUsedVariableNames

import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
public Collection<String> getUsedVariableNames(int offset, int length) {
  HashSet<String> result = new HashSet<String>();
  IBinding[] bindingsBefore = getDeclarationsInScope(offset, VARIABLES);
  for (int i = 0; i < bindingsBefore.length; i++) {
    result.add(bindingsBefore[i].getName());
  }
  IBinding[] bindingsAfter = getDeclarationsAfter(offset + length, VARIABLES);
  for (int i = 0; i < bindingsAfter.length; i++) {
    result.add(bindingsAfter[i].getName());
  }
  List<ImportDeclaration> imports = fRoot.imports();
  for (int i = 0; i < imports.size(); i++) {
    ImportDeclaration decl = imports.get(i);
    if (decl.isStatic() && !decl.isOnDemand()) {
      result.add(ASTNodes.getSimpleNameIdentifier(decl.getName()));
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:ScopeAnalyzer.java

示例5: getUsedVariableNames

import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
public Collection<String> getUsedVariableNames(int offset, int length) {
	HashSet<String> result= new HashSet<String>();
	IBinding[] bindingsBefore= getDeclarationsInScope(offset, VARIABLES);
	for (int i= 0; i < bindingsBefore.length; i++) {
		result.add(bindingsBefore[i].getName());
	}
	IBinding[] bindingsAfter= getDeclarationsAfter(offset + length, VARIABLES);
	for (int i= 0; i < bindingsAfter.length; i++) {
		result.add(bindingsAfter[i].getName());
	}
	List<ImportDeclaration> imports= fRoot.imports();
	for (int i= 0; i < imports.size(); i++) {
		ImportDeclaration decl= imports.get(i);
		if (decl.isStatic() && !decl.isOnDemand()) {
			result.add(ASTNodes.getSimpleNameIdentifier(decl.getName()));
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:ScopeAnalyzer.java

示例6: 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());
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:29,代码来源:MoveInnerToTopRefactoring.java

示例7: visit

import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(ImportDeclaration node) {
       int s= node.getStartPosition();
       int l= node.getLength();
       int declarationEnd= s + l;
       if (fImportContainer == null)
           fImportContainer= new JavaNode(getCurrentContainer(), JavaNode.IMPORT_CONTAINER, null, s, l);
       String nm= node.getName().toString();
       if (node.isOnDemand())
           nm+= ".*"; //$NON-NLS-1$
       new JavaNode(fImportContainer, JavaNode.IMPORT, nm, s, l);
       fImportContainer.setLength(declarationEnd - fImportContainer.getRange().getOffset() + 1);
       fImportContainer.setAppendPosition(declarationEnd + 2); // FIXME
       return false;
   }
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:JavaParseTreeBuilder.java

示例8: getQualifier

import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
private String getQualifier(ImportDeclaration decl) {
	String name = decl.getName().getFullyQualifiedName();
	/*
	 * If it's on demand import, return the fully qualified name. (e.g. pack1.Foo.* => pack.Foo, pack1.* => pack1)
	 * This is because we need to have pack1.Foo.* and pack1.Bar under different qualifier groups.
	 */
	if (decl.isOnDemand()) {
		return name;
	}
	return getQualifier(name, decl.isStatic());
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:ImportRewriteAnalyzer.java

示例9: visit

import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(ImportDeclaration node) {
	this.fBuffer.append("import ");//$NON-NLS-1$
	if (node.getAST().apiLevel() >= JLS3) {
		if (node.isStatic()) {
			this.fBuffer.append("static ");//$NON-NLS-1$
		}
	}
	node.getName().accept(this);
	if (node.isOnDemand()) {
		this.fBuffer.append(".*");//$NON-NLS-1$
	}
	this.fBuffer.append(";");//$NON-NLS-1$
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:16,代码来源:ASTFlattener.java

示例10: visit

import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
public boolean visit(ImportDeclaration node) {
	printIndent();
	this.buffer.append("import ");//$NON-NLS-1$
	if (node.getAST().apiLevel() >= JLS3) {
		if (node.isStatic()) {
			this.buffer.append("static ");//$NON-NLS-1$
		}
	}
	node.getName().accept(this);
	if (node.isOnDemand()) {
		this.buffer.append(".*");//$NON-NLS-1$
	}
	this.buffer.append(";\n");//$NON-NLS-1$
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:16,代码来源:NaiveASTFlattener.java

示例11: getFullName

import org.eclipse.jdt.core.dom.ImportDeclaration; //导入方法依赖的package包/类
private static String getFullName(ImportDeclaration decl) {
	String name= decl.getName().getFullyQualifiedName();
	return decl.isOnDemand() ? name + ".*": name; //$NON-NLS-1$
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:5,代码来源:ImportRewriteAnalyzer.java


注:本文中的org.eclipse.jdt.core.dom.ImportDeclaration.isOnDemand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。