Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/ec4jPublic

Java EditorConfig Parser

License

NotificationsYou must be signed in to change notification settings

ec4j/ec4j

Repository files navigation

ec4j

LicenseMaven Centralbadge

ec4j is anEditorConfig implementation for Java. It provides:

  • A parser for.editorconfig files

  • An API for querying EditorConfig properties applicable to a given file

  • A model of aneditorconfig file rich enough to support validation, folding, code completion, etc. of.editorconfig files in editors and IDEs.

Who is usingec4j?

Basic usage

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

How to build

Prerequisites:

  • Java 8+

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

  • cmake 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. )

Relationship toeditorconfig-core-java

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:

Misc.

About

Java EditorConfig Parser

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp