Git Product home page Git Product logo

editorconfig-core-java's Introduction

EditorConfig Java Binding

This directory is for EditorConfig Core Java Binding.

EditorConfig Project

EditorConfig makes it easy to maintain the correct coding style when switching between different text editors and between different projects. The EditorConfig project maintains a file format and plugins for various text editors which allow this file format to be read and used by those editors. For information on the file format and supported text editors, see the EditorConfig website.

How to use EditorConfig Core in Java

Add the editorconfig-core dependency to your pom.xml file:

  ...
  <dependencies>
    <dependency>
      <groupId>org.editorconfig</groupId>
      <artifactId>editorconfig-core</artifactId>
      <version><!-- lookup the newest version on http://mvnrepository.com/artifact/org.editorconfig/editorconfig-core --></version>
    </dependency>
  </dependencies>

A basic example:

EditorConfig ec = new EditorConfig();
List<EditorConfig.OutPair> l = null;
try {
    l = ec.getProperties("/home/user/src/editorconfig-core-py/a.py");
} catch(EditorConfigException e) {
    System.out.println(e);
    System.exit(1);
}

for(int i = 0; i < l.size(); ++i) {
    System.out.println(l.get(i).getKey() + "=" + l.get(i).getVal());
}

There is an online documentation for API details.

Build EditorConfig Core Java librarary

Prerequisistes: Java 6, Maven, Git, cmake 2.6+ (optional for tests)

Checkout the code

git clone https://github.com/editorconfig/editorconfig-core-java.git

Build the library with Maven:

cd editorconfig-core-java
mvn clean install

The built jar file is in the target directory.

Run the testsuite

First make sure that the submodule is initialized:

cd /path/to/editorconfig-core-java
git submodule init
git submodule update

Then prepare and run the tests using cmake:

cmake .
ctest .

How to Contribute

Pull requests are welcome on GitHub.

License

All source files of the Java binding are distributed under the Apache license. See LICENSE for details.

Copyright (C) 2012-2013, EditorConfig Team

editorconfig-core-java's People

Contributors

denofevil avatar emfataliev avatar greut avatar larsgrefer avatar os97673 avatar ppalaga avatar rvishnyakov avatar xuhdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

editorconfig-core-java's Issues

Perform the first Maven release

Not being sure at all how deep is the Maven knowledge here in editorconfig-core-java community, I am listing the steps necessary to perform the first Maven release.

(0) We should decide who will be the release engineer. Some of the project owners seems to be the most natural choice. I am ready to take the role too. Ideally, at least two community members should be able to release.

(1) Initial setup of our OSSRH Maven repository: http://central.sonatype.org/pages/ossrh-guide.html

(1.1) The release engineer needs to create a Jira account on Sonatype Jira: https://issues.sonatype.org/secure/Signup!default.jspa

(1.2) The release engineer needs to create a new project ticket that will be processed manually at Sonatype: https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134

(2) Our project needs to comply with Maven Central Requirements http://central.sonatype.org/pages/requirements.html such as GPG/PGP signing, supplying Javadoc and Sources, etc.

(3) The release engineer needs to release.

Paths with native Windows separator \ don't seem to be matched properly.

I'm working on Windows and tried to use gradle-eclipseconfig to manage charset settings in Eclipse project managed by Gradle. The examples provided by the project didn't work and I think I finally found the problem in the fact that the plugin forwards native paths to EditorConfig. While EditorConfig seems to have some recognition of \ in section-globs, it doesn't seem to normalize paths to match in the end. So the simple section [*] doesn't match Windows paths.

Have a look at the following debugging output:

11:01:56.533 [ERROR] [org.gradle.api.Project] C:\[...]\Dummy.java -> C:/[...]/Dummy.java
11:01:56.535 [ERROR] [system.err] .*/[^/]*
11:01:56.538 [ERROR] [system.err] .*/[^/]*
11:01:56.538 [ERROR] [org.gradle.api.Project] [:] -> [charset:utf-8, trim_trailing_whitespace:true, indent_style:space, indent_size:2, tab_width:2]
11:01:56.543 [ERROR] [system.err] .*/[^/]*

The outputs on STDERR are from EditorConfig by setting the following on the shell:

set JAVA_OPTS=-Deditorconfig.debug=true

These are the regular expressions matched against the paths and as you can see, those are using / instead of \ always with my very simple section. In my opinion, before matching the file paths those should be normalized to correspond with whatever is used in the patterns as separator.

https://github.com/editorconfig/editorconfig-core-java/blob/master/src/main/java/org/editorconfig/core/EditorConfig.java#L242

EditorConfig validator: support for line/column, offset info with ParsingException

It should be cool if we could have an utility method validate which waits a String content of an editorconfig and throws ParsingException when this content is not well formatted:

public class  EditorConfig {

....
  public void validate(String editorConfigContent) throws ParsingException {
    // here parse editorConfigContent and throws ParsingException  with line/column, offset info
  }
}

Here a sample with miss of close of [ for section names:

[*]
charset = utf-8

[*.md // <- here there is an error because section is not closed

The exception ParsingException should contains offset and line/column info where there is an error.

With this utility method validate, any IDE could support validation with marker.

Many thanks!

Inconsistent Java-Version

The Readme.md says:

Prerequisistes: Java 7

but the pom.xml contains:

<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.