Skip to content

Commit 854dd80

Browse files
committed
Convert to multi-module build
1 parent 36ff48c commit 854dd80

28 files changed

+813
-17
lines changed

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
indent_style = space
9+
indent_size = 4
10+
end_of_line = lf
11+
charset = utf-8
12+
trim_trailing_whitespace = true
13+
insert_final_newline = true
14+
15+
[*.md]
16+
trim_trailing_whitespace = false
17+
18+
[*.bnf]
19+
indent_size = 2

build.gradle

Lines changed: 142 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,173 @@
11
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
2+
import org.jetbrains.grammarkit.tasks.*
23

34
buildscript {
45
repositories {
56
mavenCentral()
67

8+
maven { url "https://jetbrains.bintray.com/intellij-third-party-dependencies" }
9+
10+
maven { url 'https://jitpack.io' }
711
maven { url 'http://dl.bintray.com/jetbrains/intellij-plugin-service' }
812
}
13+
14+
dependencies {
15+
classpath "com.github.JetBrains:gradle-grammar-kit-plugin:2018.1.2"
16+
}
917
}
1018

1119
plugins {
1220
id "org.jetbrains.intellij" version "0.3.4"
1321
id 'com.palantir.git-version' version "0.9.1"
1422
}
1523

16-
apply plugin: 'idea'
17-
apply plugin: 'org.jetbrains.intellij'
18-
apply plugin: 'java'
24+
group 'com.cedricziel.idea'
25+
version gitVersion()
26+
27+
allprojects {
28+
apply plugin: 'idea'
29+
apply plugin: 'org.jetbrains.grammarkit'
30+
apply plugin: 'org.jetbrains.intellij'
31+
apply plugin: 'java'
32+
33+
repositories {
34+
mavenCentral()
35+
}
36+
37+
intellij {
38+
version ideaVersion
39+
downloadSources !Boolean.valueOf(System.getenv('CI'))
40+
41+
publishPlugin {
42+
username System.getenv('IJ_REPO_USERNAME')
43+
password System.getenv('IJ_REPO_PASSWORD')
44+
}
45+
46+
patchPluginXml {
47+
sinceBuild '173'
48+
untilBuild '182.*'
49+
}
50+
}
51+
52+
grammarKit {
53+
grammarKitRelease = "2017.1.4"
54+
jflexRelease = '1.7.0-1'
55+
}
56+
}
57+
58+
project(":") {
59+
intellij {
60+
pluginName 'TYPO3 CMS Plugin'
61+
plugins = [
62+
"com.jetbrains.php:${phpPluginVersion}",
63+
'CSS',
64+
'java-i18n',
65+
'properties',
66+
'yaml',
67+
"PsiViewer:${psiViewerPluginVersion}",
68+
project(':lang-fluid'),
69+
project(':lang-typoscript'),
70+
]
71+
}
72+
}
73+
74+
project(":lang-fluid") {
75+
def genRoot = file('gen')
76+
sourceSets {
77+
main {
78+
java.srcDirs 'src', genRoot
79+
resources.srcDir 'resources'
80+
}
81+
test {
82+
java.srcDir 'test'
83+
resources.srcDirs 'testData'
84+
}
85+
}
86+
87+
idea {
88+
module {
89+
generatedSourceDirs += genRoot
90+
}
91+
}
1992

20-
intellij {
21-
version ideaVersion
22-
pluginName 'TYPO3 CMS Plugin'
23-
plugins = [
93+
intellij {
94+
pluginName 'TYPO3 Fluid Plugin'
95+
plugins = [
2496
"com.jetbrains.php:${phpPluginVersion}",
2597
'CSS',
2698
'java-i18n',
2799
'properties',
28100
'yaml',
29101
"PsiViewer:${psiViewerPluginVersion}"
30-
]
31-
downloadSources !Boolean.valueOf(System.getenv('CI'))
102+
]
103+
}
32104

33-
publishPlugin {
34-
username System.getenv('IJ_REPO_USERNAME')
35-
password System.getenv('IJ_REPO_PASSWORD')
105+
task generateFluidLexer(type: GenerateLexer) {
106+
source = "src/main/grammars/FluidLexer.flex"
107+
targetDir = "gen/com/cedricziel/idea/fluid/lang/lexer"
108+
targetClass = "FluidLexer"
36109
}
37110

38-
patchPluginXml {
39-
sinceBuild '173'
40-
untilBuild '182.*'
111+
task generateFluidParser(type: GenerateParser) {
112+
source = "src/main/grammars/FluidParser.bnf"
113+
targetRoot = 'gen'
114+
pathToParser = '/com/cedricziel/idea/fluid/lang/parser/FluidParserGenerated.java'
115+
pathToPsiRoot = '/com/cedricziel/idea/fluid/lang/psi'
116+
}
117+
118+
compileJava {
119+
dependsOn generateFluidParser, generateFluidLexer
41120
}
42121
}
43122

44-
group 'com.cedricziel'
45-
version gitVersion()
123+
project(":lang-typoscript") {
124+
def genRoot = file('gen')
125+
sourceSets {
126+
main {
127+
java.srcDirs 'src', genRoot
128+
resources.srcDir 'resources'
129+
}
130+
test {
131+
java.srcDir 'test'
132+
resources.srcDirs 'testData'
133+
}
134+
}
135+
136+
idea {
137+
module {
138+
generatedSourceDirs += genRoot
139+
}
140+
}
141+
142+
intellij {
143+
pluginName 'TypoScript Plugin'
144+
plugins = [
145+
"com.jetbrains.php:${phpPluginVersion}",
146+
'CSS',
147+
'java-i18n',
148+
'properties',
149+
'yaml',
150+
"PsiViewer:${psiViewerPluginVersion}"
151+
]
152+
}
153+
154+
task generateTypoScriptLexer(type: GenerateLexer) {
155+
source = "src/main/grammars/TypoScriptLexer.flex"
156+
targetDir = "gen/com/cedricziel/idea/typoscript/lang/lexer"
157+
targetClass = "TypoScriptLexer"
158+
}
159+
160+
task generateTypoScriptParser(type: GenerateParser) {
161+
source = "src/main/grammars/TypoScriptParser.bnf"
162+
targetRoot = 'gen'
163+
pathToParser = '/com/cedricziel/idea/typoscript/lang/parser/TypoScriptParserGenerated.java'
164+
pathToPsiRoot = '/com/cedricziel/idea/typoscript/lang/psi'
165+
}
166+
167+
compileJava {
168+
dependsOn generateTypoScriptParser, generateTypoScriptLexer
169+
}
170+
}
46171

47172
wrapper {
48173
gradleVersion '4.8'

lang-fluid/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
gen
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package com.cedricziel.idea.fluid.lang.lexer;
2+
3+
import com.intellij.lexer.FlexLexer;
4+
5+
import com.intellij.psi.TokenType;
6+
import com.intellij.psi.tree.IElementType;
7+
8+
import com.cedricziel.idea.fluid.lang.psi.FluidTypes;
9+
10+
%%
11+
12+
%{
13+
private boolean ternaryBranchesOparatorMatched = false;
14+
private boolean wsAfterTernaryBranchesOparatorMatched = false;
15+
16+
public _FluidLexer() {
17+
this((java.io.Reader) null);
18+
}
19+
%}
20+
21+
%class _FluidLexer
22+
%implements FlexLexer
23+
%function advance
24+
%type IElementType
25+
%unicode
26+
27+
WS = \s
28+
29+
SINGLE_QUOTED_STR_CONTENT = ([^\\']|\\([\\'\"/bfnrt]|u[a-fA-F0-9]{4}))+
30+
DOUBLE_QUOTED_STR_CONTENT = ([^\\\"]|\\([\\'\"/bfnrt]|u[a-fA-F0-9]{4}))+
31+
32+
INTEGER_NUMBER = 0|[1-9]\d*
33+
FLOAT_NUMBER = [0-9]*\.[0-9]+([eE][-+]?[0-9]+)?|[0-9]+[eE][-+]?[0-9]+
34+
IDENTIFIER = [\p{Alpha}_][\p{Alnum}_:]*
35+
36+
%state EXPRESSION
37+
%state SINGLE_QUOTED_STRING
38+
%state DOUBLE_QUOTED_STRING
39+
%state TERNARY_BRANCHES_OP
40+
%state COMMENT
41+
42+
%%
43+
44+
<YYINITIAL> {
45+
"{" { yybegin(EXPRESSION); return FluidTypes.EXPR_START; }
46+
"\\{" { return FluidTypes.OUTER_TEXT; }
47+
"<!--/*" { yybegin(COMMENT); return FluidTypes.COMMENT_START; }
48+
[^] { return FluidTypes.OUTER_TEXT; }
49+
}
50+
51+
<EXPRESSION> {
52+
"}" { yybegin(YYINITIAL); return FluidTypes.EXPR_END; }
53+
54+
"true" { return FluidTypes.BOOLEAN_LITERAL; }
55+
"false" { return FluidTypes.BOOLEAN_LITERAL; }
56+
"TRUE" { return FluidTypes.BOOLEAN_LITERAL; }
57+
"FALSE" { return FluidTypes.BOOLEAN_LITERAL; }
58+
59+
"'" { yybegin(SINGLE_QUOTED_STRING); return FluidTypes.SINGLE_QUOTE; }
60+
\" { yybegin(DOUBLE_QUOTED_STRING); return FluidTypes.DOUBLE_QUOTE; }
61+
{INTEGER_NUMBER} { return FluidTypes.INTEGER_NUMBER; }
62+
{FLOAT_NUMBER} { return FluidTypes.FLOAT_NUMBER; }
63+
{IDENTIFIER} { return FluidTypes.IDENTIFIER; }
64+
65+
"(" { return FluidTypes.LEFT_PARENTH; }
66+
")" { return FluidTypes.RIGHT_PARENTH; }
67+
"." { return FluidTypes.DOT; }
68+
"," { return FluidTypes.COMMA; }
69+
"!" { return FluidTypes.NOT; }
70+
"&&" { return FluidTypes.AND; }
71+
"||" { return FluidTypes.OR; }
72+
73+
"=" { return FluidTypes.ASSIGN; }
74+
"==" { return FluidTypes.EQ; }
75+
"!=" { return FluidTypes.NEQ; }
76+
"<" { return FluidTypes.LT; }
77+
">" { return FluidTypes.GT; }
78+
"<=" { return FluidTypes.LEQ; }
79+
">=" { return FluidTypes.GEQ; }
80+
"?" { return FluidTypes.TERNARY_QUESTION_OP; }
81+
82+
{WS}+ { return TokenType.WHITE_SPACE; }
83+
84+
[^] { yybegin(YYINITIAL); return FluidTypes.OUTER_TEXT; }
85+
}
86+
87+
<SINGLE_QUOTED_STRING> {
88+
"'" { yybegin(EXPRESSION); return FluidTypes.SINGLE_QUOTE; }
89+
{SINGLE_QUOTED_STR_CONTENT} { return FluidTypes.STRING_CONTENT; }
90+
91+
[^] {
92+
yypushback(1); // cancel unexpected char
93+
yybegin(EXPRESSION); // and try to parse it again in <EXPRESSION>
94+
}
95+
}
96+
97+
<DOUBLE_QUOTED_STRING> {
98+
\" { yybegin(EXPRESSION); return FluidTypes.DOUBLE_QUOTE; }
99+
{DOUBLE_QUOTED_STR_CONTENT} { return FluidTypes.STRING_CONTENT; }
100+
101+
[^] {
102+
yypushback(1); // cancel unexpected char
103+
yybegin(EXPRESSION); // and try to parse it again in <EXPRESSION>
104+
}
105+
}
106+
107+
<COMMENT> {
108+
"*/-->" { yybegin(YYINITIAL); return FluidTypes.COMMENT_END; }
109+
[^] { return FluidTypes.COMMENT_CONTENT; }
110+
}

0 commit comments

Comments
 (0)