本文整理汇总了Java中com.intellij.psi.JavaPsiFacade.findPackage方法的典型用法代码示例。如果您正苦于以下问题:Java JavaPsiFacade.findPackage方法的具体用法?Java JavaPsiFacade.findPackage怎么用?Java JavaPsiFacade.findPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.JavaPsiFacade
的用法示例。
在下文中一共展示了JavaPsiFacade.findPackage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveMember
import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
@Override
public List<? extends RatedResolveResult> resolveMember(@NotNull String name,
@Nullable PyExpression location,
@NotNull AccessDirection direction,
@NotNull PyResolveContext resolveContext) {
Project project = myPackage.getProject();
JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
String childName = myPackage.getQualifiedName() + "." + name;
GlobalSearchScope scope = getScope(project);
ResolveResultList result = new ResolveResultList();
final PsiClass[] classes = facade.findClasses(childName, scope);
for (PsiClass aClass : classes) {
result.poke(aClass, RatedResolveResult.RATE_NORMAL);
}
final PsiPackage psiPackage = facade.findPackage(childName);
if (psiPackage != null) {
result.poke(psiPackage, RatedResolveResult.RATE_NORMAL);
}
return result;
}
示例2: resolveImportReference
import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
@Nullable
public PsiElement resolveImportReference(QualifiedName name, QualifiedNameResolveContext context, boolean withRoots) {
String fqn = name.toString();
final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(context.getProject());
final PsiPackage aPackage = psiFacade.findPackage(fqn);
if (aPackage != null) {
return aPackage;
}
Module module = context.getModule();
if (module != null) {
final PsiClass aClass = psiFacade.findClass(fqn, module.getModuleWithDependenciesAndLibrariesScope(false));
if (aClass != null) return aClass;
}
return null;
}
示例3: createPositionManager
import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
@Override
public PositionManager createPositionManager(@NotNull final DebugProcess process) {
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
try {
JavaPsiFacade facade = JavaPsiFacade.getInstance(process.getProject());
if (facade.findPackage("com.springsource.loaded") != null || facade.findPackage("org.springsource.loaded") != null) {
return new SpringLoadedPositionManager(process);
}
}
finally {
accessToken.finish();
}
try {
// Check spring loaded for remote process
if (!process.getVirtualMachineProxy().classesByName("com.springsource.loaded.agent.SpringLoadedAgent").isEmpty()
|| !process.getVirtualMachineProxy().classesByName("org.springsource.loaded.agent.SpringLoadedAgent").isEmpty()) {
return new SpringLoadedPositionManager(process);
}
}
catch (Exception ignored) {
// Some problem with virtual machine.
}
return null;
}
示例4: getDescriptionsDirs
import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
public static PsiDirectory[] getDescriptionsDirs(Module module,
DescriptionType descriptionType) {
final JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(module.getProject());
final PsiPackage psiPackage = javaPsiFacade.findPackage(descriptionType.getDescriptionFolder());
if (psiPackage != null) {
return psiPackage.getDirectories(GlobalSearchScope.moduleWithDependenciesScope(module));
}
return PsiDirectory.EMPTY_ARRAY;
}
示例5: collectVariants
import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
public static Collection<LookupElement> collectVariants(@NotNull Module module, @NotNull String text, int offset, @NotNull String prefix) {
if (prefix.startsWith("-D")) {
return getSystemPropertiesVariants();
}
List<LookupElement> res = new ArrayList<LookupElement>();
if (text.substring(0, offset).matches("\\s*(grails\\s*)?(?:(:?-D\\S+|dev|prod|test)\\s+)*\\S*")) {
// Complete command name because command name is not typed.
for (String completionVariant : getAllTargetNames(module)) {
res.add(TailTypeDecorator.withTail(LookupElementBuilder.create(completionVariant), TailType.SPACE));
}
}
else {
// Command name already typed. Try to complete classes and packages names.
GlobalSearchScope scope = GlobalSearchScope.moduleScope(module);
JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
// Complete class names if prefix is a package name with dot at end.
if (prefix.endsWith(".") && prefix.length() > 1) {
PsiPackage p = facade.findPackage(prefix.substring(0, prefix.length() - 1));
if (p != null) {
for (PsiClass aClass : p.getClasses(scope)) {
String qualifiedName = aClass.getQualifiedName();
if (qualifiedName != null) {
res.add(LookupElementBuilder.create(aClass, qualifiedName));
}
}
}
}
PsiPackage defaultPackage = facade.findPackage("");
if (defaultPackage != null) {
collectClassesAndPackageNames(res, defaultPackage, scope);
}
}
return res;
}
示例6: resolvePackage
import com.intellij.psi.JavaPsiFacade; //导入方法依赖的package包/类
private PsiPackage resolvePackage(PsiClass aggregateRoot) {
String qualifiedName = aggregateRoot.getQualifiedName();
JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(getProject());
return javaPsiFacade.findPackage(qualifiedName.substring(0, qualifiedName.lastIndexOf(".")));
}