use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class ReformatFilesWithFiltersTest method testDirectoryScopeWithMask.
public void testDirectoryScopeWithMask() throws IOException {
TestFileStructure fileTree = new TestFileStructure(getModule(), myWorkingDirectory);
PsiFile java1 = fileTree.addTestFile("Test1.java", "empty content");
PsiFile php1 = fileTree.addTestFile("Pair1.php", "empty content");
PsiFile js1 = fileTree.addTestFile("Pair1.js", "empty content");
PsiDirectory outer = fileTree.createDirectoryAndMakeItCurrent("toFormat");
PsiFile java2 = fileTree.addTestFile("Test2.java", "empty content");
PsiFile php2 = fileTree.addTestFile("Pair2.php", "empty content");
PsiFile js2 = fileTree.addTestFile("Pair2.js", "empty content");
PsiDirectory inner = fileTree.createDirectoryAndMakeItCurrent("toFormat");
PsiFile java3 = fileTree.addTestFile("Test3.java", "empty content");
PsiFile php3 = fileTree.addTestFile("Pair3.php", "empty content");
PsiFile js3 = fileTree.addTestFile("Pair3.js", "empty content");
reformatDirectory(myWorkingDirectory, "*.js", directoryScope(outer, true));
assertWasFormatted(js2, js3);
assertWasNotFormatted(java1, php1, js1, java2, php2, java3, php3);
reformatDirectory(myWorkingDirectory, "*.js", directoryScope(myWorkingDirectory, false));
assertWasFormatted(js1);
assertWasNotFormatted(js2, js3, java1, php1, java2, php2, java3, php3);
reformatDirectory(myWorkingDirectory, "*.java, *.php", directoryScope(myWorkingDirectory, false).union(directoryScope(inner, false)));
assertWasFormatted(java1, php1, java3, php3);
assertWasNotFormatted(java2, php2, js1, js2, js3);
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class ReformatFilesWithFiltersTest method testIDEA126830.
public void testIDEA126830() throws IOException {
TestFileStructure fileTree = new TestFileStructure(getModule(), myWorkingDirectory);
fileTree.createDirectoryAndMakeItCurrent("src");
PsiFile java2 = fileTree.addTestFile("Test2.tj", "empty content");
PsiFile php2 = fileTree.addTestFile("Pair2.php", "empty content");
PsiFile js2 = fileTree.addTestFile("Pair2.js", "empty content");
PsiDirectory test = fileTree.createDirectoryAndMakeItCurrent("test");
PsiFile testJava1 = fileTree.addTestFile("testJava1.tj", "empty content");
PsiFile testPhp1 = fileTree.addTestFile("testPhp1.php", "empty content");
PsiFile testJs1 = fileTree.addTestFile("testJs1.js", "empty content");
GlobalSearchScope testScope = directoryScope(test, true);
reformatAndOptimize(myWorkingDirectory, testScope);
assertWasFormatted(testJava1, testPhp1, testJs1);
assertWasNotFormatted(java2, php2, js2);
}
use of com.intellij.psi.PsiDirectory in project intellij-community by JetBrains.
the class ReformatOnlyVcsChangedTextTest method testReformatInAllSubtree.
public void testReformatInAllSubtree() throws IOException {
ChangedFilesStructure fs = new ChangedFilesStructure(myWorkingDirectory);
PsiFile modified11 = fs.createFile("Test4.java", COMMITTED, MODIFIED);
PsiFile modified12 = fs.createFile("Test5.java", COMMITTED, MODIFIED);
fs.createDirectoryAndMakeItCurrent();
PsiDirectory dirToReformat = fs.getCurrentDirectory();
PsiFile modified21 = fs.createFile("Test6.java", COMMITTED, MODIFIED);
PsiFile modified22 = fs.createFile("Test7.java", COMMITTED, MODIFIED);
fs.createDirectoryAndMakeItCurrent();
PsiFile modified31 = fs.createFile("Test8.java", COMMITTED, MODIFIED);
PsiFile modified32 = fs.createFile("Test9.java", COMMITTED, MODIFIED);
reformatDirectory(dirToReformat);
assertFormattedLines(CHANGED_LINES, modified21, modified22, modified31, modified32);
assertFormattedLines(NO_CHANGED_LINES, modified11, modified12);
}
use of com.intellij.psi.PsiDirectory in project intellij-plugins by JetBrains.
the class CfmlFileReferenceInspection method buildVisitor.
@NotNull
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
return new PsiElementVisitor() {
public void visitElement(final PsiElement element) {
PsiElement tagParent = PsiTreeUtil.getParentOfType((element), CfmlTag.class);
if ((element.getNode().getElementType() == CfmlTokenTypes.STRING_TEXT)) {
if ((tagParent == null || (!((CfmlTag) tagParent).getTagName().equalsIgnoreCase("cfinclude") && !((CfmlTag) tagParent).getTagName().equalsIgnoreCase("cfmodule")))) {
PsiElement superParent = element.getParent() != null ? element.getParent().getParent() : null;
ASTNode superParentNode = superParent != null ? superParent.getNode() : null;
if ((superParentNode == null || superParentNode.getElementType() != CfmlElementTypes.INCLUDEEXPRESSION)) {
return;
}
}
final PsiReference[] refs = element.getParent().getReferences();
for (int i = 0, refsLength = refs.length; i < refsLength; i++) {
PsiReference ref = refs[i];
if (!(ref instanceof FileReference))
continue;
if (ref.resolve() == null) {
PsiDirectory dir;
if (i > 0) {
final PsiElement target = refs[i - 1].resolve();
dir = target instanceof PsiDirectory ? (PsiDirectory) target : null;
} else {
dir = element.getContainingFile().getParent();
}
holder.registerProblem(ref.getElement(), ref.getRangeInElement(), isOnTheFly ? "Path '" + ref.getCanonicalText() + "' not found" : "Path not found", isOnTheFly && dir != null ? new LocalQuickFix[] { new CreateFileFix(i < refs.length - 1, ref.getCanonicalText(), dir) } : LocalQuickFix.EMPTY_ARRAY);
// ProblemHighlightType.ERROR);
break;
}
}
}
}
};
}
use of com.intellij.psi.PsiDirectory in project intellij-plugins by JetBrains.
the class CucumberJavaAllFeaturesInFolderRunConfigurationProducer method getStepsGlue.
@Override
protected NullableComputable<String> getStepsGlue(@NotNull final PsiElement element) {
final Set<String> glues = getHookGlue(element);
if (element instanceof PsiDirectory) {
final PsiDirectory dir = (PsiDirectory) element;
final CucumberJvmExtensionPoint[] extensions = Extensions.getExtensions(CucumberJvmExtensionPoint.EP_NAME);
return new NullableComputable<String>() {
@Nullable
@Override
public String compute() {
dir.accept(new PsiElementVisitor() {
@Override
public void visitFile(final PsiFile file) {
if (file instanceof GherkinFile) {
for (CucumberJvmExtensionPoint extension : extensions) {
extension.getGlues((GherkinFile) file, glues);
}
}
}
@Override
public void visitDirectory(PsiDirectory dir) {
for (PsiDirectory subDir : dir.getSubdirectories()) {
subDir.accept(this);
}
for (PsiFile file : dir.getFiles()) {
file.accept(this);
}
}
});
return StringUtil.join(glues, " ");
}
};
}
return null;
}
Aggregations