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


Java PsiManager類代碼示例

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


PsiManager類屬於com.intellij.psi包,在下文中一共展示了PsiManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDocumentationElementForLookupItem

import com.intellij.psi.PsiManager; //導入依賴的package包/類
@Override
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object,
    @Nullable PsiElement element) {
  if (object instanceof Suggestion) {
    Suggestion suggestion = Suggestion.class.cast(object);
    MetadataNode target = suggestion.getRef();
    boolean requestedForTargetValue = suggestion.isReferringToValue();
    String text = null;
    if (element != null) {
      text = element.getText();
    }
    return new DocumentationProxyElement(psiManager, JavaLanguage.INSTANCE, target,
        requestedForTargetValue, text);
  }
  return super.getDocumentationElementForLookupItem(psiManager, object, element);
}
 
開發者ID:1tontech,項目名稱:intellij-spring-assistant,代碼行數:17,代碼來源:PropertiesDocumentationProvider.java

示例2: generate

import com.intellij.psi.PsiManager; //導入依賴的package包/類
@Override
public Set<TSVarExpr> generate(Project project) {
    Set<TSVarExpr> items = new HashSet<>();
    //Search every file in the project
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, TSFileType.INSTANCE, GlobalSearchScope.projectScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        TSFile tsFile = (TSFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (tsFile != null) {
            Collection<TSAssignExpr> assignments = PsiTreeUtil.findChildrenOfType(tsFile, TSAssignExpr.class);
            for (TSAssignExpr assignment : assignments) {
                PsiElement first = assignment.getFirstChild();
                if (!(first instanceof TSVarExpr))
                    continue;

                if (((TSVarExpr)first).isLocal())
                    continue;

                items.add((TSVarExpr) first);

            }
        }
        ProgressManager.progress("Loading Symbols");
    }
    return items;
}
 
開發者ID:CouleeApps,項目名稱:TS-IJ,代碼行數:26,代碼來源:TSGlobalCachedListGenerator.java

示例3: getDictionaryFileFromInclude

