本文整理匯總了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;
}
示例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()]);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
});
}
示例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();
}
示例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
);
}
}
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}