Skip to content

Commit

Permalink
spec can be started from html file
Browse files Browse the repository at this point in the history
  • Loading branch information
idegtiarenko committed Oct 31, 2015
1 parent d906251 commit 8e3b7dd
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 6 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

[![Build Status](https://travis-ci.org/concordion/idea-concordion-support.svg)](https://travis-ci.org/concordion/idea-concordion-support)

This plugin provides support for [concordion](http://concordion.org/) framework.
This plugin provides support for [concordion 2.0](http://concordion.org/) framework.

It can be installed from Intellij IDEA plugins (search for *Concordion support*) or downloaded [here](https://plugins.jetbrains.com/plugin/7978)

It is built by gradle so it does not require to have intellij idea plugin sdk set up to start development.

# Required versions:
# Requirements

- idea 14.1+ running on jdk 8
- concordion 2.0-SNAPSHOT
- idea 14.1+ with JUnit plugin running on jdk 8

# Supported features

Expand All @@ -20,4 +21,5 @@ It is built by gradle so it does not require to have intellij idea plugin sdk se
- Navigation between concordion html spec and test fixture using concordion icon and navigation action (ctrl + shift + s)
- Ctrl+click navigation and usages search for concordion expressions
- Quick fields and methods creation from usages
- Renaming support
- Renaming support
- Run concordion spec from HTML file
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ repositories {

intellij {
version '14.1.4'
plugins 'junit'
pluginName 'IdeaConcordionSupport'
sandboxDirectory 'idea-sandbox'
}
Expand Down
9 changes: 8 additions & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
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);
}
}

0 comments on commit 8e3b7dd

Please sign in to comment.