- Notifications
You must be signed in to change notification settings - Fork7
ec4j/ec4j
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
ec4j
is anEditorConfig implementation for Java. It provides:
A parser for
.editorconfig
filesAn API for querying EditorConfig properties applicable to a given file
A model of an
editorconfig
file rich enough to support validation, folding, code completion, etc. of.editorconfig
files in editors and IDEs.
Here are some projects that useec4j
:
EditorConfig for Eclipse based on GenericEditor andtm4e.
Add the following dependency to your project:
<dependency> <groupId>org.ec4j.core</groupId> <artifactId>ec4j-core</artifactId> <version><!-- check the latest on http://central.maven.org/maven2/org/ec4j/core/ec4j-core/--></version></dependency>
To parse a single.editorconfig
file into anEditorConfig
model:
java.nio.file.PatheditorConfigFile =Paths.get("path/to/my/.editorconfig");EditorConfigParserparser =EditorConfigParser.builder().build();EditorConfigModelHandlerhandler =newEditorConfigModelHandler(PropertyTypeRegistry.default_(),Version.CURRENT);parser.parse(Resources.ofPath(editorConfigFile,StandardCharsets.UTF_8),handler,ErrorHandler.THROW_SYNTAX_ERRORS_IGNORE_OTHERS);EditorConfigeditorConfig =handler.getEditorConfig();
To query the properties applicable to a file in a source tree:
CachemyCache = ...;// e.g. Caches.permanent()EditorConfigLoadermyLoader = ...;// e.g. EditorConfigLoader.default_()ResourcePropertiesServicepropService =ResourcePropertiesService.builder() .cache(myCache) .loader(myLoader) .rootDirectory(ResourcePaths.ofPath(Paths.get("/my/dir"),StandardCharsets.UTF_8)) .build();ResourcePropertiesprops =propService.queryProperties(Resources.ofPath(Paths.get("/my/dir1/Class1.java"),StandardCharsets.UTF_8));IndentStyleValueindentStyleValue =props.getValue(PropertyType.indent_style,IndentStyleValue.space,true);charindentChar =indentStyleValue.getIndentChar();// Now you can e.g. check that /my/dir1/Class1.java is indented using indentChar
Prerequisites:
Java 8+
Optionally Maven 3.6.1+, unless you want to use
./mvnw
ormvnw.bat
delivered by the projectcmake 2.6+ to run theeditorconfig-core-test testsuite (optional).
The most common build with unit tests:
./mvnw clean install
On Windows:
mvnw.bat clean install
A build witheditorconfig-core-test testsuite:
git submodule initgit submodule updatemvn -Pcore-test clean install&& (cd core&& cmake.&& ctest. )
The authors ofec4j
decided to startec4j
because they were unsuccessful with their proposals ineditorconfig-core-java
.
Althoughec4j
is not a fork ofeditorconfig-core-java
it uses a few portions of code fromeditorconfig-core-java
. Such ones are clearly marked inec4j
's JavaDoc.
ec4j
aims at offering a superset ofeditorconfig-core-java
's functionality.
Whileeditorconfig-core-java
supports just the basic use case of querying the EditorConfig propertiesapplicable to a given file,ec4j
offers much more in addition to that:
A propermodel of an
.editorconfig
fileEditorConfigParser andEditorConfigHandler interfacedesigned to support syntax highlighting, validation, folding, etc. of
.editorconfig
files in IDEs.ec4j
is available on Maven Centralec4j
performs better against theeditorconfig-core test suite:Library
Lib. revision
Tests passed/total on Linux
Tests passed/total on Windows
ec4j
fa51d88
189/189
185/187
editorconfig-core-java
e3e0905
185/189
?
editorconfig-core-test
revision:0001aa2
All code and contributions are underApache License
Issues and Discussions:https://github.com/ec4j/ec4j/issues
The
ec4j/ec4j
repository is the reference repository for contributing toec4j
.
About
Java EditorConfig Parser
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.