當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiManager.findFile方法代碼示例

本文整理匯總了Java中com.intellij.psi.PsiManager.findFile方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiManager.findFile方法的具體用法?Java PsiManager.findFile怎麽用?Java PsiManager.findFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.PsiManager的用法示例。


在下文中一共展示了PsiManager.findFile方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: initialize

import com.intellij.psi.PsiManager; //導入方法依賴的package包/類
public void initialize( PsiClass delegate, List<IFile> files, String fqn, DiagnosticCollector issues )
{
  _ifiles = files;
  _fqn = fqn;
  _issues = issues;
  PsiManager manager = PsiManagerImpl.getInstance( delegate.getProject() );
  _files = new ArrayList<>( _ifiles.size() );
  for( IFile ifile : _ifiles )
  {
    VirtualFile vfile = ((IjFile)ifile).getVirtualFile();
    if( vfile != null )
    {
      PsiFile file = manager.findFile( vfile );
      _files.add( file );

      Module module = ModuleUtilCore.findModuleForFile( vfile, delegate.getProject() );
      if( module != null )
      {
        file.putUserData( ModuleUtil.KEY_MODULE, module );
      }
    }
  }
  delegate.getContainingFile().putUserData( KEY_MANIFOLD_PSI_CLASS, this );
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:25,代碼來源:ManifoldPsiClass.java

示例8: 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

示例9: 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

示例10: 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

示例11: convertVirtualFileToPsiFile

import com.intellij.psi.PsiManager; //導入方法依賴的package包/類
@Nullable
public static PsiFile convertVirtualFileToPsiFile(@NotNull Project project, @NotNull VirtualFile file) {
    PsiManager psiManager = PsiManager.getInstance(project);
    return psiManager.findFile(file);
}
 
開發者ID:dmeybohm,項目名稱:chocolate-cakephp,代碼行數:6,代碼來源:PsiUtil.java


注:本文中的com.intellij.psi.PsiManager.findFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。