-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d906251
commit 8e3b7dd
Showing
4 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,14 @@ | |
<version>0.2</version> | ||
<vendor email="[email protected]" url="https://github.com/concordion/idea-concordion-support">Ievgen Degtiarenko</vendor> | ||
|
||
<depends>com.intellij.modules.java</depends> | ||
<depends>JUnit</depends> | ||
|
||
<description><![CDATA[ | ||
<p> | ||
<br/>This plugin provides support such as autocompletion, navigation between spec files, go to declaration and renaming for <a href="http://concordion.org/">http://concordion.org/</a> (2.0) testing framework. | ||
<br/>Plugin homepage: <a href="https://github.com/concordion/idea-concordion-support">https://github.com/concordion/idea-concordion-support</a> | ||
<br/>Require idea 14.1+ running on jdk 8 | ||
<br/>Require idea 14.1+ with JUnit plugin running on jdk 8 | ||
</p> | ||
]]></description> | ||
|
||
|
@@ -17,6 +20,8 @@ | |
Version 0.2<br/> | ||
<ul> | ||
<li>Autocomplete with spec variables</li> | ||
<li>Better ognl expression type derivation</li> | ||
<li>Run concordion spec from HTML file</li> | ||
</ul> | ||
Version 0.1<br/> | ||
<ul> | ||
|
@@ -81,6 +86,8 @@ | |
|
||
<projectService serviceInterface="org.concordion.plugin.idea.ConcordionNavigationService" | ||
serviceImplementation="org.concordion.plugin.idea.ConcordionNavigationService"/> | ||
|
||
<runConfigurationProducer implementation="org.concordion.plugin.idea.configuration.ConcordionConfigurationProducer"/> | ||
</extensions> | ||
|
||
<application-components> | ||
|
54 changes: 54 additions & 0 deletions
54
src/org/concordion/plugin/idea/configuration/ConcordionConfigurationProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.concordion.plugin.idea.configuration; | ||
|
||
import com.intellij.execution.actions.ConfigurationContext; | ||
import com.intellij.execution.junit.JUnitConfiguration; | ||
import com.intellij.execution.junit.TestClassConfigurationProducer; | ||
import com.intellij.execution.junit.TestObject; | ||
import com.intellij.openapi.module.Module; | ||
import com.intellij.openapi.util.Ref; | ||
import com.intellij.psi.PsiClass; | ||
import com.intellij.psi.PsiElement; | ||
import com.intellij.psi.PsiFile; | ||
import org.concordion.plugin.idea.ConcordionNavigationService; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import static org.concordion.plugin.idea.ConcordionPsiUtils.*; | ||
|
||
public class ConcordionConfigurationProducer extends TestClassConfigurationProducer { | ||
|
||
@Override | ||
protected boolean setupConfigurationFromContext(JUnitConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) { | ||
PsiClass testFixture = testFixtureFrom(context); | ||
if (testFixture == null) { | ||
return false; | ||
} | ||
sourceElement.set(testFixture); | ||
setupConfigurationModule(context, configuration); | ||
final Module originalModule = configuration.getConfigurationModule().getModule(); | ||
configuration.beClassConfiguration(testFixture); | ||
configuration.restoreOriginalModule(originalModule); | ||
configuration.setForkMode(JUnitConfiguration.FORK_NONE); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isConfigurationFromContext(JUnitConfiguration unitConfiguration, ConfigurationContext context) { | ||
PsiClass testFixture = testFixtureFrom(context); | ||
TestObject testObject = unitConfiguration.getTestObject(); | ||
|
||
return testObject != null && testObject.isConfiguredByElement(unitConfiguration, testFixture, null, null, null); | ||
} | ||
|
||
@Nullable | ||
private PsiClass testFixtureFrom(ConfigurationContext context) { | ||
PsiElement location = context.getPsiLocation(); | ||
if (location == null) { | ||
return null; | ||
} | ||
PsiFile file = location.getContainingFile(); | ||
if (file == null || !isConcordionHtmlSpec(file)) { | ||
return null; | ||
} | ||
return ConcordionNavigationService.getInstance(context.getProject()).correspondingJavaRunner(file); | ||
} | ||
} |