本文整理汇总了Java中com.intellij.execution.actions.ConfigurationFromContext类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationFromContext类的具体用法?Java ConfigurationFromContext怎么用?Java ConfigurationFromContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationFromContext类属于com.intellij.execution.actions包,在下文中一共展示了ConfigurationFromContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRunConfigurationFromContext
import com.intellij.execution.actions.ConfigurationFromContext; //导入依赖的package包/类
/**
* Creates run configuration from right click menu
*
* @param fixture test fixture
* @param expectedClass expected class of run configuration
* @param <C> expected class of run configuration
* @return configuration (if created) or null (otherwise)
*/
@Nullable
public static <C extends RunConfiguration> C createRunConfigurationFromContext(
@NotNull final CodeInsightTestFixture fixture,
@NotNull final Class<C> expectedClass) {
final DataContext context = DataManager.getInstance().getDataContext(fixture.getEditor().getComponent());
for (final RunConfigurationProducer<?> producer : RunConfigurationProducer.EP_NAME.getExtensions()) {
final ConfigurationFromContext fromContext = producer.createConfigurationFromContext(ConfigurationContext.getFromContext(context));
if (fromContext == null) {
continue;
}
final C result = PyUtil.as(fromContext.getConfiguration(), expectedClass);
if (result != null) {
return result;
}
}
return null;
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: chooseSubclass
import com.intellij.execution.actions.ConfigurationFromContext; //导入依赖的package包/类
@VisibleForTesting
static void chooseSubclass(
ConfigurationFromContext configuration,
ConfigurationContext context,
Runnable startRunnable) {
RunConfiguration config = configuration.getConfiguration();
if (!(config instanceof BlazeCommandRunConfiguration)) {
return;
}
AbstractTestLocation location = locationFromConfiguration(configuration);
if (location == null) {
return;
}
SubclassTestChooser.chooseSubclass(
context,
location.abstractClass,
(psiClass) -> {
if (psiClass != null) {
setupContext((BlazeCommandRunConfiguration) config, psiClass, location.method);
}
startRunnable.run();
});
}
示例6: testIgnoreTestClassWitNoTestSubclasses
import com.intellij.execution.actions.ConfigurationFromContext; //导入依赖的package包/类
@Test
public void testIgnoreTestClassWitNoTestSubclasses() {
PsiFile javaFile =
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 testMethod1() {}",
" @org.junit.Test",
" public void testMethod2() {}",
"}");
PsiClass javaClass = ((PsiClassOwner) javaFile).getClasses()[0];
assertThat(javaClass).isNotNull();
ConfigurationContext context = createContextFromPsi(javaClass);
ConfigurationFromContext fromContext =
new BlazeJavaAbstractTestCaseConfigurationProducer()
.createConfigurationFromContext(context);
assertThat(fromContext).isNull();
}
示例7: executeDebugRunner
import com.intellij.execution.actions.ConfigurationFromContext; //导入依赖的package包/类
/**
* Run tests for given element
*
* @param psiElement Elements are PhpClass or Method possible context
*/
public static void executeDebugRunner(@NotNull PsiElement psiElement) {
ConfigurationFromContext context = RunConfigurationProducer.getInstance(BehatRuntimeConfigurationProducer.class)
.createConfigurationFromContext(new ConfigurationContext(psiElement));
if(context != null) {
ProgramRunnerUtil.executeConfiguration(
psiElement.getProject(),
context.getConfigurationSettings(),
DefaultDebugExecutor.getDebugExecutorInstance()
);
}
}
示例8: createConfigurationFromContext
import com.intellij.execution.actions.ConfigurationFromContext; //导入依赖的package包/类
@Nullable
@Override
public ConfigurationFromContext createConfigurationFromContext(ConfigurationContext context) {
ConfigurationFromContext fromContext = super.createConfigurationFromContext(context);
if (fromContext != null) {
JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration((RunConfigurationBase)fromContext.getConfiguration(),
context.getLocation());
}
return fromContext;
}
示例9: 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);
}
示例10: onFirstRun
import com.intellij.execution.actions.ConfigurationFromContext; //导入依赖的package包/类
@Override
public void onFirstRun(
ConfigurationFromContext configuration,
ConfigurationContext context,
Runnable startRunnable) {
chooseSubclass(configuration, context, startRunnable);
}
示例11: 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);
}
示例12: testNotProducedFromNonTestFiles
import com.intellij.execution.actions.ConfigurationFromContext; //导入依赖的package包/类
@Test
public void testNotProducedFromNonTestFiles() {
MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
builder.setTargetMap(
TargetMapBuilder.builder()
.addTarget(
TargetIdeInfo.builder()
.setKind("java_test")
.setLabel("//java/com/google/test:allTests")
.addSource(sourceRoot("java/com/google/test/NonTestClass1.java"))
.addSource(sourceRoot("java/com/google/test/NonTestClass2.java"))
.build())
.build());
registerProjectService(
BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
workspace.createPsiDirectory(new WorkspacePath("java/com/google/test"));
PsiFile testClass1 =
createAndIndexFile(
new WorkspacePath("java/com/google/test/NonTestClass1.java"),
"package com.google.test;",
"public class NonTestClass1 {");
PsiFile testClass2 =
createAndIndexFile(
new WorkspacePath("java/com/google/test/NonTestClass2.java"),
"package com.google.test;",
"public class NonTestClass2 {}");
ConfigurationContext context =
createContextFromMultipleElements(new PsiElement[] {testClass1, testClass2});
ConfigurationFromContext fromContext =
new MultipleJavaClassesTestConfigurationProducer().createConfigurationFromContext(context);
assertThat(fromContext).isNull();
}
示例13: testProducedFromPyFile
import com.intellij.execution.actions.ConfigurationFromContext; //导入依赖的package包/类
@Test
public void testProducedFromPyFile() {
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()));
ConfigurationContext context = createContextFromPsi(pyFile);
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)).isNull();
assertThat(getCommandType(config)).isEqualTo(BlazeCommandName.TEST);
}
示例14: 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);
}
示例15: 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);
}