Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{gradle,yml}]
indent_size = 2
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ bin/
build/
generated/
xtext-gen/
.project
.classpath
11 changes: 0 additions & 11 deletions .project

This file was deleted.

1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
language: java
before_install: cd org.metafacture.fix.parent
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ This repo contains an Xtext web project with a basic Fix grammar, which generate
Setup
-----

Go to the Xtext parent project:
Go to the Git repository root:

`cd metafacture-fix/org.metafacture.fix.parent`
`cd metafacture-fix/`

Run the tests (in `org.metafacture.fix/src/test/java`):
Run the tests (in `org.metafacture.fix/src/test/java`) and checks (`.editorconfig`, `config/checkstyle/checkstyle.xml`):

`./gradlew clean test`
`./gradlew clean check`

Editor
------
Expand All @@ -44,7 +44,7 @@ Visit [http://localhost:8080/](http://localhost:8080/), and paste this into the

```
# Fix is a macro-language for data transformations

# Simple fixes

add_field(hello,world)
Expand All @@ -54,27 +54,27 @@ copy_field(stats,output.$append)
# Conditionals

if exists(error)
set_field(is_valid, no)
log(error)
set_field(is_valid, no)
log(error)
elsif exists(warning)
set_field(is_valid, yes)
log(warning)
set_field(is_valid, yes)
log(warning)
else
set_field(is_valid, yes)
set_field(is_valid, yes)
end

# Loops

do list(path)
add_field(foo,bar)
add_field(foo,bar)
end

# Nested expressions

do marc_each()
if marc_has(f700)
marc_map(f700a,authors.$append)
end
if marc_has(f700)
marc_map(f700a,authors.$append)
end
end
```

Expand Down Expand Up @@ -110,12 +110,13 @@ Run workflows, passing `data`, `flux`, and `fix`:

[http://localhost:8080/xtext-service/run?data='1'{'a': '5', 'z': 10}&flux=as-lines|decode-formeta|fix|encode-formeta(style="multiline")&fix=map(a,b) map(_else)](http://localhost:8080/xtext-service/run?data=%271%27{%27a%27:%20%275%27,%20%27z%27:%2010}&flux=as-lines|decode-formeta|fix|encode-formeta(style=%22multiline%22)&fix=map(a,c)%20map(_else))

Xtext
-----
Eclipse IDE
-----------

To import the projects in Eclipse, choose File > Import > Existing Gradle Project:
To import the projects in Eclipse, choose File > Import > Existing Gradle Project and select the `metafacture-fix` directory.

![Import projects](docs/xtext-import.png)
Xtext
-----

This repo has been originally set up with Xtext 2.17.0 and Eclipse for Java 2019-03, following [https://www.eclipse.org/Xtext/documentation/104_jvmdomainmodel.html](https://www.eclipse.org/Xtext/documentation/104_jvmdomainmodel.html). Below are some details to reproduce the original setup:

Expand All @@ -126,4 +127,3 @@ In the New > Xtext Project wizard, the language details are specified:
As well as the project and build customization:

![Build details](docs/xtext-setup-2.png)

69 changes: 69 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
plugins {
id 'org.ec4j.editorconfig' version '0.0.3'
id 'org.xtext.builder' version '2.0.8'
}

editorconfig {
excludes = [
'**/generated',
'**/xtext-gen',
'**/bin',
'**/.*',
'gradlew*'
]
}

check.dependsOn(editorconfigCheck)

subprojects {
group = 'org.metafacture.fix'
version = '1.0.0-SNAPSHOT'

ext {
versions = [
'ace': '1.3.3',
'jetty': '9.4.14.v20181114',
'jquery': '3.3.1-1',
'jupiter': '5.1.1',
'metafacture': '5.0.1',
'mockito': '2.27.0',
'requirejs': '2.3.6',
'slf4j': '1.7.21',
'xtext': '2.17.0'
]
}

apply plugin: 'checkstyle'
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'org.xtext.builder'

apply from: "${rootDir}/gradle/source-layout.gradle"

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

repositories {
jcenter()
}

dependencies {
compile platform("org.eclipse.xtext:xtext-dev-bom:${versions.xtext}")
}

configurations.all {
exclude group: 'asm'
}

checkstyle {
toolVersion '8.30'
}

tasks.withType(JavaCompile) {
'all -processing -rawtypes -serial'.split().each {
options.compilerArgs << "-Xlint:${it}"
}

options.compilerArgs << '-Werror'
}
}
165 changes: 165 additions & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="SuppressionSingleFilter">
<property name="checks" value=".*"/>
<property name="files" value="/xtext-gen/"/>
</module>
<module name="TreeWalker">
<module name="AbstractClassName"/>
<module name="AnnotationUseStyle"/>
<module name="AnonInnerLength"/>
<module name="ArrayTypeStyle"/>
<module name="AvoidNestedBlocks"/>
<module name="AvoidNoArgumentSuperConstructorCall"/>
<module name="AvoidStarImport"/>
<module name="AvoidStaticImport"/>
<module name="BooleanExpressionComplexity"/>
<module name="CatchParameterName">
<property name="format" value="^e$"/>
</module>
<module name="ClassDataAbstractionCoupling"/>
<module name="ClassFanOutComplexity"/>
<module name="ClassTypeParameterName"/>
<module name="ConstantName"/>
<module name="CovariantEquals"/>
<module name="CustomImportOrder">
<property name="customImportOrderRules" value="SAME_PACKAGE(2)###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE###SPECIAL_IMPORTS###STATIC"/>
<property name="separateLineBetweenGroups" value="true"/>
</module>
<module name="CyclomaticComplexity"/>
<module name="DeclarationOrder"/>
<module name="DefaultComesLast"/>
<module name="EmptyLineSeparator">
<property name="allowMultipleEmptyLines" value="false"/>
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
<property name="allowNoEmptyLineBetweenFields" value="true"/>
</module>
<module name="EmptyStatement"/>
<module name="EqualsAvoidNull"/>
<module name="EqualsHashCode"/>
<module name="ExecutableStatementCount"/>
<module name="ExplicitInitialization"/>
<module name="FallThrough"/>
<module name="FinalLocalVariable">
<property name="validateEnhancedForLoopVariable" value="true"/>
</module>
<module name="FinalParameters">
<property name="tokens" value="CTOR_DEF,LITERAL_CATCH,METHOD_DEF"/>
</module>
<module name="GenericWhitespace"/>
<module name="HiddenField">
<property name="ignoreConstructorParameter" value="true"/>
<property name="ignoreSetter" value="true"/>
</module>
<module name="HideUtilityClassConstructor"/>
<module name="IllegalCatch"/>
<module name="IllegalThrows"/>
<module name="IllegalToken">
<property name="tokens" value="POST_INC,POST_DEC"/>
</module>
<module name="IllegalType"/>
<module name="Indentation"/>
<module name="InnerAssignment"/>
<module name="InnerTypeLast"/>
<module name="InterfaceIsType"/>
<module name="InterfaceTypeParameterName"/>
<module name="JavaNCSS"/>
<module name="JavadocType"/>
<module name="LambdaParameterName"/>
<module name="LeftCurly"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MagicNumber"/>
<module name="MemberName"/>
<module name="MethodLength"/>
<module name="MethodName"/>
<module name="MethodParamPad"/>
<module name="MethodTypeParameterName"/>
<module name="MissingCtor"/>
<module name="MissingDeprecated"/>
<module name="MissingOverride"/>
<module name="MissingSwitchDefault"/>
<module name="ModifiedControlVariable"/>
<module name="ModifierOrder"/>
<module name="MultipleStringLiterals">
<property name="allowedDuplicates" value="2"/>
<property name="ignoreStringsRegexp" value="^&quot;.?.?&quot;$"/>
</module>
<module name="MultipleVariableDeclarations"/>
<module name="MutableException"/>
<module name="NeedBraces"/>
<module name="NPathComplexity"/>
<module name="NoArrayTrailingComma"/>
<module name="NoClone"/>
<module name="NoEnumTrailingComma"/>
<module name="NoFinalizer"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OneStatementPerLine">
<property name="treatTryResourcesAsStatement" value="true"/>
</module>
<module name="OneTopLevelClass"/>
<module name="OperatorWrap">
<property name="option" value="eol"/>
</module>
<module name="OuterTypeFilename"/>
<module name="OuterTypeNumber"/>
<module name="OverloadMethodsDeclarationOrder"/>
<module name="PackageDeclaration"/>
<module name="PackageName"/>
<module name="ParameterAssignment"/>
<module name="ParameterName"/>
<module name="ParameterNumber">
<property name="max" value="5"/>
</module>
<module name="ParenPad"/>
<module name="RedundantImport"/>
<module name="RedundantModifier"/>
<module name="RequireThis"/>
<module name="ReturnCount"/>
<module name="RightCurly">
<property name="option" value="alone"/>
</module>
<module name="SeparatorWrap">
<property name="tokens" value="COMMA,SEMI,ELLIPSIS,ARRAY_DECLARATOR"/>
<property name="option" value="eol"/>
</module>
<module name="SeparatorWrap">
<property name="tokens" value="DOT,AT,METHOD_REF"/>
<property name="option" value="nl"/>
</module>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="StaticVariableName"/>
<module name="StringLiteralEquality"/>
<module name="SuperClone"/>
<module name="SuperFinalize"/>
<module name="SuppressWarnings">
<!-- allow: fallthrough, unchecked (cf. https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javac.html#BHCJBHDF) -->
<property name="format" value="^\s*(?:all|cast|classfile|deprecation|dep-ann|divzero|empty|finally|options|overrides|path|processing|rawtypes|Serial|static|try|varargs)\s*$"/>
</module>
<module name="SuppressWithNearbyCommentFilter">
<property name="checkFormat" value="$1"/>
<property name="commentFormat" value="checkstyle-disable-line (\w+(?:\|\w+)?)"/>
</module>
<module name="ThrowsCount">
<property name="max" value="2"/>
</module>
<module name="TypecastParenPad"/>
<module name="TypeName"/>
<module name="UnnecessaryParentheses"/>
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration"/>
<module name="UnnecessarySemicolonInEnumeration"/>
<module name="UnnecessarySemicolonInTryWithResources">
<property name="allowWhenNoBraceAfterSemicolon" value="false"/>
</module>
<module name="UnusedImports"/>
<module name="UpperEll"/>
<module name="VisibilityModifier"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
</module>
</module>
Binary file removed docs/xtext-import.png
Binary file not shown.
26 changes: 26 additions & 0 deletions gradle/source-layout.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/main/xtext-gen']
resources.srcDirs = ['src/main/resources', 'src/main/xtext-gen']
}
test {
java.srcDirs = ['src/test/java', 'src/test/xtext-gen']
resources.srcDirs = ['src/test/resources', 'src/test/xtext-gen']
}
}

jar {
from('model') {
into('model')
}
from(sourceSets.main.allSource) {
include '**/*.xtext'
}
manifest {
attributes 'Bundle-SymbolicName': project.name
}
}

plugins.withId('war') {
webAppDirName = 'src/main/webapp'
}
File renamed without changes.
File renamed without changes.
Loading