本文整理汇总了Java中org.netbeans.api.java.source.CompilationInfo.getClasspathInfo方法的典型用法代码示例。如果您正苦于以下问题:Java CompilationInfo.getClasspathInfo方法的具体用法?Java CompilationInfo.getClasspathInfo怎么用?Java CompilationInfo.getClasspathInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.java.source.CompilationInfo
的用法示例。
在下文中一共展示了CompilationInfo.getClasspathInfo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CreateEnumConstant
import org.netbeans.api.java.source.CompilationInfo; //导入方法依赖的package包/类
public CreateEnumConstant(CompilationInfo info, String name, Set<Modifier> modifiers, TypeElement target, TypeMirror proposedType, FileObject targetFile) {
this.name = name;
this.inFQN = target.getQualifiedName().toString();
this.cpInfo = info.getClasspathInfo();
this.targetFile = targetFile;
this.target = ElementHandle.create(target);
if (proposedType.getKind() == TypeKind.NULL) {
TypeElement tel = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
if (tel != null) {
proposedType = tel.asType();
this.proposedType = TypeMirrorHandle.create(proposedType);
} else {
this.proposedType = null;
}
} else {
this.proposedType = TypeMirrorHandle.create(proposedType);
}
}
示例2: ElementJavadoc
import org.netbeans.api.java.source.CompilationInfo; //导入方法依赖的package包/类
private ElementJavadoc(CompilationInfo compilationInfo, Element element, final URL url, final Callable<Boolean> cancel) {
this.cpInfo = compilationInfo.getClasspathInfo();
this.fileObject = compilationInfo.getFileObject();
this.handle = element == null ? null : ElementHandle.create(element);
this.cancel = cancel;
final StringBuilder header = getElementHeader(element, compilationInfo);
try {
//Optimisitic no http
CharSequence doc = getElementDoc(element, compilationInfo, header, url, true);
if (doc == null) {
computeDocURL(Collections.emptyList(), true, cancel);
doc = header.append(noJavadocFound());
}
this.content = new Now(doc.toString());
} catch (JavadocHelper.RemoteJavadocException re) {
if (fileObject == null || JavaSource.forFileObject(fileObject) == null) {
header.append(noJavadocFound());
this.content = new Now(header.toString());
return;
}
this.content = new FutureTask<>(() -> {
final JavaSourceUtil.Handle ch = JavaSourceUtil.createControllerHandle(fileObject, null);
final CompilationController c = (CompilationController) ch.getCompilationController();
c.toPhase(Phase.RESOLVED);
final Element el = handle.resolve(c);
CharSequence doc = getElementDoc(el, c, header, url, false);
if (doc == null) {
computeDocURL(Collections.emptyList(), false, cancel);
doc = header.append(noJavadocFound());
}
return doc.toString();
});
RP.post((Runnable)this.content);
}
}
示例3: run
import org.netbeans.api.java.source.CompilationInfo; //导入方法依赖的package包/类
@Override
@org.netbeans.api.annotations.common.SuppressWarnings(value={"DMI_COLLECTION_OF_URLS"}, justification="URLs have never host part") //NOI18N
public void run(final Result result, final SchedulerEvent event) {
final CompilationInfo info = CompilationInfo.get(result);
final ClasspathInfo cpInfo = info.getClasspathInfo();
if (cpInfo != null) {
final ClassPath src = cpInfo.getClassPath(PathKind.SOURCE);
final ClassPath boot = cpInfo.getClassPath(PathKind.BOOT);
final ClassPath compile = cpInfo.getClassPath(PathKind.COMPILE);
if (!isIncomplete(src, boot, compile)) {
final ClassPath cachedSrc = ClasspathInfoAccessor.getINSTANCE().getCachedClassPath(cpInfo, PathKind.SOURCE);
try {
final Set<URL> unknown = new HashSet<URL>();
if (cachedSrc.entries().isEmpty() && !src.entries().isEmpty()) {
for (ClassPath.Entry entry : src.entries()) {
final URL url = entry.getURL();
if (!this.factory.firedFor.contains(url) &&
!JavaIndex.hasSourceCache(url,false) &&
FileOwnerQuery.getOwner(url.toURI()) != null) {
unknown.add(url);
this.factory.firedFor.add(url);
}
}
}
if (!unknown.isEmpty()) {
PathRegistry.getDefault().registerUnknownSourceRoots(src, unknown);
}
} catch (URISyntaxException e) {
Exceptions.printStackTrace(e);
}
}
}
}
示例4: init
import org.netbeans.api.java.source.CompilationInfo; //导入方法依赖的package包/类
public void init(TokenHierarchy h, CompilationInfo info, FxmlParserResult fxmlResult) {
this.hierarchy = h;
this.compilationInfo = info;
this.cpInfo = info.getClasspathInfo();
this.fxmlParserResult = fxmlResult;
processTokens(h);
}
示例5: addModuleDirectives
import org.netbeans.api.java.source.CompilationInfo; //导入方法依赖的package包/类
private void addModuleDirectives(
@NonNull final ModuleElement module,
@NonNull final Description target,
@NonNull final Context ctx,
@NonNull final CompilationInfo info,
final boolean fqn) {
target.subs = new HashSet<>();
for (ModuleElement.Directive dir : module.getDirectives()) {
if (isImportant(dir)) {
final ClasspathInfo cpInfo = info.getClasspathInfo();
final Description dirDesc;
if (ctx.isSource) {
final DirectiveTree dt = ctx.getDirectiveTree(dir);
final TreePathHandle treePathHandle = TreePathHandle.create(TreePath.getPath(info.getCompilationUnit(), dt), info);
final String name = getDirectiveName(dir, fqn);
dirDesc = Description.directive(
ui,
name,
treePathHandle,
dir.getKind(),
cpInfo,
ctx.getStartPosition(dir),
OpenAction.openable(treePathHandle, ctx.getFileObject(), name));
} else {
dirDesc = Description.directive(
ui,
getDirectiveName(dir, fqn),
dir.getKind(),
cpInfo,
OpenAction.openable(module, dir, cpInfo));
}
dirDesc.htmlHeader = createHtmlHeader(info, dir, fqn);
target.subs.add(dirDesc);
}
}
}
示例6: CreateFieldFix
import org.netbeans.api.java.source.CompilationInfo; //导入方法依赖的package包/类
public CreateFieldFix(CompilationInfo info, String name, Set<Modifier> modifiers, TypeElement target, TypeMirror proposedType, FileObject targetFile) {
this.name = name;
this.inFQN = Utilities.target2String(target);
this.cpInfo = info.getClasspathInfo();
this.modifiers = modifiers;
this.targetFile = targetFile;
this.target = ElementHandle.create(target);
if (proposedType.getKind() == TypeKind.NULL || proposedType.getKind() == TypeKind.NONE) {
TypeElement te = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
proposedType = te == null ? null : te.asType();
}
this.proposedType = proposedType == null ? null : TypeMirrorHandle.create(proposedType);
this.remote = !org.openide.util.Utilities.compareObjects(info.getFileObject(), targetFile);
}
示例7: CreateInnerClassFix
import org.netbeans.api.java.source.CompilationInfo; //导入方法依赖的package包/类
public CreateInnerClassFix(CompilationInfo info, String name, Set<Modifier> modifiers, TypeElement target, List<? extends TypeMirror> argumentTypes, List<String> argumentNames, TypeMirror superType, ElementKind kind, int numTypeParameters, FileObject targetFile) {
super(info, modifiers, argumentTypes, argumentNames, superType, kind, numTypeParameters);
this.name = name;
this.target = ElementHandle.create(target);
this.inFQN = Utilities.target2String(target);
this.cpInfo = info.getClasspathInfo();
this.targetFile = targetFile;
}
示例8: ElementDescription
import org.netbeans.api.java.source.CompilationInfo; //导入方法依赖的package包/类
public ElementDescription(CompilationInfo info, Element element, boolean overriddenFlag) {
this.originalCPInfo = info.getClasspathInfo();
this.handle = ElementHandle.create(element);
if (METHOD.equals(element.getKind()) && null != element.getEnclosingElement()) {
//when showing the implementors/overriders of a method, show the type icon (not the method icon)
this.imageKind = element.getEnclosingElement().getKind();
} else {
this.imageKind = this.handle.getKind();
}
this.outtermostElement = ElementHandle.create(SourceUtils.getOutermostEnclosingTypeElement(element));
this.modifiers = element.getModifiers();
this.displayName = overriddenFlag ? computeDisplayNameIsOverridden(element) : computeDisplayNameOverrides(element);
this.overriddenFlag = overriddenFlag;
}
示例9: readHints
import org.netbeans.api.java.source.CompilationInfo; //导入方法依赖的package包/类
@Override
public Map<HintMetadata, ? extends Collection<? extends HintDescription>> readHints(CompilationInfo info, Collection<? extends ClassPath> from, AtomicBoolean cancel) {
Map<HintMetadata, Collection<HintDescription>> result = new HashMap<HintMetadata, Collection<HintDescription>>(globalHints);
if (info != null) {
for (ElementBasedHintProvider provider : Lookup.getDefault().lookupAll(ElementBasedHintProvider.class)) {
sortByMetadata(provider.computeHints(info), result);
}
}
ClassPath compound;
if (from != null) {
// not cached, probably not invoked that much
compound = ClassPathSupport.createProxyClassPath(from.toArray(new ClassPath[0]));
} else {
OK: if (info != null) {
synchronized (compoundPathCache) {
ClasspathInfo cpInfo = info.getClasspathInfo();
Reference<Holder> cpRef = compoundPathCache.get(cpInfo);
if (cpRef != null) {
Holder cp = cpRef.get();
if (cp != null) {
compound = cp.compound;
break OK;
}
}
Holder h = new Holder(cpInfo);
compoundPathCache.put(cpInfo, new WeakReference<>(h));
compound = h.compound;
}
} else {
compound = ClassPathSupport.createClassPath(new FileObject[0]);
}
}
for (ClassPathBasedHintProvider p : Lookup.getDefault().lookupAll(ClassPathBasedHintProvider.class)) {
Collection<? extends HintDescription> hints = p.computeHints(compound, cancel);
if (hints == null || (cancel != null && cancel.get())) return null;
sortByMetadata(hints, result);
}
return result;
}