本文整理汇总了Java中com.intellij.execution.actions.ConfigurationFromContext.getConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationFromContext.getConfiguration方法的具体用法?Java ConfigurationFromContext.getConfiguration怎么用?Java ConfigurationFromContext.getConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.execution.actions.ConfigurationFromContext
的用法示例。
在下文中一共展示了ConfigurationFromContext.getConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testProducedFromFuncallExpression
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Test
public void testProducedFromFuncallExpression() {
PsiFile buildFile =
workspace.createPsiFile(
new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");
FuncallExpression target =
PsiUtils.findFirstChildOfClassRecursive(buildFile, FuncallExpression.class);
assertThat(target).isNotNull();
ConfigurationContext context = createContextFromPsi(target);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazeBuildFileRunConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config =
(BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget())
.isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test:unit_tests"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
示例2: testProducedWhenInsideFuncallExpression
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Test
public void testProducedWhenInsideFuncallExpression() {
PsiFile buildFile =
workspace.createPsiFile(
new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");
StringLiteral nameString =
PsiUtils.findFirstChildOfClassRecursive(buildFile, StringLiteral.class);
assertThat(nameString).isNotNull();
ConfigurationContext context = createContextFromPsi(nameString);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazeBuildFileRunConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config =
(BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget())
.isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test:unit_tests"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
示例3: testProducedFromPsiDirectory
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Test
public void testProducedFromPsiDirectory() {
PsiDirectory directory =
workspace.createPsiDirectory(new WorkspacePath("java/com/google/test"));
workspace.createPsiFile(
new WorkspacePath("java/com/google/test/BUILD"), "java_test(name='unit_tests'");
ConfigurationContext context = createContextFromPsi(directory);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(AllInPackageBlazeConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config =
(BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget())
.isEqualTo(TargetExpression.fromStringSafe("//java/com/google/test/...:all"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
示例4: isPreferredConfiguration
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Override
public boolean isPreferredConfiguration(ConfigurationFromContext self, ConfigurationFromContext other) {
final RunConfiguration configuration = self.getConfiguration();
if (configuration instanceof PythonUnitTestRunConfiguration &&
((PythonUnitTestRunConfiguration)configuration).getTestType() == AbstractPythonTestRunConfiguration.TestType.TEST_FOLDER) {
return true;
}
return other.isProducedBy(PythonTestConfigurationProducer.class) || other.isProducedBy(PythonRunConfigurationProducer.class);
}
示例5: testNoFilterIfDirectoryAtPackageRoot
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Test
public void testNoFilterIfDirectoryAtPackageRoot() {
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(
TargetMapBuilder.builder()
.addTarget(
TargetIdeInfo.builder()
.setKind("java_test")
.setLabel("//java/com/google/test:TestClass")
.addSource(sourceRoot("java/com/google/test/TestClass.java"))
.build())
.build());
registerProjectService(
BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
PsiDirectory directory = workspace.createPsiDirectory(new WorkspacePath("java"));
createAndIndexFile(
new WorkspacePath("java/com/google/test/TestClass.java"),
"package com.google.test;",
"@org.junit.runner.RunWith(org.junit.runners.JUnit4.class)",
"public class TestClass {",
" @org.junit.Test",
" public void testMethod() {}",
"}");
ConfigurationContext context = createContextFromPsi(directory);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(MultipleJavaClassesTestConfigurationProducer.class))
.isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config =
(BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(getTestFilterContents(config)).isNull();
assertThat(config.getName()).isEqualTo("Blaze test test:TestClass");
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
示例6: testProducedFromGoFile
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Test
public void testProducedFromGoFile() {
PsiFile goFile =
createAndIndexFile(
new WorkspacePath("foo/bar/foo_test.go"),
"package foo",
"import \"testing\"",
"func TestFoo(t *testing.T) {}");
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(
TargetMapBuilder.builder()
.addTarget(
TargetIdeInfo.builder()
.setKind("go_test")
.setLabel("//foo/bar:foo_test")
.addSource(sourceRoot("foo/bar/foo_test.go"))
.build())
.build());
registerProjectService(
BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
ConfigurationContext context = createContextFromPsi(goFile);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).isNotNull();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazeGoTestConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config =
(BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//foo/bar:foo_test"));
assertThat(getTestFilterContents(config)).isNull();
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
示例7: testProducedFromGoFile
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Test
public void testProducedFromGoFile() {
PsiFile goFile =
createAndIndexFile(new WorkspacePath("foo/bar/main.go"), "package main", "func main() {}");
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(
TargetMapBuilder.builder()
.addTarget(
TargetIdeInfo.builder()
.setKind("go_binary")
.setLabel("//foo/bar:main")
.addSource(sourceRoot("foo/bar/main.go"))
.build())
.build());
registerProjectService(
BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
ConfigurationContext context = createContextFromPsi(goFile);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).isNotNull();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazeGoBinaryConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config =
(BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//foo/bar:main"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.RUN);
}
示例8: testProducedFromPyClass
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Test
public void testProducedFromPyClass() {
PsiFile pyFile =
createAndIndexFile(
new WorkspacePath("py/test/unittest.py"),
"class UnitTest(googletest.TestCase):",
" def testSomething():",
" return");
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(
TargetMapBuilder.builder()
.addTarget(
TargetIdeInfo.builder()
.setKind("py_test")
.setLabel("//py/test:unittests")
.addSource(sourceRoot("py/test/unittest.py"))
.build())
.build());
registerProjectService(
BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
PyClass pyClass = PsiUtils.findFirstChildOfClassRecursive(pyFile, PyClass.class);
assertThat(pyClass).isNotNull();
ConfigurationContext context = createContextFromPsi(pyClass);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazePyTestConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config =
(BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget())
.isEqualTo(TargetExpression.fromStringSafe("//py/test:unittests"));
assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=UnitTest");
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
示例9: testProducedFromTestCase
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Test
public void testProducedFromTestCase() {
PsiFile pyFile =
createAndIndexFile(
new WorkspacePath("py/test/unittest.py"),
"class UnitTest(googletest.TestCase):",
" def testSomething():",
" return");
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(
TargetMapBuilder.builder()
.addTarget(
TargetIdeInfo.builder()
.setKind("py_test")
.setLabel("//py/test:unittests")
.addSource(sourceRoot("py/test/unittest.py"))
.build())
.build());
registerProjectService(
BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
PyFunction function = PsiUtils.findFirstChildOfClassRecursive(pyFile, PyFunction.class);
assertThat(function).isNotNull();
ConfigurationContext context = createContextFromPsi(function);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazePyTestConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config =
(BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget())
.isEqualTo(TargetExpression.fromStringSafe("//py/test:unittests"));
assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=UnitTest.testSomething");
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
示例10: testProducedFromPyFile
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Test
public void testProducedFromPyFile() {
PsiFile pyFile =
createAndIndexFile(
new WorkspacePath("py/bin/main.py"),
"def main():",
" return",
"if __name__ == '__main__':",
" main()");
workspace.createFile(new WorkspacePath("py/bin/BUILD"), "py_binary(name = 'main')");
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(
TargetMapBuilder.builder()
.addTarget(
TargetIdeInfo.builder()
.setKind("py_binary")
.setLabel("//py/bin:main")
.addSource(sourceRoot("py/bin/main.py"))
.build())
.build());
registerProjectService(
BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
ConfigurationContext context = createContextFromPsi(pyFile);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazePyBinaryConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config =
(BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//py/bin:main"));
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.RUN);
}
示例11: getExternalSystemRunConfiguration
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@NotNull
private ExternalSystemRunConfiguration getExternalSystemRunConfiguration(PsiElement psiElement) {
assertNotNull(psiElement);
ConfigurationContext context = createContext(psiElement, new MapDataContext());
assertNotNull(context);
ConfigurationFromContext myPantsConfigurationFromContext = getPantsJunitConfigurationFromContext(context);
assertNotNull(myPantsConfigurationFromContext);
return (ExternalSystemRunConfiguration) myPantsConfigurationFromContext.getConfiguration();
}
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:10,代码来源:OSSPantsJvmRunConfigurationIntegrationTest.java
示例12: getExternalSystemRunConfiguration
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@NotNull
private ExternalSystemRunConfiguration getExternalSystemRunConfiguration(PsiElement psiElement) {
ConfigurationContext context = createContext(psiElement, new MapDataContext());
ConfigurationFromContext myPantsConfigurationFromContext = getPantsPytestConfigurationFromContext(context);
assertNotNull(myPantsConfigurationFromContext);
return (ExternalSystemRunConfiguration) myPantsConfigurationFromContext.getConfiguration();
}
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:8,代码来源:OSSPantsPythonRunConfigurationIntegrationTest.java
示例13: shouldReplace
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Override
@RequiredReadAction
public boolean shouldReplace(ConfigurationFromContext self, ConfigurationFromContext other)
{
RunConfiguration configuration = other.getConfiguration();
if(configuration instanceof NodeJSConfiguration)
{
PsiFile containingFile = other.getSourceElement().getContainingFile();
if(containingFile instanceof JSFile)
{
return ourFileCondition.value((JSFile) containingFile);
}
}
return false;
}
示例14: testScalaTestProducedFromPsiClass
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Test
public void testScalaTestProducedFromPsiClass() {
PsiFile file =
createAndIndexFile(
WorkspacePath.createIfValid("scala/com/google/test/TestClass.scala"),
"package com.google.test {",
" class TestClass extends org.scalatest.FlatSpec {",
" \"this test\" should \"pass\" in {}",
" }",
"}",
"package org.scalatest {",
" trait FlatSpec extends Suite",
" trait Suite",
"}");
assertThat(file).isInstanceOf(ScalaFile.class);
ScalaFile scalaFile = (ScalaFile) file;
PsiClass[] classes = scalaFile.getClasses();
assertThat(classes).isNotEmpty();
PsiClass testClass = classes[0];
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(
TargetMapBuilder.builder()
.addTarget(
TargetIdeInfo.builder()
.setKind("scala_test")
.setLabel("//scala/com/google/test:TestClass")
.addSource(sourceRoot("scala/com/google/test/TestClass.scala"))
.build())
.build());
registerProjectService(
BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
ConfigurationContext context = createContextFromPsi(testClass);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).isNotNull();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazeScalaTestClassConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config =
(BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget())
.isEqualTo(TargetExpression.fromStringSafe("//scala/com/google/test:TestClass"));
assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=com.google.test.TestClass");
assertThat(config.getName()).isEqualTo("Blaze test TestClass");
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
示例15: testProducedFromTestCase
import com.intellij.execution.actions.ConfigurationFromContext; //导入方法依赖的package包/类
@Test
public void testProducedFromTestCase() {
PsiFile goFile =
createAndIndexFile(
new WorkspacePath("foo/bar/foo_test.go"),
"package foo",
"import \"testing\"",
"func TestFoo(t *testing.T) {}");
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(
TargetMapBuilder.builder()
.addTarget(
TargetIdeInfo.builder()
.setKind("go_test")
.setLabel("//foo/bar:foo_test")
.addSource(sourceRoot("foo/bar/foo_test.go"))
.build())
.build());
registerProjectService(
BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
List<GoFunctionDeclaration> functions =
PsiUtils.findAllChildrenOfClassRecursive(goFile, GoFunctionDeclaration.class);
assertThat(functions).hasSize(1);
GoFunctionDeclaration function = functions.get(0);
ConfigurationContext context = createContextFromPsi(function);
List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext();
assertThat(configurations).isNotNull();
assertThat(configurations).hasSize(1);
ConfigurationFromContext fromContext = configurations.get(0);
assertThat(fromContext.isProducedBy(BlazeGoTestConfigurationProducer.class)).isTrue();
assertThat(fromContext.getConfiguration()).isInstanceOf(BlazeCommandRunConfiguration.class);
BlazeCommandRunConfiguration config =
(BlazeCommandRunConfiguration) fromContext.getConfiguration();
assertThat(config.getTarget()).isEqualTo(TargetExpression.fromStringSafe("//foo/bar:foo_test"));
assertThat(getTestFilterContents(config)).isEqualTo("--test_filter=^TestFoo$");
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}