use of com.igormaznitsa.ideamindmap.lang.psi.PsiExtraFile in project netbeans-mmd-plugin by raydac.
the class IdeaUtils method findPsiFileLinksForProjectScope.
public static List<PsiExtraFile> findPsiFileLinksForProjectScope(final Project project) {
List<PsiExtraFile> result = new ArrayList<PsiExtraFile>();
Collection<VirtualFile> virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, MindMapFileType.INSTANCE, GlobalSearchScope.allScope(project));
for (VirtualFile virtualFile : virtualFiles) {
final MMDFile simpleFile = (MMDFile) PsiManager.getInstance(project).findFile(virtualFile);
if (simpleFile != null) {
final PsiExtraFile[] fileLinks = PsiTreeUtil.getChildrenOfType(simpleFile, PsiExtraFile.class);
if (fileLinks != null) {
Collections.addAll(result, fileLinks);
}
}
}
return result;
}
use of com.igormaznitsa.ideamindmap.lang.psi.PsiExtraFile in project netbeans-mmd-plugin by raydac.
the class RefactoringUtils method replaceMMUriToNewFile.
@Nonnull
public static String replaceMMUriToNewFile(@Nonnull final PsiExtraFile mindMapFile, @Nonnull final MMapURI oldFile, @Nonnull final MMapURI newFile) throws IOException {
final File projectFolder = IdeaUtils.findProjectFolder(mindMapFile);
if (projectFolder == null)
throw new NullPointerException("Project folder is not found for " + mindMapFile);
final MindMap parsedMap = new MindMap(null, new StringReader(mindMapFile.getContainingFile().getText()));
parsedMap.replaceAllLinksToFile(projectFolder, oldFile, newFile);
return parsedMap.write(new StringWriter(16384)).toString();
}
use of com.igormaznitsa.ideamindmap.lang.psi.PsiExtraFile in project netbeans-mmd-plugin by raydac.
the class PsiExtraFileReferenceProvider method getReferencesByElement.
@Nonnull
@Override
public PsiReference[] getReferencesByElement(@Nonnull PsiElement element, @Nonnull ProcessingContext context) {
PsiReference[] result = PsiReference.EMPTY_ARRAY;
final PsiExtraFile extraFile = (PsiExtraFile) element;
final VirtualFile targetFile = extraFile.findTargetFile();
if (targetFile != null) {
final TextRange range = new TextRange(0, extraFile.getTextLength());
result = new PsiReference[] { new PsiExtraFileReference(extraFile, range) };
}
return result;
}
Aggregations