本文整理汇总了Java中org.eclipse.jdt.internal.core.CompilationUnitElementInfo类的典型用法代码示例。如果您正苦于以下问题:Java CompilationUnitElementInfo类的具体用法?Java CompilationUnitElementInfo怎么用?Java CompilationUnitElementInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompilationUnitElementInfo类属于org.eclipse.jdt.internal.core包,在下文中一共展示了CompilationUnitElementInfo类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CompletionUnitStructureRequestor
import org.eclipse.jdt.internal.core.CompilationUnitElementInfo; //导入依赖的package包/类
public CompletionUnitStructureRequestor(
ICompilationUnit unit,
CompilationUnitElementInfo unitInfo,
Parser parser,
ASTNode assistNode,
Map bindingCache,
Map elementCache,
Map elementWithProblemCache,
Map newElements) {
super(unit, unitInfo, newElements);
this.parser = parser;
this.assistNode = assistNode;
this.bindingCache = bindingCache;
this.elementCache = elementCache;
this.elementWithProblemCache = elementWithProblemCache;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:CompletionUnitStructureRequestor.java
示例2: convert
import org.eclipse.jdt.internal.core.CompilationUnitElementInfo; //导入依赖的package包/类
private CompilationUnitDeclaration convert(
ISourceType[] sourceTypes, CompilationResult compilationResult) throws JavaModelException {
this.unit = new CompilationUnitDeclaration(this.problemReporter, compilationResult, 0);
// not filled at this point
if (sourceTypes.length == 0) return this.unit;
SourceTypeElementInfo topLevelTypeInfo = (SourceTypeElementInfo) sourceTypes[0];
org.eclipse.jdt.core.ICompilationUnit cuHandle =
topLevelTypeInfo.getHandle().getCompilationUnit();
this.cu = (ICompilationUnit) cuHandle;
final CompilationUnitElementInfo compilationUnitElementInfo =
(CompilationUnitElementInfo) ((JavaElement) this.cu).getElementInfo();
if (this.has1_5Compliance
&& (compilationUnitElementInfo.annotationNumber
>= CompilationUnitElementInfo.ANNOTATION_THRESHOLD_FOR_DIET_PARSE
|| (compilationUnitElementInfo.hasFunctionalTypes && (this.flags & LOCAL_TYPE) != 0))) {
// If more than 10 annotations, diet parse as this is faster, but not if
// the client wants local and anonymous types to be converted
// (https://bugs.eclipse.org/bugs/show_bug.cgi?id=254738)
// Also see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=405843
if ((this.flags & LOCAL_TYPE) == 0) {
return new Parser(this.problemReporter, true).dietParse(this.cu, compilationResult);
} else {
return new Parser(this.problemReporter, true).parse(this.cu, compilationResult);
}
}
/* only positions available */
int start = topLevelTypeInfo.getNameSourceStart();
int end = topLevelTypeInfo.getNameSourceEnd();
/* convert package and imports */
String[] packageName = ((PackageFragment) cuHandle.getParent()).names;
if (packageName.length > 0)
// if its null then it is defined in the default package
this.unit.currentPackage =
createImportReference(packageName, start, end, false, ClassFileConstants.AccDefault);
IImportDeclaration[] importDeclarations =
topLevelTypeInfo.getHandle().getCompilationUnit().getImports();
int importCount = importDeclarations.length;
this.unit.imports = new ImportReference[importCount];
for (int i = 0; i < importCount; i++) {
ImportDeclaration importDeclaration = (ImportDeclaration) importDeclarations[i];
ISourceImport sourceImport = (ISourceImport) importDeclaration.getElementInfo();
String nameWithoutStar = importDeclaration.getNameWithoutStar();
this.unit.imports[i] =
createImportReference(
Util.splitOn('.', nameWithoutStar, 0, nameWithoutStar.length()),
sourceImport.getDeclarationSourceStart(),
sourceImport.getDeclarationSourceEnd(),
importDeclaration.isOnDemand(),
sourceImport.getModifiers());
}
/* convert type(s) */
try {
int typeCount = sourceTypes.length;
final TypeDeclaration[] types = new TypeDeclaration[typeCount];
/*
* We used a temporary types collection to prevent this.unit.types from being null during a call to
* convert(...) when the source is syntactically incorrect and the parser is flushing the unit's types.
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=97466
*/
for (int i = 0; i < typeCount; i++) {
SourceTypeElementInfo typeInfo = (SourceTypeElementInfo) sourceTypes[i];
types[i] = convert((SourceType) typeInfo.getHandle(), compilationResult);
}
this.unit.types = types;
return this.unit;
} catch (AnonymousMemberFound e) {
return new Parser(this.problemReporter, true).parse(this.cu, compilationResult);
}
}
示例3: computeEnclosingJavaElements
import org.eclipse.jdt.internal.core.CompilationUnitElementInfo; //导入依赖的package包/类
private void computeEnclosingJavaElements() {
this.hasComputedEnclosingJavaElements = true;
if (this.typeRoot == null) return;
if (this.typeRoot.getElementType() == IJavaElement.COMPILATION_UNIT) {
ICompilationUnit original = (org.eclipse.jdt.core.ICompilationUnit)this.typeRoot;
HashMap handleToBinding = new HashMap();
HashMap bindingToHandle = new HashMap();
HashMap nodeWithProblemToHandle = new HashMap();
HashMap handleToInfo = new HashMap();
org.eclipse.jdt.core.ICompilationUnit handle = new AssistCompilationUnit(original, this.owner, handleToBinding, handleToInfo);
CompilationUnitElementInfo info = new CompilationUnitElementInfo();
handleToInfo.put(handle, info);
CompletionUnitStructureRequestor structureRequestor =
new CompletionUnitStructureRequestor(
handle,
info,
this.parser,
this.assistNode,
handleToBinding,
bindingToHandle,
nodeWithProblemToHandle,
handleToInfo);
CompletionElementNotifier notifier =
new CompletionElementNotifier(
structureRequestor,
true,
this.assistNode);
notifier.notifySourceElementRequestor(
this.compilationUnitDeclaration,
this.compilationUnitDeclaration.sourceStart,
this.compilationUnitDeclaration.sourceEnd,
false,
this.parser.sourceEnds,
new HashMap());
this.bindingsToHandles = bindingToHandle;
this.nodesWithProblemsToHandles = nodeWithProblemToHandle;
this.compilationUnit = handle;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:49,代码来源:InternalExtendedCompletionContext.java