本文整理匯總了Java中com.intellij.psi.PsiFile.accept方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiFile.accept方法的具體用法?Java PsiFile.accept怎麽用?Java PsiFile.accept使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.PsiFile
的用法示例。
在下文中一共展示了PsiFile.accept方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getIndexer
import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@NotNull
@Override
public DataIndexer<String, Set<String>, FileContent> getIndexer() {
return inputData -> {
final Map<String, Set<String>> map = new THashMap<>();
PsiFile psiFile = inputData.getPsiFile();
if (psiFile instanceof PhpFile) {
Map<String, ArrayList<TYPO3ServiceDefinition>> serviceMap = new THashMap<>();
psiFile.accept(new CoreServiceDefinitionParserVisitor(serviceMap));
serviceMap.forEach((serviceId, definitionList) -> {
Set<String> implementations = new HashSet<>();
definitionList.forEach(typo3ServiceDefinition -> implementations.add(typo3ServiceDefinition.getClassName()));
map.put(serviceId, implementations);
});
}
return map;
};
}
示例2: collectServices
import com.intellij.psi.PsiFile; //導入方法依賴的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));
}
}
}
示例3: removeRedundantAnnotationsInPackage
import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
private void removeRedundantAnnotationsInPackage(Project project, PsiFile[] files, PsiAnnotation annotation) {
if (!removeRedundantAnnotations)
{
return;
}
List<String> redundantAnnotations = nullable
? NullableNotNullManager.getInstance(project).getNullables()
: NullableNotNullManager.getInstance(project).getNotNulls();
Set<PsiAnnotation.TargetType> targetsForDefaultAnnotation = targetTypesForDefault(annotation);
if (targetsForDefaultAnnotation == null) {
return;
}
for (PsiFile file : files) {
if (file instanceof PsiJavaFile) {
JavaElementVisitor visitor = new JavaElementVisitor() {
@Override
public void visitMethod(@Nonnull PsiMethod method) {
removeRedundantAnnotations(method, redundantAnnotations, targetsForDefaultAnnotation);
}
@Override
public void visitParameter(@Nonnull PsiParameter parameter) {
removeRedundantAnnotations(parameter, redundantAnnotations, targetsForDefaultAnnotation);
}
@Override
public void visitField(@Nonnull PsiField field) {
removeRedundantAnnotations(field, redundantAnnotations, targetsForDefaultAnnotation);
}
@Override
public void visitLocalVariable(@Nonnull PsiLocalVariable variable) {
super.visitLocalVariable(variable);
}
};
PsiRecursiveElementWalkingVisitor recursiveVisitor = new PsiRecursiveElementWalkingVisitor() {
@Override
public void visitElement(@Nonnull PsiElement element) {
element.accept(visitor);
super.visitElement(element);
}
};
file.accept(recursiveVisitor);
JavaCodeStyleManager.getInstance(project).optimizeImports(file);
}
}
}
開發者ID:stylismo,項目名稱:nullability-annotations-inspection,代碼行數:55,代碼來源:AddPackageInfoWithNullabilityDefaultsFix.java