import com.intellij.psi.PsiManager; //導入依賴的package包/類
@Nullable
private static XmlFile getDictionaryFileFromInclude(@NotNull Project project, IncludedXmlTag xmlIncludeTag) {
  XmlFile xmlFile = null;
  XmlElement origXmlElement = xmlIncludeTag.getOriginal();
  PsiFile origPsiFile = origXmlElement != null ? origXmlElement.getContainingFile() : null;
  if (origPsiFile instanceof XmlFile) {
    xmlFile = (XmlFile) origPsiFile;
    AppleScriptSystemDictionaryRegistryService dictionaryService = ServiceManager.getService(AppleScriptSystemDictionaryRegistryService
        .class);
    VirtualFile vFile = origPsiFile.getVirtualFile();
    DictionaryInfo dInfo = dictionaryService.getDictionaryInfoByApplicationPath(vFile.getPath());
    if (dInfo != null) {
      File ioFile = dInfo.getDictionaryFile();
      if (ioFile.exists()) {
        vFile = LocalFileSystem.getInstance().findFileByIoFile(ioFile);
        if (vFile == null || !vFile.isValid()) return null;

        PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
        xmlFile = (XmlFile) psiFile;
      }
    }
  }
  return xmlFile;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:25,代碼來源:SDEF_Parser.java

示例4: createDictionaryFromInfo

import com.intellij.psi.PsiManager; //導入依賴的package包/類
@Nullable
private ApplicationDictionary createDictionaryFromInfo(final @NotNull DictionaryInfo dInfo) {
  if (!dInfo.isInitialized()) {
    //dictionary terms must be ridden from the dictionary file before creating a PSI for it
    LOG.error("Attempt to create dictionary for not initialized Dictionary Info for application" + dInfo.getApplicationName());
    return null;
  }
  String applicationName = dInfo.getApplicationName();
  VirtualFile vFile = LocalFileSystem.getInstance().findFileByIoFile(dInfo.getDictionaryFile());
  if (vFile != null && vFile.isValid()) {
    PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
    XmlFile xmlFile = (XmlFile) psiFile;
    if (xmlFile != null) {
      ApplicationDictionary dictionary = new ApplicationDictionaryImpl(project, xmlFile, applicationName, dInfo.getApplicationFile());
      dictionaryMap.put(applicationName, dictionary);
      return dictionary;
    }
  }
  LOG.warn("Failed to create dictionary from info for application: " + applicationName + ". Reason: file is null");
  return null;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:22,代碼來源:AppleScriptProjectDictionaryService.java

示例5: makeDefaultParameterizedTypeForCompoundType

import com.intellij.psi.PsiManager; //導入依賴的package包/類
private static PsiType makeDefaultParameterizedTypeForCompoundType( PsiIntersectionType type, PsiManager mgr )
{
  PsiType[] types = type.getConjuncts();
  PsiType[] defCompTypes = new PsiType[types.length];
  int i = 0;
  boolean bDifferent = false;
  for( PsiType compType : types )
  {
    defCompTypes[i++] = getDefaultParameterizedType( compType, mgr );
    bDifferent = bDifferent || !defCompTypes[i].equals( compType );
  }
  if( bDifferent )
  {
    return PsiIntersectionType.createIntersection( defCompTypes );
  }
  return type;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:18,代碼來源:TypeUtil.java

示例6: findModules

import com.intellij.psi.PsiManager; //導入依賴的package包/類
@NotNull
public static List<PsiModule> findModules(@NotNull Project project, @NotNull String name) {
    ArrayList<PsiModule> result = new ArrayList<>();

    Collection<VirtualFile> virtualFiles = FilenameIndex.getAllFilesByExt(project, RmlFileType.INSTANCE.getDefaultExtension());
    for (VirtualFile virtualFile : virtualFiles) {
        PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
        PsiModule[] modules = PsiTreeUtil.getChildrenOfType(file, PsiModule.class);
        if (modules != null) {
            for (PsiModule module : modules) {
                if (name.equals(module.getName())) {
                    result.add(module);
                }
            }
        }
    }

    return result;
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:20,代碼來源:RmlPsiUtil.java

示例7: findElementsForKey

import com.intellij.psi.PsiManager; //導入依賴的package包/類
public static PsiElement[] findElementsForKey(@NotNull Project project, @NotNull String identifier) {
    Set<String> keys = new HashSet<>();
    keys.add(identifier);
    Set<PsiElement> elements = new HashSet<>();

    FileBasedIndex.getInstance().getFilesWithKey(ResourcePathIndex.KEY, keys, virtualFile -> {
        elements.add(PsiManager.getInstance(project).findFile(virtualFile));

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

    return elements
            .stream()
            .filter(Objects::nonNull)
            .toArray(PsiElement[]::new);
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:17,代碼來源:ResourcePathIndex.java

示例8: getIconDefinitionElements

import com.intellij.psi.PsiManager; //導入依賴的package包/類
@NotNull
public static PsiElement[] getIconDefinitionElements(@NotNull Project project, @NotNull String identifier) {
    Map<VirtualFile, IconStub> iconDefinitionByIdentifier = getIconDefinitionByIdentifier(project, identifier);
    if (iconDefinitionByIdentifier.size() > 0) {
        return iconDefinitionByIdentifier
                .keySet()
                .stream()
                .map(virtualFile -> {
                    IconStub iconStub = iconDefinitionByIdentifier.get(virtualFile);
                    PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
                    return file != null ? file.findElementAt(iconStub.getTextRange().getStartOffset()) : null;
                })
                .filter(Objects::nonNull)
                .toArray(PsiElement[]::new);
    }

    return new PsiElement[0];
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:19,代碼來源:IconIndex.java

示例9: findDefinitionElements

import com.intellij.psi.PsiManager; //導入依賴的package包/類
public static PsiElement[] findDefinitionElements(@NotNull Project project, @NotNull String translationId) {
    Set<String> keys = new HashSet<>();
    keys.add(translationId);

    List<PsiElement> elements = new ArrayList<>();
    FileBasedIndex.getInstance().getFilesWithKey(TranslationIndex.KEY, keys, virtualFile -> {
        FileBasedIndex.getInstance().processValues(TranslationIndex.KEY, translationId, virtualFile, (file, value) -> {
            PsiFile file1 = PsiManager.getInstance(project).findFile(file);
            if (file1 != null) {
                PsiElement elementAt = file1.findElementAt(value.getTextRange().getStartOffset());
                if (elementAt != null) {
                    elements.add(elementAt.getParent());
                }
            }

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

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

    return elements.toArray(new PsiElement[elements.size()]);
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:24,代碼來源:TranslationUtil.java

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

示例11: getDefinitionElements

import com.intellij.psi.PsiManager; //導入依賴的package包/類
public static PsiElement[] getDefinitionElements(@NotNull Project project, @NotNull String actionName) {
    Set<String> keys = new HashSet<>();
    keys.add(actionName);

    List<PsiElement> elements = new ArrayList<>();
    FileBasedIndex.getInstance().getFilesWithKey(ControllerActionIndex.KEY, keys, virtualFile -> {
        FileBasedIndex.getInstance().processValues(ControllerActionIndex.KEY, actionName, virtualFile, (file, value) -> {
            PsiFile file1 = PsiManager.getInstance(project).findFile(file);
            if (file1 != null) {
                PsiElement elementAt = file1.findElementAt(value.getTextRange().getStartOffset());
                if (elementAt != null) {
                    elements.add(elementAt.getParent().getParent());
                }
            }

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

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

    return elements.toArray(new PsiElement[elements.size()]);
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:24,代碼來源:ControllerActionUtil.java

示例12: collectServices

import com.intellij.psi.PsiManager; //導入依賴的package包/類
private void collectServices(Project project) {
    FileBasedIndex index = FileBasedIndex.getInstance();
    Collection<VirtualFile> containingFiles = index.getContainingFiles(
            FileTypeIndex.NAME,
            PhpFileType.INSTANCE,
            GlobalSearchScope.allScope(project)
    );
    containingFiles.removeIf(virtualFile -> !(virtualFile.getName().contains("ext_localconf.php")));

    for (VirtualFile projectFile : containingFiles) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(projectFile);
        if (psiFile != null) {
            psiFile.accept(new CoreServiceDefinitionParserVisitor(serviceMap));
        }
    }
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:17,代碼來源:CoreServiceParser.java

示例13: findProperties

import com.intellij.psi.PsiManager; //導入依賴的package包/類
public static List<GCMTypeDeclaration> findProperties(Project project) {
    final List<GCMTypeDeclaration> result = new ArrayList<GCMTypeDeclaration>();
    Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, GCMLanguageType.INSTANCE,
            GlobalSearchScope.allScope(project));
    for (VirtualFile virtualFile : virtualFiles) {
        GCMFile simpleFile = (GCMFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (simpleFile != null) {
            simpleFile.acceptChildren(new PsiElementVisitor() {
                @Override
                public void visitElement(PsiElement element) {
                    if (element instanceof GCMDeclaration) {
                        GCMDeclaration declaration = (GCMDeclaration) element;
                        if (declaration.getClassDeclaration() != null) {
                            result.add(declaration.getClassDeclaration().getTypeDeclaration());
                        }
                        if (declaration.getCustomTypeDeclaration() != null) {
                            //result.add(declaration.getCustomTypeDeclaration().getTypeDeclaration());
                        }
                    }
                    super.visitElement(element);
                }
            });
        }
    }
    return result;
}
 
開發者ID:datathings,項目名稱:greycat-idea-plugin,代碼行數:27,代碼來源:GCMUtil.java

示例14: getVirtualTypeElements

import com.intellij.psi.PsiManager; //導入依賴的package包/類
public Collection<PsiElement> getVirtualTypeElements(final String name, final GlobalSearchScope scope) {
    Collection<PsiElement> result = new ArrayList<>();

    Collection<VirtualFile> virtualFiles =
            FileBasedIndex.getInstance().getContainingFiles(VirtualTypeIndex.KEY, name, scope);

    for (VirtualFile virtualFile : virtualFiles) {
        XmlFile xmlFile = (XmlFile) PsiManager.getInstance(project).findFile(virtualFile);
        if (xmlFile != null) {
            Collection<XmlAttributeValue> valueElements = XmlPsiTreeUtil
                    .findAttributeValueElements(xmlFile, "virtualType", "name", name);
            result.addAll(valueElements);
        }
    }
    return result;
}
 
開發者ID:magento,項目名稱:magento2-phpstorm-plugin,代碼行數:17,代碼來源:DiIndex.java

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


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