Add capability to get properties#42
Add capability to get properties#42JacksonBailey wants to merge 9 commits intoncjones:masterfrom JacksonBailey:add-capability-to-get-properties
Conversation
This is a workaround for some of the editors needing more than a single property during visiting. - See: #41
The XML editor has two properties, `indentationChar` and
`indentationSize`. `indentationChar` is which character to use for
indentation (as expected) but `indentationSize` is how many of the
*`indentationChar` character* to use, now *how many columns one level of
indentation should be.*
As such, If your `.editorconfig` file has `indent_style = tab` and
`indent_size = 2` (something like below for example) then the XML editor
will use *2 tabs* for one level of indentation.
[*]
indent_size = 2
[*.xml]
indent_style = tab
Each of those 2 tabs will be 2 columns wide so the individual tabs are
being *displayed* correctly, just not *placed* correctly.
This change makes it so that the XML editor's `indentationSize` set to
the `.editorconfig` file's `indent_size`'s value *only* when the
`indent_style` is `space`. When it is `tab` the XML editor's
`indentationSize` is cleared.
- See: #41
| @@ -0,0 +1,99 @@ | |||
| /* | |||
| * Copyright 2017 Nathan Jones, Jackson Bailey | |||
There was a problem hiding this comment.
@ncjones I put your name here even though you haven't touched this file since all the code was copied and pasted from a file you wrote.
There was a problem hiding this comment.
The tests have never been run on Windows. I have tried to fix the platform-dependent nature of the test code in the "cross-platform-functional-tests" branch by using Paths.get(URI) instead of Paths.get(String[]). Can you please pull that branch and see if it works for you now?
There was a problem hiding this comment.
That fixes it, they work with and without my changes now. If want to you merge those into master I can rebase or if you don't like rebases I can just cherry-pick it.
There was a problem hiding this comment.
I've merged my fixes for the functional test suite on Windows. You can rebase this branch on master.
| return configProperties; | ||
| } | ||
|
|
||
| public ConfigProperty getConfigProperty(String name) { |
There was a problem hiding this comment.
Please write a unit test for this method.
| @Override | ||
| public void visitIndentSize(final ConfigProperty<Integer> property) { | ||
| final String indentSizeString = property.getValue().toString(); | ||
| final Object indentStyle = editorFileConfig.getConfigProperty("INDENT_STYLE").getValue(); |
There was a problem hiding this comment.
Can getConfigProperty("INDENT_STYLE") ever return null?
There was a problem hiding this comment.
Yes, it looks like if indent style is not set in the file or any parent then it could return null.
There was a problem hiding this comment.
I added a null-check to avoid exceptions. indentStyle can still be null but it shouldn't matter.
|
Sorry for disappearing for a couple of months on this. I've merged master into my branch and the (current) functional tests all pass. I will add some for the new features as well as unit tests and I will check if |
| Bundle-Name: EditorConfig Eclipse Functional Test | ||
| Bundle-SymbolicName: editorconfig-eclipse-functional-test;singleton:=true | ||
| Bundle-Version: 0.3.0.qualifier | ||
| Bundle-Version: 0.4.0.qualifier |
There was a problem hiding this comment.
I don't know if this needed to be changed, but it looked like here and in the POM the version wasn't bumped. I can remove this commit if it's not supposed to be here.
There was a problem hiding this comment.
This was overlooked. I've already pushed this change to master and updated the "update-versions.sh" script so that this doesn't happen again.
|
@ncjones I was adding functional tests for the new feature but the test for Ant's (Here is the commit I made showing the problem. If you remove the tab test or don't have the |
|
@JacksonBailey maven artifacts are by default cached in ~/.m2. I would do something like the following in Bash to remove relevant artifacts: find "$HOME/.m2" -type d -name '*editorconfig*' | xargs rm -rf |
|
I checked my m2, but I was looking in |
|
I've cherry picked the commits for refactoring the visitor and adding the method to get properties by name. Can you please rebase the remainder of the work? I have two concerns about the functional change here:
By the way, there should be a new test for this scenario (indent size + style) instead of just adding indent size to the existing indent style test. |
|
This PR is superseded by #47. |
|
Closed, please see #47 |
@ncjones Please don't blindly merge this because I haven't ran added functional tests or installed and tested locally yet, I just wanted your initial thoughts.
Also, I can't get the functional tests to work locally (even without my changes), can they not be ran from Windows? When I run
mvn -f editorconfig-eclipse-functional-test/pom.xml integration-testit opens an Eclipse window and just hangs for a while and then prints out a lot of tests failing with this output