ec4j

An EditorConfig parser for Java

License

License

GroupId

GroupId

org.ec4j.core
ArtifactId

ArtifactId

ec4j-core-parent
Last Version

Last Version

0.3.0
Release Date

Release Date

Type

Type

pom
Description

Description

ec4j
An EditorConfig parser for Java
Project URL

Project URL

https://github.com/angelozerr/ec4j
Source Code Management

Source Code Management

https://github.com/angelozerr/ec4j

Download ec4j-core-parent

Filename Size
ec4j-core-parent-0.3.0.pom 21 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/org.ec4j.core/ec4j-core-parent/ -->
<dependency>
    <groupId>org.ec4j.core</groupId>
    <artifactId>ec4j-core-parent</artifactId>
    <version>0.3.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/org.ec4j.core/ec4j-core-parent/
implementation 'org.ec4j.core:ec4j-core-parent:0.3.0'
// https://jarcasting.com/artifacts/org.ec4j.core/ec4j-core-parent/
implementation ("org.ec4j.core:ec4j-core-parent:0.3.0")
'org.ec4j.core:ec4j-core-parent:pom:0.3.0'
<dependency org="org.ec4j.core" name="ec4j-core-parent" rev="0.3.0">
  <artifact name="ec4j-core-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='org.ec4j.core', module='ec4j-core-parent', version='0.3.0')
)
libraryDependencies += "org.ec4j.core" % "ec4j-core-parent" % "0.3.0"
[org.ec4j.core/ec4j-core-parent "0.3.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • core
  • ide-support
  • core-build

ec4j

License Maven Central Build Status

ec4j is an EditorConfig parser for Java.

Who is using ec4j?

Here are some projects that use `ec4j:

Basic usage

To parse a single .editorconfig file into an EditorConfig model:

java.nio.file.Path editorConfigFile = Paths.get("path/to/my/.editorconfig");
EditorConfigParser parser = EditorConfigParser.builder().build();
EditorConfigModelHandler handler = new EditorConfigModelHandler(EditorConfigConstants.VERSION,
            PropertyTypeRegistry.getDefault());
parser.parse(Resources.ofPath(editorConfigFile), StandardCharsets.UTF_8, handler);
EditorConfig editorConfig = handler.getEditorConfig();

To query the properties applicable to a file in a source tree:

Cache myCache = ...; // e.g. Caches.none()
EditorConfigLoader myLoader = ...; // e.g. EditorConfigLoader.getDefault()
EditorConfigSession mySession = EditorConfigSession.builder()
        .cache(myCache)
        .loader(myLoader)
        .rootDirectory(ResourcePaths.ofPath(Paths.get("/my/dir")))
        .build();
QueryResult result = mySession.queryProperties(Resources.ofPath(Paths.get("/my/dir1/Class1.java")));
IndentStyleValue indentStyleValue = result.getValue(PropertyType.indent_style, IndentStyleValue.space);
switch (indentStyleVal) {
    case space:
        // ...
        break;
    case tab:
        //...
        break;
    default:
        throw new IllegalStateException("Huh "+ indentStyleVal +"?");
    }
}

How to build

Prerequisites:

  • Java 7+

  • Optionally Maven 3.5.0+, unless you want to use ./mvnw or mvnw.bat delivered by the project

  • cmake 2.6+ to run the editorconfig-core-test testsuite (optional).

The most common build with unit tests:

./mvnw clean install

On Windows:

mvnw.bat clean install

A build with editorconfig-core-test testsuite:

git submodule init
git submodule update
mvn -Pcore-test clean install && ( cd core && cmake . && ctest . )

Relationship to editorconfig-core-java

ec4j aims at offering a superset of editorconfig-core-java 's functionality.

While editorconfig-core-java supports just the basic use case of querying the EditorConfig properties applicable to a given file, ec4j offers much more in addition to that:

ec4j took portions of code from editorconfig-core-java. Such ones are clearly marked in `ec4j’s JavaDoc.

Get support and contribute

  • License and community: ec4j is a community open-source project licensed under the Apache License.

  • Support: You can ask questions, report bugs, and request features using GitHub issues.

  • Git: This angelozerr/ec4j repository is the reference repository to contribute to ec4j

  • Build and CI: build can be performed with a simple mvn clean verify, continuous integration and deployment is performed by Travis CI

Versions

Version
0.3.0
0.2.2
0.2.1
0.2.0
0.1.0
0.0.4
0.0.3
0.0.2
0.0.1