Search in sources :

Example 31 with PsiFile

use of com.intellij.psi.PsiFile in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoCompletionTest method testImportsPriority.

public void testImportsPriority() {
    myFixture.addFileToProject("package/long/but/similar/path/test.go", "package pack");
    myFixture.addFileToProject("package/very/long/path/test.go", "package pack");
    myFixture.addFileToProject("package/middle/path/test.go", "package pack");
    myFixture.addFileToProject("package/short/test.go", "package pack");
    PsiFile testFile = myFixture.addFileToProject("package/long/but/similar/test.go", "package pack; import `package/<caret>`");
    myFixture.configureFromExistingVirtualFile(testFile.getVirtualFile());
    myFixture.completeBasic();
    myFixture.assertPreferredCompletionItems(0, "package/long/but/similar/path", "package/short", "package/middle/path", "package/very/long/path");
}
Also used : PsiFile(com.intellij.psi.PsiFile)

Example 32 with PsiFile

use of com.intellij.psi.PsiFile in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoHighlightingTest method testMethodOnNonLocalTypeInTheSameDirectory.

public void testMethodOnNonLocalTypeInTheSameDirectory() {
    myFixture.addFileToProject("method/foo.go", "package a; type H struct {}");
    PsiFile psiFile = myFixture.addFileToProject("method/foo_test.go", "package a_test;\n" + "func (<error descr=\"Unresolved type 'H'\">H</error>) Hello() {}");
    myFixture.configureFromExistingVirtualFile(psiFile.getVirtualFile());
    myFixture.checkHighlighting();
}
Also used : PsiFile(com.intellij.psi.PsiFile)

Example 33 with PsiFile

use of com.intellij.psi.PsiFile in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoHighlightingTest method testDuplicatePackageImport.

public void testDuplicatePackageImport() {
    myFixture.addFileToProject("pack/pack1.go", "package pack; func Foo() {}");
    PsiFile file = myFixture.addFileToProject("pack3/pack3.go", "package main; import \"pack\"; import <error>\"pack\"</error>; func main() { pack.Foo() }");
    myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    myFixture.checkHighlighting();
}
Also used : PsiFile(com.intellij.psi.PsiFile)

Example 34 with PsiFile

use of com.intellij.psi.PsiFile in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoHighlightingTest method testDuplicatePackageAlias.

public void testDuplicatePackageAlias() {
    myFixture.addFileToProject("pack1/pack1.go", "package pack1; func Foo() {}");
    myFixture.addFileToProject("pack2/pack2.go", "package pack2");
    PsiFile file = myFixture.addFileToProject("pack3/pack3.go", "package main; import p \"pack1\"; import <error>p \"pack2\"</error>; func main() { p.Foo() }");
    myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    myFixture.checkHighlighting();
}
Also used : PsiFile(com.intellij.psi.PsiFile)

Example 35 with PsiFile

use of com.intellij.psi.PsiFile in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoInvalidPackageImportInspectionTest method testImportPackageWithoutBuildableSource.

public void testImportPackageWithoutBuildableSource() {
    PsiFile file = myFixture.addFileToProject("withSources/a.go", "package withSources");
    myFixture.addFileToProject("withIgnoredFiles/a.go", "package documentation");
    myFixture.addFileToProject("withIgnoredFiles/.b.go", "package withIgnoredFiles");
    myFixture.addFileToProject("withIgnoredFiles/_b.go", "package withIgnoredFiles");
    WriteCommandAction.runWriteCommandAction(myFixture.getProject(), () -> {
        //noinspection ConstantConditions
        file.getParent().getParent().createSubdirectory("withoutSources");
    });
    myFixture.configureByText("a.go", "package pack\n" + "import `withSources`\n" + "import <error descr=\"'/src/withIgnoredFiles' has no buildable Go source files\">`withIgnoredFiles`</error>\n" + "import <error descr=\"'/src/withoutSources' has no buildable Go source files\">`withoutSources`</error>\n" + "import <error descr=\"'/src/withoutSources' has no buildable Go source files\">_ `without<caret>Sources`</error>\n" + "import `unresolved`\n");
    myFixture.checkHighlighting();
    applySingleQuickFix(GoDeleteImportQuickFix.QUICK_FIX_NAME);
    myFixture.checkResult("package pack\n" + "import `withSources`\n" + "import `withIgnoredFiles`\n" + "import `withoutSources`\n" + "import `unresolved`\n");
}
Also used : PsiFile(com.intellij.psi.PsiFile)

Aggregations

PsiFile (com.intellij.psi.PsiFile)1785 VirtualFile (com.intellij.openapi.vfs.VirtualFile)496 PsiElement (com.intellij.psi.PsiElement)468 Project (com.intellij.openapi.project.Project)267 Nullable (org.jetbrains.annotations.Nullable)267 NotNull (org.jetbrains.annotations.NotNull)248 Document (com.intellij.openapi.editor.Document)181 Editor (com.intellij.openapi.editor.Editor)168 XmlFile (com.intellij.psi.xml.XmlFile)126 PsiDirectory (com.intellij.psi.PsiDirectory)114 PsiDocumentManager (com.intellij.psi.PsiDocumentManager)109 Module (com.intellij.openapi.module.Module)108 TextRange (com.intellij.openapi.util.TextRange)88 ArrayList (java.util.ArrayList)84 XmlTag (com.intellij.psi.xml.XmlTag)68 File (java.io.File)58 PsiManager (com.intellij.psi.PsiManager)56 PsiClass (com.intellij.psi.PsiClass)51 List (java.util.List)46 Language (com.intellij.lang.Language)45