Search in sources :

Example 36 with PsiFile

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

the class GoSelfImportInspectionTest method testRemoveSelfImport.

public void testRemoveSelfImport() {
    PsiFile file = myFixture.addFileToProject("path/a.go", "package pack;" + "import <error descr=\"Self import is not allowed\"><caret>\"path\"</error>");
    myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    myFixture.checkHighlighting();
    applySingleQuickFix(GoDeleteImportQuickFix.QUICK_FIX_NAME);
    myFixture.checkResult("package pack;");
}
Also used : PsiFile(com.intellij.psi.PsiFile)

Example 37 with PsiFile

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

the class GoSelfImportInspectionTest method testDoNotConsiderImportFromTestPackageAsSelfImport.

public void testDoNotConsiderImportFromTestPackageAsSelfImport() {
    PsiFile file = myFixture.addFileToProject("path/a_test.go", "package pack_test; import <caret>\"path\"");
    myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    myFixture.checkHighlighting();
}
Also used : PsiFile(com.intellij.psi.PsiFile)

Example 38 with PsiFile

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

the class GoNamedElementTest method doTestGetUseScope.

private <T> void doTestGetUseScope(@NotNull String text, @NotNull Class<T> scope) {
    myFixture.configureByText("a.go", text);
    PsiFile file = myFixture.getFile();
    GoVarDefinition var = PsiTreeUtil.findChildOfType(file, GoVarDefinition.class);
    assertNotNull(var);
    assertTrue(scope.isInstance(var.getUseScope()));
}
Also used : GoVarDefinition(com.goide.psi.GoVarDefinition) PsiFile(com.intellij.psi.PsiFile)

Example 39 with PsiFile

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

the class GoIntroduceFunctionFixTest method testInOtherPackageWithChanOfImportedTypes.

public void testInOtherPackageWithChanOfImportedTypes() {
    myFixture.addFileToProject("a/a.go", "package a; type MyType int; func CreateChanOfMyType() chan MyType { return nil};");
    PsiFile file = myFixture.addFileToProject("b/b.go", "package b; import alias \"a\"; func _() { asd<caret>(alias.CreateChanOfMyType());};");
    myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    applySingleQuickFix(QUICK_FIX_NAME);
    myFixture.checkResult("package b; import alias \"a\"; " + "func _() { asd(alias.CreateChanOfMyType());}\nfunc asd(myType chan alias.MyType) {\n\t<caret>\n};");
}
Also used : PsiFile(com.intellij.psi.PsiFile)

Example 40 with PsiFile

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

the class GoIntroduceFunctionFixTest method testInOtherPackageWithTwoAlias.

public void testInOtherPackageWithTwoAlias() {
    myFixture.addFileToProject("c/c.go", "package c; type MyType int;");
    myFixture.addFileToProject("a/a.go", "package a; import myC \"c\" func CreateMyType() myC.MyType { return myC.MyType{}};");
    PsiFile file = myFixture.addFileToProject("b/b.go", "package b; import (. \"a\"; importC \"c\"); func _() { asd<caret>(CreateMyType());};");
    myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    applySingleQuickFix(QUICK_FIX_NAME);
    myFixture.checkResult("package b; import (. \"a\"; importC \"c\"); func _() { asd(CreateMyType());}\nfunc asd(myType importC.MyType) {\n\t<caret>\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