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


Java PsiManager.getInstance方法代码示例

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


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

示例1: findFileModules

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
@NotNull
public static List<PsiFile> findFileModules(@NotNull Project project, String extension, @NotNull String name, boolean exact) {
    ArrayList<PsiFile> result = new ArrayList<>();

    Bucklescript bucklescript = BucklescriptProjectComponent.getInstance(project);
    PsiManager psiManager = PsiManager.getInstance(project);

    Collection<VirtualFile> files = FilenameIndex.getAllFilesByExt(project, extension);
    for (VirtualFile vFile : files) {
        String canonicalPath = vFile.getCanonicalPath();
        if (bucklescript.isDependency(canonicalPath)) {
            FileBase file = (FileBase) psiManager.findFile(vFile);
            if (file != null) {
                String fileModuleName = file.asModuleName();
                boolean found = exact ? fileModuleName.equals(name) : fileModuleName.startsWith(name);
                if (found) {
                    result.add(file);
                }
            }
        }
    }

    return result;
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:25,代码来源:RmlPsiUtil.java

示例2: getTableDefinitionElements

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
public static PsiElement[] getTableDefinitionElements(@NotNull String tableName, @NotNull Project project) {

        PsiFile[] extTablesSqlFilesInProjectContainingTable = getExtTablesSqlFilesInProjectContainingTable(tableName, project);
        Set<PsiElement> elements = new HashSet<>();

        PsiManager psiManager = PsiManager.getInstance(project);

        for (PsiFile virtualFile : extTablesSqlFilesInProjectContainingTable) {
            FileBasedIndex.getInstance().processValues(TablenameFileIndex.KEY, tableName, virtualFile.getVirtualFile(), (file, value) -> {

                PsiFile file1 = psiManager.findFile(file);
                if (file1 != null) {
                    PsiElement elementAt = file1.findElementAt(value.getEndOffset() - 2);
                    if (elementAt != null) {
                        elements.add(elementAt);
                    }
                }

                return true;
            }, GlobalSearchScope.allScope(project));
        }

        return elements.toArray(new PsiElement[elements.size()]);
    }
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:25,代码来源:TableUtil.java

示例3: getComponentDeclarations

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
private static List<XmlTag> getComponentDeclarations(String componentValue, String componentType, ID<String, Void> id, Project project, ComponentMatcher componentMatcher) {
    List<XmlTag> results = new ArrayList<XmlTag>();
    Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
        .getContainingFiles(
            id,
            componentValue,
            GlobalSearchScope.allScope(project)
        );
    PsiManager psiManager = PsiManager.getInstance(project);

    for (VirtualFile virtualFile: containingFiles) {
        XmlFile xmlFile = (XmlFile)psiManager.findFile(virtualFile);
        if (xmlFile == null) {
            continue;
        }

        XmlTag rootTag = xmlFile.getRootTag();
        if (rootTag == null) {
            continue;
        }
        collectComponentDeclarations(rootTag, results, componentValue, componentType, componentMatcher);
    }

    return results;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:LayoutIndex.java

示例4: getLayoutFiles

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
public static List<XmlFile> getLayoutFiles(Project project, @Nullable String fileName) {
    List<XmlFile> results = new ArrayList<XmlFile>();
    Collection<VirtualFile> xmlFiles = FilenameIndex.getAllFilesByExt(project, "xml");

    PsiManager psiManager = PsiManager.getInstance(project);
    for (VirtualFile xmlFile: xmlFiles) {
        if (isLayoutFile(xmlFile)) {
            if (fileName != null && !xmlFile.getNameWithoutExtension().equals(fileName)) {
                continue;
            }

            PsiFile file = psiManager.findFile(xmlFile);
            if (file != null) {
                results.add((XmlFile)file);
            }
        }
    }

    return results;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:21,代码来源:LayoutIndex.java

示例5: getClassConfigurations

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
public static List<XmlTag> getClassConfigurations(PhpClass phpClass) {
    String classFqn = phpClass.getPresentableFQN();

    Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
        .getContainingFiles(KEY, classFqn, GlobalSearchScope.allScope(phpClass.getProject())
    );

    PsiManager psiManager = PsiManager.getInstance(phpClass.getProject());

    List<XmlTag> tags = new ArrayList<XmlTag>();

    for (VirtualFile virtualFile: containingFiles) {
        XmlFile file = (XmlFile)psiManager.findFile(virtualFile);

        if (file == null) {
            continue;
        }

        XmlTag rootTag = file.getRootTag();
        fillRelatedTags(classFqn, rootTag, tags);
    }

    return tags;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:25,代码来源:TypeConfigurationIndex.java

示例6: getWebApiRoutes

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
/**
 * Get list of Web API routes associated with the provided method.
 *
 * Parent classes are not taken into account.
 */
public static List<XmlTag> getWebApiRoutes(Method method) {
    List<XmlTag> tags = new ArrayList<>();
    if (!method.getAccess().isPublic()) {
        return tags;
    }
    PhpClass phpClass = method.getContainingClass();
    String methodFqn = method.getName();
    if (phpClass == null) {
        return tags;
    }
    String classFqn = phpClass.getPresentableFQN();
    Collection<VirtualFile> containingFiles = FileBasedIndex
        .getInstance().getContainingFiles(KEY, classFqn, GlobalSearchScope.allScope(phpClass.getProject()));

    PsiManager psiManager = PsiManager.getInstance(phpClass.getProject());
    for (VirtualFile virtualFile : containingFiles) {
        XmlFile file = (XmlFile) psiManager.findFile(virtualFile);
        if (file == null) {
            continue;
        }
        XmlTag rootTag = file.getRootTag();
        fillRelatedTags(classFqn, methodFqn, rootTag, tags);
    }
    return tags;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:31,代码来源:WebApiTypeIndex.java

示例7: getReferencesByElement

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
    String value = StringUtil.unquoteString(element.getText());
    Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
        .getContainingFiles(EventNameIndex.KEY, value,
                GlobalSearchScope.getScopeRestrictedByFileTypes(
                        GlobalSearchScope.allScope(element.getProject()),
                        PhpFileType.INSTANCE
                )
        );

    PsiManager psiManager = PsiManager.getInstance(element.getProject());
    for (VirtualFile virtualFile: containingFiles) {
        PhpFile phpFile = (PhpFile) psiManager.findFile(virtualFile);
        if (phpFile != null) {
            List<PsiElement> psiElements = new ArrayList<>();
            recursiveFill(psiElements, phpFile, value);
            if (psiElements.size() > 0) {
                return new PsiReference[] {new PolyVariantReferenceBase(element, psiElements)};
            }
        }
    }
    return PsiReference.EMPTY_ARRAY;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:EventNameReferenceProvider.java

示例8: processPackageDirectories

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
@Override
public boolean processPackageDirectories(@NotNull PsiPackage psiPackage,
                                         @NotNull final GlobalSearchScope scope,
                                         @NotNull final Processor<PsiDirectory> consumer,
                                         boolean includeLibrarySources) {
  //System.out.println( "processDirectories() : " + psiPackage + " : " + scope );

  final PsiManager psiManager = PsiManager.getInstance( _project );
  return PackageIndex.getInstance( _project )
    .getDirsByPackageName(psiPackage.getQualifiedName(), includeLibrarySources)
    .forEach(new ReadActionProcessor<VirtualFile>() {
      @Override
      public boolean processInReadAction(final VirtualFile dir) {
        if (!scope.contains(dir)) return true;
        PsiDirectory psiDir = psiManager.findDirectory(dir);
        return psiDir == null || consumer.process(psiDir);
      }
    });
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:20,代码来源:ManTypeFinder.java

示例9: findReferences

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
public List<PsiReference> findReferences(PsiField field, int maxNumberOfResults) {
    PsiClass fieldClass = PsiTypesUtil.getPsiClass(field.getType());
    if (fieldClass == null) {
        return Collections.emptyList();
    }
    Project project = field.getProject();
    PsiManager manager = PsiManager.getInstance(project);
    JGivenUsageProvider usageProvider = new JGivenUsageProvider(scenarioStateProvider, resolutionHandler, new ReferenceFactory(manager));
    StateReferenceProcessor processor = new StateReferenceProcessor(field, maxNumberOfResults, usageProvider);

    SearchScope scope = GlobalSearchScope.everythingScope(project).intersectWith(javaFilesScope(project));

    findPsiFields(project, (GlobalSearchScope) scope, processor);
    return processor.getResults();
}
 
开发者ID:TNG,项目名称:jgiven-intellij-plugin,代码行数:16,代码来源:ScenarioStateReferenceProvider.java

示例10: loadModules

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
private void loadModules() {
    Collection<String> packages = FileBasedIndex.getInstance().getAllKeys(ModulePackageIndex.KEY, this.project);
    PsiManager psiManager = PsiManager.getInstance(this.project);
    for (String packageName: packages) {
        if (components.containsKey(packageName)) {
            continue;
        }

        Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
            .getContainingFiles(ModulePackageIndex.KEY, packageName, GlobalSearchScope.allScope(this.project));

        if (containingFiles.size() > 0) {
            VirtualFile configurationFile = containingFiles.iterator().next();

            PsiFile psiFile = psiManager.findFile(configurationFile);
            if (psiFile != null && psiFile instanceof JsonFile) {
                JsonObject jsonObject = PsiTreeUtil.getChildOfType((JsonFile) psiFile, JsonObject.class);
                if (jsonObject == null) {
                    continue;
                }

                MagentoComponent magentoComponent;
                ComposerPackageModel composerPackageModel = new ComposerPackageModelImpl(jsonObject);
                if ("magento2-module".equals(composerPackageModel.getType())) {
                    magentoComponent = new MagentoModuleImpl(new ComposerPackageModelImpl(jsonObject), psiFile.getContainingDirectory());
                } else {
                    magentoComponent = new MagentoComponentImp(new ComposerPackageModelImpl(jsonObject), psiFile.getContainingDirectory());
                }

                components.put(
                    packageName,
                    magentoComponent
                );
            }
        }
    }
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:38,代码来源:MagentoComponentManager.java

示例11: setUp

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    application = getApplication();

    final Project project = getProject();
    final PsiManager psiManager = PsiManager.getInstance(project);
    final PsiTypeConverter converter = new PsiTypeConverter(psiManager);
    underTest = new MethodNamePolicy(project, converter);
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:12,代码来源:MethodNamePolicyTest.java

示例12: setUp

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    final Project project = getProject();
    final PsiManager psiManager = PsiManager.getInstance(project);
    underTest = new PsiTypeConverter(psiManager);
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:9,代码来源:PsiTypeConverterTest.java

示例13: convertVirtualFilesToPsiFiles

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
@NotNull
public static Collection<PsiFile> convertVirtualFilesToPsiFiles(@NotNull Project project, @NotNull Collection<VirtualFile> files) {

    Collection<PsiFile> psiFiles = new HashSet<>();
    PsiManager psiManager = PsiManager.getInstance(project);

    for (VirtualFile file : files) {
        PsiFile psiFile = psiManager.findFile(file);
        if(psiFile != null) {
            psiFiles.add(psiFile);
        }
    }

    return psiFiles;
}
 
开发者ID:dmeybohm,项目名称:chocolate-cakephp,代码行数:16,代码来源:PsiUtil.java

示例14: computeChildren

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
@Override
public MultiMap<PsiFile, ConfigFileNode> computeChildren(PsiFile psiFile) {
    Project project = getProject();
    MultiMap<PsiFile, ConfigFileNode> children = new MultiMap<>();
    if (project != null) {
        PsiManager psiManager = PsiManager.getInstance(project);
        for (VirtualFile virtualFile : CoffigUtil.findCoffigFiles(getProject())) {
            PsiFile file = psiManager.findFile(virtualFile);
            children.putValue(file, new ConfigFileNode(this, psiManager.findFile(virtualFile)));
        }
    }
    return children;
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:14,代码来源:ConfigurationNode.java

示例15: createEmptyPsiField

import com.intellij.psi.PsiManager; //导入方法依赖的package包/类
protected PsiElement createEmptyPsiField() {
    final String text = "<undefined>";
    final IElementType type = CsvTypes.FIELD;
    final Project project = this.element.getProject();
    final PsiManager psiManager = PsiManager.getInstance(project);
    final DummyHolder dummyHolder = DummyHolderFactory.createHolder(psiManager, null);
    final FileElement fileElement = dummyHolder.getTreeElement();
    final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(CsvLanguage.INSTANCE);
    final Lexer lexer = parserDefinition.createLexer(project);
    final PsiBuilder psiBuilder = PsiBuilderFactory.getInstance().createBuilder(project, fileElement, lexer, CsvLanguage.INSTANCE, text);
    final ASTNode node = parserDefinition.createParser(project).parse(type, psiBuilder);
    fileElement.rawAddChildren((com.intellij.psi.impl.source.tree.TreeElement)node);
    return node.getPsi();
}
 
开发者ID:SeeSharpSoft,项目名称:intellij-csv-validator,代码行数:15,代码来源:CsvStructureViewElement.java


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