Search in sources :

Example 11 with PsiFile

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

the class GoBuildMatcherTest method testCgoCImport.

public void testCgoCImport() {
    myFixture.configureByText("a.go", "package a; import \"C\"");
    PsiFile file = myFixture.getFile();
    assertTrue(new GoBuildMatcher(new GoTargetSystem("linux", "amd64", "1.4", null, ThreeState.YES)).matchFile(file));
    assertFalse(new GoBuildMatcher(new GoTargetSystem("linux", "amd64", "1.4", null, ThreeState.NO)).matchFile(file));
}
Also used : PsiFile(com.intellij.psi.PsiFile)

Example 12 with PsiFile

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

the class GoTestRunConfigurationProducerTest method testSameConfigurationOnDirectory.

public void testSameConfigurationOnDirectory() {
    PsiFile file = myFixture.configureByText("a.go", "package main");
    PsiDirectory directory = file.getParent();
    assertNotNull(directory);
    ConfigurationContext configurationContext = new ConfigurationContext(directory);
    GotestRunConfigurationProducer producer = new GotestRunConfigurationProducer();
    GoTestRunConfiguration runConfiguration = createDirectoryConfiguration(GotestFramework.INSTANCE, directory.getVirtualFile().getPath(), directory.getVirtualFile().getPath());
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createDirectoryConfiguration(GotestFramework.INSTANCE, directory.getVirtualFile().getPath() + "_vl", directory.getVirtualFile().getPath());
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createDirectoryConfiguration(GobenchFramework.INSTANCE, directory.getVirtualFile().getPath(), directory.getVirtualFile().getPath());
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createDirectoryConfiguration(GotestFramework.INSTANCE, directory.getVirtualFile().getPath(), directory.getVirtualFile().getPath() + "_vl");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) PsiDirectory(com.intellij.psi.PsiDirectory) PsiFile(com.intellij.psi.PsiFile) GotestRunConfigurationProducer(com.goide.runconfig.testing.frameworks.gotest.GotestRunConfigurationProducer)

Example 13 with PsiFile

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

the class GoIntroduceFunctionFixTest method testInOtherPackageWithImportForSideEffects.

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

Example 14 with PsiFile

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

the class GoIntroduceFunctionFixTest method testInOtherPackageWithDotAlias.

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

Example 15 with PsiFile

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

the class GoRunConfigurationProducerTest method testSameRunApplicationConfigurationOnPackage.

public void testSameRunApplicationConfigurationOnPackage() {
    PsiFile file = myFixture.configureByText("a.go", "package main; <caret>\nfunc main() {}");
    PsiElement at = file.findElementAt(myFixture.getCaretOffset());
    assertNotNull(at);
    ConfigurationContext configurationContext = new ConfigurationContext(at);
    GoApplicationRunConfigurationProducer producer = new GoApplicationRunConfigurationProducer();
    GoApplicationConfiguration runConfiguration = createRunAppFileConfiguration(file.getVirtualFile().getPath());
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createRunAppFileConfiguration(file.getVirtualFile().getPath() + "_vl");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) GoApplicationRunConfigurationProducer(com.goide.runconfig.application.GoApplicationRunConfigurationProducer) PsiFile(com.intellij.psi.PsiFile) GoApplicationConfiguration(com.goide.runconfig.application.GoApplicationConfiguration) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiFile (com.intellij.psi.PsiFile)1776 VirtualFile (com.intellij.openapi.vfs.VirtualFile)490 PsiElement (com.intellij.psi.PsiElement)466 Nullable (org.jetbrains.annotations.Nullable)267 Project (com.intellij.openapi.project.Project)266 NotNull (org.jetbrains.annotations.NotNull)248 Document (com.intellij.openapi.editor.Document)181 Editor (com.intellij.openapi.editor.Editor)166 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)106 TextRange (com.intellij.openapi.util.TextRange)88 ArrayList (java.util.ArrayList)81 XmlTag (com.intellij.psi.xml.XmlTag)68 File (java.io.File)58 PsiManager (com.intellij.psi.PsiManager)56 PsiClass (com.intellij.psi.PsiClass)50 List (java.util.List)46 Language (com.intellij.lang.Language)45