use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class XsltIncludeIndex method _process.
private static boolean _process(VirtualFile[] files, Project project, Processor<XmlFile> processor) {
final PsiManager psiManager = PsiManager.getInstance(project);
final PsiFile[] psiFiles = ContainerUtil.map2Array(files, PsiFile.class, (NullableFunction<VirtualFile, PsiFile>) file -> psiManager.findFile(file));
for (final PsiFile psiFile : psiFiles) {
if (XsltSupport.isXsltFile(psiFile)) {
if (!processor.process((XmlFile) psiFile)) {
return false;
}
}
}
return true;
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class MethodTypeInferencer method compute.
@Override
@Nullable
public PsiType compute() {
List<GrStatement> returns = ControlFlowUtils.collectReturns(myBlock);
if (returns.isEmpty())
return PsiType.VOID;
PsiType result = null;
PsiManager manager = myBlock.getManager();
for (GrStatement returnStatement : returns) {
GrExpression value = null;
if (returnStatement instanceof GrReturnStatement) {
value = ((GrReturnStatement) returnStatement).getReturnValue();
} else if (returnStatement instanceof GrExpression) {
value = (GrExpression) returnStatement;
}
if (value != null) {
result = TypesUtil.getLeastUpperBoundNullable(result, value.getType(), manager);
}
}
return result;
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class TempFileSystemTest method testMove.
public void testMove() {
ProjectRootManager rootManager = ProjectRootManager.getInstance(getProject());
VirtualFile sourceRoot = rootManager.getContentSourceRoots()[0];
PsiManager psiManager = PsiManager.getInstance(getProject());
PsiDirectory psiSourceRoot = psiManager.findDirectory(sourceRoot);
PsiFile psiFile = ApplicationManager.getApplication().runWriteAction(new Computable<PsiFile>() {
@Override
public PsiFile compute() {
return psiSourceRoot.createFile("TestDocument.xml");
}
});
PsiDirectory subdirectory = ApplicationManager.getApplication().runWriteAction(new Computable<PsiDirectory>() {
@Override
public PsiDirectory compute() {
return psiSourceRoot.createSubdirectory("com");
}
});
PlatformTestCase.move(psiFile.getVirtualFile(), subdirectory.getVirtualFile());
assertTrue(psiFile.isValid());
ApplicationManager.getApplication().runWriteAction(() -> psiFile.delete());
assertFalse(psiFile.isValid());
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class BackwardDependenciesBuilder method analyze.
@Override
public void analyze() {
final DependenciesBuilder builder = new ForwardDependenciesBuilder(getProject(), myForwardScope, getScopeOfInterest());
builder.setTotalFileCount(myTotalFileCount);
builder.analyze();
subtractScope(builder, getScope());
final PsiManager psiManager = PsiManager.getInstance(getProject());
psiManager.startBatchFilesProcessingMode();
try {
final int fileCount = getScope().getFileCount();
final boolean includeTestSource = getScope().isIncludeTestSource();
getScope().accept(virtualFile -> {
if (!includeTestSource && TestSourcesFilter.isTestSources(virtualFile, getProject())) {
return true;
}
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
if (indicator.isCanceled()) {
throw new ProcessCanceledException();
}
indicator.setText(AnalysisScopeBundle.message("package.dependencies.progress.text"));
indicator.setText2(getRelativeToProjectPath(virtualFile));
if (fileCount > 0) {
indicator.setFraction(((double) ++myFileCount) / myTotalFileCount);
}
}
ApplicationManager.getApplication().runReadAction(() -> {
PsiFile file = psiManager.findFile(virtualFile);
if (file != null) {
final PsiElement navigationElement = file.getNavigationElement();
if (navigationElement instanceof PsiFile) {
file = (PsiFile) navigationElement;
}
final Map<PsiFile, Set<PsiFile>> dependencies = builder.getDependencies();
for (final PsiFile psiFile : dependencies.keySet()) {
if (dependencies.get(psiFile).contains(file)) {
Set<PsiFile> fileDeps = getDependencies().get(file);
if (fileDeps == null) {
fileDeps = new HashSet<>();
getDependencies().put(file, fileDeps);
}
fileDeps.add(psiFile);
}
}
psiManager.dropResolveCaches();
}
});
return true;
});
} finally {
psiManager.finishBatchFilesProcessingMode();
}
}
use of com.intellij.psi.PsiManager in project intellij-community by JetBrains.
the class GoToLinkTargetAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = getEventProject(e);
VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
if (project != null && file != null && file.is(VFileProperty.SYMLINK)) {
VirtualFile target = file.getCanonicalFile();
if (target != null) {
PsiManager psiManager = PsiManager.getInstance(project);
PsiFileSystemItem psiFile = target.isDirectory() ? psiManager.findDirectory(target) : psiManager.findFile(target);
if (psiFile != null) {
ProjectView.getInstance(project).select(psiFile, target, false);
}
}
}
}
Aggregations