Skip to content

Commit 08e3f72

Browse files
authored
Add Travis configuration (#1)
* Add travis configuration * Add iml file * Add executable bit to travis script * Move plugin definition * Remove lib folder from classpath to avoid binary incompatibility * Ignore IDEA source * Exclude build folders * Add jar task * Introduce AbstractServiceLocatorTypeProvider * Make lib folder
1 parent 487744c commit 08e3f72

File tree

10 files changed

+441
-32
lines changed

10 files changed

+441
-32
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,7 @@ crashlytics.properties
6565
crashlytics-build.properties
6666
fabric.properties
6767

68+
/idea
69+
/build
70+
/build_test
71+
/plugins/typo3-plugin

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
sudo: false
2+
language: java
3+
jdk:
4+
- oraclejdk8
5+
6+
script: "./travis.sh"
7+
cache:
8+
directories:
9+
- .cache
10+
before_script:
11+
- chmod +x travis.sh
12+
- mkdir lib
13+
14+
env:
15+
- PHPSTORM_ENV=2016.3.1
16+
- PHPSTORM_ENV=2016.3.2
17+
- PHPSTORM_ENV=eap
18+
19+
matrix:
20+
allow_failures:
21+
- env: PHPSTORM_ENV=eap
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@
3737
<!-- Add your actions here -->
3838
</actions>
3939

40-
</idea-plugin>
40+
</idea-plugin>

build-test.xml

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
<project name="TYPO3 Idea Plugin" default="test" basedir=".">
2+
3+
<property file="build.properties" />
4+
5+
<!-- set global properties for this build -->
6+
<property name="build.compiler" value="modern"/>
7+
8+
<property name="src" location="${basedir}/src"/>
9+
<property name="test.src" location="${basedir}/tests"/>
10+
<property name="build" location="build"/>
11+
<property name="test.build" location="build_test"/>
12+
<property name="resources" value="${basedir}/resources"/>
13+
<property name="idea.build" location="${basedir}/idea/" />
14+
<property name="plugins" location="${basedir}/plugins"/>
15+
<property name="deploy" location="${basedir}/deploy"/>
16+
17+
<path id="idea.classpath">
18+
<fileset dir="${idea.build}/lib">
19+
<include name="*.jar"/>
20+
</fileset>
21+
<fileset dir="${basedir}/lib">
22+
<include name="*.jar"/>
23+
</fileset>
24+
<fileset dir="${plugins}">
25+
<include name="*.jar"/>
26+
</fileset>
27+
<fileset dir="${plugins}/php/lib">
28+
<include name="*.jar"/>
29+
</fileset>
30+
<fileset dir="${plugins}/twig/lib">
31+
<include name="*.jar"/>
32+
</fileset>
33+
<fileset dir="${idea.build}/plugins/properties/lib">
34+
<include name="*.jar"/>
35+
</fileset>
36+
<fileset dir="${idea.build}/plugins/java-i18n/lib">
37+
<include name="*.jar"/>
38+
</fileset>
39+
<fileset dir="${idea.build}/plugins/CSS/lib">
40+
<include name="*.jar"/>
41+
</fileset>
42+
<fileset dir="${idea.build}/plugins/yaml/lib">
43+
<include name="*.jar"/>
44+
</fileset>
45+
<fileset dir="${idea.build}/plugins/webDeployment/lib">
46+
<include name="*.jar"/>
47+
</fileset>
48+
</path>
49+
50+
<path id="classpath">
51+
<pathelement location="${build}"/>
52+
<path refid="idea.classpath"/>
53+
</path>
54+
55+
<path id="classpath.test">
56+
<pathelement location="${build}"/>
57+
<pathelement location="${test.build}"/>
58+
<fileset dir="${idea.build}/lib">
59+
<include name="**/*.jar" />
60+
<exclude name="ant/lib/**/*.jar" />
61+
</fileset>
62+
<fileset dir="${plugins}">
63+
<include name="*.jar"/>
64+
</fileset>
65+
<fileset dir="${plugins}/php/lib">
66+
<include name="*.jar"/>
67+
</fileset>
68+
<fileset dir="${plugins}/twig/lib">
69+
<include name="*.jar"/>
70+
</fileset>
71+
<fileset dir="${idea.build}/plugins/properties/lib">
72+
<include name="*.jar"/>
73+
</fileset>
74+
<fileset dir="${idea.build}/plugins/java-i18n/lib">
75+
<include name="*.jar"/>
76+
</fileset>
77+
<fileset dir="${idea.build}/plugins/CSS/lib">
78+
<include name="*.jar"/>
79+
</fileset>
80+
<fileset dir="${idea.build}/plugins/yaml/lib">
81+
<include name="*.jar"/>
82+
</fileset>
83+
<fileset dir="${idea.build}/plugins/webDeployment/lib">
84+
<include name="*.jar"/>
85+
</fileset>
86+
<fileset dir="${java.home}/../lib">
87+
<include name="**/*.jar" />
88+
</fileset>
89+
</path>
90+
91+
<taskdef name="javac2" classname="com.intellij.ant.Javac2">
92+
<classpath>
93+
<pathelement location="${idea.build}/lib/javac2.jar"/>
94+
<path refid="idea.classpath"/>
95+
</classpath>
96+
</taskdef>
97+
98+
<macrodef name="copy_resources">
99+
<attribute name="dest"/>
100+
<attribute name="src"/>
101+
<sequential>
102+
<echo message="Copying resources"/>
103+
<patternset id="resources">
104+
<include name="**/*.php"/>
105+
<include name="**/*.png"/>
106+
<include name="**/*.xml"/>
107+
<include name="**/*.yml"/>
108+
<include name="**/*.xlf"/>
109+
<include name="**/*.twig"/>
110+
<include name="**/*.json"/>
111+
<include name="**/*.xlf"/>
112+
<include name="**/*.xliff"/>
113+
<include name="**/*.html"/>
114+
</patternset>
115+
116+
<copy toDir="@{dest}">
117+
<fileset dir="@{src}">
118+
<patternset refid="resources"/>
119+
</fileset>
120+
</copy>
121+
</sequential>
122+
</macrodef>
123+
124+
<macrodef name="make_plugin">
125+
<attribute name="dest"/>
126+
<sequential>
127+
<copy toDir="@{dest}/classes">
128+
<fileset dir="${src}"/>
129+
</copy>
130+
<copy toDir="@{dest}/lib">
131+
<fileset dir="${basedir}/lib"/>
132+
</copy>
133+
<copy toDir="@{dest}/META-INF">
134+
<fileset dir="${basedir}/META-INF"/>
135+
</copy>
136+
</sequential>
137+
</macrodef>
138+
139+
<target name="init">
140+
<tstamp/>
141+
<mkdir dir="${build}"/>
142+
<mkdir dir="${test.build}"/>
143+
<mkdir dir="${plugins}/typo3-plugin"/>
144+
<echo message="Using IDEA build from: ${idea.build}"/>
145+
<echo message="Using JAVA_HOME: ${java.home}"/>
146+
</target>
147+
148+
<target name="compile" depends="init" description="Compile the source code">
149+
150+
<sequential>
151+
<pathconvert property="classpathProp" refid="classpath"/>
152+
153+
<javac2 destdir="${build}" classpathref="classpath" verbose="false" debug="true" source="1.8" target="1.8" includeantruntime="false">
154+
<src path="${src}"/>
155+
</javac2>
156+
157+
<copy_resources dest="${build}" src="${src}"/>
158+
<make_plugin dest="${plugins}/typo3-plugin"/>
159+
<copy todir="${build}/META-INF">
160+
<fileset dir="META-INF"/>
161+
</copy>
162+
</sequential>
163+
</target>
164+
165+
<target name="compile_test" depends="compile" description="Compile tests">
166+
167+
<sequential>
168+
<pathconvert property="classpathProp" refid="classpath"/>
169+
170+
<javac2 destdir="${test.build}" classpathref="classpath" verbose="false" debug="true" source="1.8" target="1.8" includeantruntime="false">
171+
<src path="${src}"/>
172+
<src path="${test.src}"/>
173+
</javac2>
174+
175+
<copy_resources dest="${test.build}" src="${src}"/>
176+
<copy_resources dest="${test.build}" src="${test.src}"/>
177+
</sequential>
178+
</target>
179+
180+
<target name="test" depends="compile_test" description="Run the tests">
181+
<echo message="Running tests"/>
182+
183+
<property name="suspend" value="n"/>
184+
185+
<junit printsummary="yes"
186+
haltonfailure="false"
187+
failureProperty="failure_found"
188+
fork="yes" forkmode="once" reloading="no" showoutput="yes">
189+
190+
<jvmarg value="-Didea.home.path=${idea.build}"/>
191+
<jvmarg value="-Xbootclasspath/a:${idea.build}/lib/boot.jar"/>
192+
<jvmarg value="-Dfile.encoding=UTF-8"/>
193+
<jvmarg value="-Didea.load.plugins.id=com.jetbrains.php,com.jetbrains.twig,com.intellij.modules.platformorg.jetbrains.plugins.yaml,com.jetbrains.plugins.webDeployment,de.espend.idea.php.annotation,de.espend.idea.php.toolbox,com.cedricziel.idea.typo3"/>
194+
<jvmarg value="-ea"/>
195+
<jvmarg value="-Didea.plugins.path=${plugins}"/>
196+
<jvmarg line="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=${suspend},address=43251"/>
197+
<jvmarg value="-Didea.launcher.bin.path=${idea.build}/bin"/>
198+
199+
<classpath refid="classpath.test"/>
200+
201+
<formatter type="brief" usefile="false"/>
202+
203+
<batchtest>
204+
<fileset dir="${test.src}">
205+
<include name="**/*Test.java"/>
206+
<exclude name="**/*TestCase.java"/>
207+
</fileset>
208+
</batchtest>
209+
</junit>
210+
211+
<antcall target="check_test"/>
212+
</target>
213+
214+
<target name="check_test" if="failure_found">
215+
<fail message="Failures found"/>
216+
</target>
217+
218+
<target name="jar" description="build the plugin jar" depends="compile">
219+
<jar destfile="idea-php-typo3-plugin.jar" >
220+
<fileset dir="${build}"/>
221+
</jar>
222+
</target>
223+
224+
<target name="clean" description="clean up">
225+
<delete dir="${build}" />
226+
<delete dir="${test.build}" />
227+
<delete dir="${plugins}/typo3-plugin" />
228+
</target>
229+
230+
</project>

idea-php-typo3-plugin.iml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="PLUGIN_MODULE" version="4">
3+
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/META-INF/plugin.xml" />
4+
<component name="NewModuleRootManager" inherit-compiler-output="true">
5+
<exclude-output />
6+
<content url="file://$MODULE_DIR$">
7+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
8+
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
9+
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
10+
<excludeFolder url="file://$MODULE_DIR$/.cache" />
11+
<excludeFolder url="file://$MODULE_DIR$/idea" />
12+
<excludeFolder url="file://$MODULE_DIR$/plugins" />
13+
</content>
14+
<orderEntry type="inheritedJdk" />
15+
<orderEntry type="sourceFolder" forTests="false" />
16+
<orderEntry type="library" scope="PROVIDED" name="php-openapi" level="project" />
17+
<orderEntry type="library" scope="PROVIDED" name="php" level="project" />
18+
<orderEntry type="library" scope="TEST" name="junit:junit:4.9" level="project" />
19+
<orderEntry type="library" scope="TEST" name="css-openapi" level="project" />
20+
<orderEntry type="library" scope="TEST" name="css" level="project" />
21+
<orderEntry type="library" scope="TEST" name="java-i18n" level="project" />
22+
<orderEntry type="library" scope="TEST" name="properties" level="project" />
23+
<orderEntry type="library" scope="TEST" name="yaml" level="project" />
24+
</component>
25+
</module>

resources/.gitkeep

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.cedricziel.idea.typo3.provider;
2+
3+
import com.intellij.openapi.project.Project;
4+
import com.jetbrains.php.PhpIndex;
5+
import com.jetbrains.php.lang.psi.elements.PhpNamedElement;
6+
import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider2;
7+
8+
import java.util.Collection;
9+
import java.util.Collections;
10+
11+
abstract public class AbstractServiceLocatorTypeProvider implements PhpTypeProvider2 {
12+
@Override
13+
public Collection<? extends PhpNamedElement> getBySignature(String s, Project project) {
14+
int endIndex = s.lastIndexOf("%");
15+
if (endIndex == -1) {
16+
return Collections.emptySet();
17+
}
18+
19+
// Get FQN from parameter string.
20+
// Example (PhpStorm 8): #K#C\Foo\Bar::get()%#K#C\Bar\Baz. -> \Bar\Baz.
21+
// Example (PhpStorm 9): #K#C\Foo\Bar::get()%#K#C\Bar\Baz.class -> \Bar\Baz.class
22+
String parameter = s.substring(endIndex + 5, s.length());
23+
24+
if (parameter.contains(".class")) { // for PhpStorm 9
25+
parameter = parameter.replace(".class", "");
26+
}
27+
28+
if (parameter.contains(".")) {
29+
parameter = parameter.replace(".", "");
30+
}
31+
32+
return PhpIndex.getInstance(project).getAnyByFQN(parameter);
33+
}
34+
}

src/com/cedricziel/idea/typo3/provider/GeneralUtilityTypeProvider.java

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,15 @@
22

33
import com.cedricziel.idea.typo3.psi.PhpElementsUtil;
44
import com.intellij.openapi.project.DumbService;
5-
import com.intellij.openapi.project.Project;
65
import com.intellij.psi.PsiElement;
7-
import com.jetbrains.php.PhpIndex;
86
import com.jetbrains.php.lang.psi.elements.MethodReference;
9-
import com.jetbrains.php.lang.psi.elements.PhpNamedElement;
107
import com.jetbrains.php.lang.psi.elements.PhpReference;
11-
import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider2;
128
import org.jetbrains.annotations.Nullable;
139

14-
import java.util.Collection;
15-
import java.util.Collections;
16-
1710
/**
1811
* TypeProvider for `GeneralUtility::makeInstance`
1912
*/
20-
public class GeneralUtilityTypeProvider implements PhpTypeProvider2 {
13+
public class GeneralUtilityTypeProvider extends AbstractServiceLocatorTypeProvider {
2114

2215
@Override
2316
public char getKey() {
@@ -51,27 +44,4 @@ public String getType(PsiElement psiElement) {
5144

5245
return null;
5346
}
54-
55-
@Override
56-
public Collection<? extends PhpNamedElement> getBySignature(String s, Project project) {
57-
int endIndex = s.lastIndexOf("%");
58-
if (endIndex == -1) {
59-
return Collections.emptySet();
60-
}
61-
62-
// Get FQN from parameter string.
63-
// Example (PhpStorm 8): #K#C\Foo\Bar::get()%#K#C\Bar\Baz. -> \Bar\Baz.
64-
// Example (PhpStorm 9): #K#C\Foo\Bar::get()%#K#C\Bar\Baz.class -> \Bar\Baz.class
65-
String parameter = s.substring(endIndex + 5, s.length());
66-
67-
if (parameter.contains(".class")) { // for PhpStorm 9
68-
parameter = parameter.replace(".class", "");
69-
}
70-
71-
if (parameter.contains(".")) {
72-
parameter = parameter.replace(".", "");
73-
}
74-
75-
return PhpIndex.getInstance(project).getAnyByFQN(parameter);
76-
}
7747
}

tests/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)