use of com.intellij.psi.PsiFile in project intellij-community by JetBrains.
the class CollapseTagTest method testAvailable.
public void testAvailable() throws Exception {
PsiFile file = myFixture.configureByText(XmlFileType.INSTANCE, "<a> <caret> </a>");
assertTrue(new CollapseTagIntention().isAvailable(getProject(), myFixture.getEditor(), file));
}
use of com.intellij.psi.PsiFile in project intellij-community by JetBrains.
the class CollapseTagTest method testAlreadyCollapsed.
public void testAlreadyCollapsed() throws Exception {
PsiFile file = myFixture.configureByText(XmlFileType.INSTANCE, "<a/>");
assertFalse(new CollapseTagIntention().isAvailable(getProject(), myFixture.getEditor(), file));
}
use of com.intellij.psi.PsiFile in project intellij-community by JetBrains.
the class CollapseTagTest method testNotAvailable.
public void testNotAvailable() throws Exception {
PsiFile file = myFixture.configureByText(XmlFileType.INSTANCE, "<a> <caret> <b/> </a>");
assertFalse(new CollapseTagIntention().isAvailable(getProject(), myFixture.getEditor(), file));
}
use of com.intellij.psi.PsiFile in project intellij-plugins by StepicOrg.
the class ProgrammingLanguageUtils method switchProgrammingLanguage.
public static void switchProgrammingLanguage(@NotNull Project project, @NotNull StepNode targetStepNode, @NotNull SupportedLanguages language) {
if (!targetStepNode.getSupportedLanguages().contains(language)) {
return;
}
SupportedLanguages currentLang = targetStepNode.getCurrentLang();
String currentMainFileName = currentLang.getMainFileName();
String mainFilePath = String.join("/", targetStepNode.getPath(), EduNames.SRC, currentMainFileName);
VirtualFile mainFile = project.getBaseDir().findFileByRelativePath(mainFilePath);
boolean mainFileExists = mainFile != null;
if (currentLang == language && mainFileExists) {
return;
}
if (currentMainFileName.equals(language.getMainFileName()) && mainFileExists) {
targetStepNode.setCurrentLang(language);
Metrics.switchLanguage(project, targetStepNode, SUCCESSFUL);
return;
}
PsiDirectory src = getOrCreateSrcPsiDirectory(project, targetStepNode);
if (src == null) {
return;
}
PsiDirectory hide = getOrCreatePsiDirectory(project, src, EduNames.HIDE);
if (hide == null) {
return;
}
PsiFile second = findFile(src, language.getMainFileName());
boolean moveSecond = second == null;
if (moveSecond) {
second = getOrCreateMainFile(project, hide.getVirtualFile(), language, targetStepNode);
if (second == null) {
logger.error("Can't create Main file: " + language.getMainFileName());
return;
}
}
PsiFile first = findFile(hide, currentMainFileName);
boolean moveFirst = first == null;
if (moveFirst) {
first = findFile(src, currentMainFileName);
moveFirst = !second.isEquivalentTo(first);
}
targetStepNode.setCurrentLang(language);
ArrayList<VirtualFile> needClose = closeStepNodeFile(project, targetStepNode);
PsiFile finalSecond = second;
PsiFile finalFirst = first;
boolean finalMoveFirst = moveFirst;
ApplicationManager.getApplication().invokeAndWait(() -> {
FileEditorManager.getInstance(project).openFile(finalSecond.getVirtualFile(), true);
FileEditorManager editorManager = FileEditorManager.getInstance(project);
needClose.forEach(editorManager::closeFile);
exchangeFiles(src, hide, finalFirst, finalSecond, finalMoveFirst, moveSecond);
ProjectView.getInstance(project).selectPsiElement(finalSecond, false);
});
Metrics.switchLanguage(project, targetStepNode, SUCCESSFUL);
}
use of com.intellij.psi.PsiFile in project Main by SpartanRefactoring.
the class ToolboxTest method testCheckExcluded.
public void testCheckExcluded() throws Exception {
tb.initComponent();
PsiFile f = createTestFileFromString("class A{}");
tb.excludeFile(f);
assertTrue(tb.checkExcluded(f));
tb.includeFile(f);
assertFalse(tb.checkExcluded(f));
tb.disposeComponent();
}
Aggregations