Commit Graph

731 Commits

Author SHA1 Message Date
Havoc Pennington
ea78c17381 Merge pull request #298 from fpringvaldsen/task/improve-indentation
Improve indentation
2015-04-01 21:08:24 -04:00
Preben Ingvaldsen
deb32bcab0 Change parent class of ConfigNodeInclude
Modify the parent class of ConfigNodeInclude to be
AbstractConfigNode instead of ConfigNodeComplexValue, as an
include statement is not a value.
2015-04-01 16:06:02 -07:00
Preben Ingvaldsen
dc567e8489 Look at includes when finding indentation
Modify the indentation calculation algorithm to also look at the
indentation before include nodes.
2015-04-01 13:20:33 -07:00
Preben Ingvaldsen
1b257fd426 Address PR feedback and add new test
Cleanup the indentText() method on ConfigNodeComplexValue as per
PR feedback. Add a test for indentation when inserting a value
with an include statement.
2015-04-01 13:20:33 -07:00
Preben Ingvaldsen
a29475ba4a Indent multi-line values on replacement
Indent multi-line values when they replace a value in a
ConfigDocument.
2015-04-01 13:20:33 -07:00
Preben Ingvaldsen
7ec3777c25 Improve indentation when adding a setting
Modify the algorithm for adding a new value into a ConfigDocument
so that it will attempt to indent the new setting properly.
2015-04-01 13:20:33 -07:00
Havoc Pennington
2dcefc006b Merge pull request #296 from fpringvaldsen/task/removeValue-fix
Fix removeValue test failures
2015-03-30 19:12:24 -04:00
Preben Ingvaldsen
33fed067b6 Fix removeValue test failures 2015-03-30 15:51:43 -07:00
Havoc Pennington
dcab6e7158 Add some failing tests for ConfigDocument.removeValue 2015-03-30 16:29:35 -04:00
Havoc Pennington
ed004d47e7 Merge pull request #294 from fpringvaldsen/task/more-ConfigDocument-methods
Add new ConfigDocument API methods
2015-03-30 16:18:56 -04:00
Preben Ingvaldsen
e959e2c8a9 Address PR feedback
Reduce cast noise in the `hasValue` method in the
ConfigNodeObject class. Cleanup exception testing in
ConfigDocument array tests.
2015-03-30 13:09:05 -07:00
Preben Ingvaldsen
d6c9f632ab Modify duplicate removal
Modify the ConfigDocument duplicate removal so that multi-element
paths beginning with the desired path whose value should be set
are always removed as duplicates.
2015-03-30 11:53:57 -07:00
Preben Ingvaldsen
97bd1f60c0 Add new ConfigDocument API methods
Add two new methods to the ConfigDocument API, hasValue() and
removeValue(), along with tests.
2015-03-30 11:53:57 -07:00
Havoc Pennington
d4ab52fb6b Merge pull request #292 from typesafehub/parser-package
Parser package
2015-03-30 14:41:13 -04:00
Havoc Pennington
52d997beff Add package.html for parser package and some other doc tweaks 2015-03-30 09:59:30 -04:00
Havoc Pennington
2d83b1fb6b Move ConfigDocument and ConfigNode into a "parser" package
This should cut down on people wasting time on these when they
are looking for the regular config API; they are for a narrower
use-case.
2015-03-30 09:40:59 -04:00
Havoc Pennington
2af0b42ad9 Mention getIsNull and hasPathOrNull as exceptions to "Config hides null" docs 2015-03-29 10:31:51 -04:00
Havoc Pennington
26dc482c0f Merge pull request #287 from fpringvaldsen/task/integrate-ConfigDocument
Refactor Parser
2015-03-28 21:27:18 -04:00
Preben Ingvaldsen
74070b44cc Address PR feedback
Address numerous pieces of PR feedback, including:
  * Change ConfigDocumentParser's parse method to take a
    ConfigOrigin as a parameter, and uses this origin when
    throwing Parse exceptions rather than a dummy origin
  * Pass in the type of an include node on construction so it
    does not have to parse the information out itself
  * Add tests to ensure an empty object is created inside a
    ConfigNodeRoot when an empty document is given
  * Remove unused instance variables or variables duplicated
    between the two parsers
2015-03-27 13:36:58 -07:00
Preben Ingvaldsen
13cb4785b9 Fix compilation errors 2015-03-27 09:13:07 -07:00
Havoc Pennington
a7240387e8 Add a test for serializing WrongType exception
There's a bug report about this not working... it seems to work
here though.
2015-03-27 10:38:12 -04:00
Preben Ingvaldsen
368ad614f8 Refactor Parser to parse ConfigNodes
Rename the Parser class to ConfigParser. Refactor ConfigParser
to parse ConfigNodes rather than Tokens.
2015-03-26 15:26:23 -07:00
Havoc Pennington
a3c255e50a Merge pull request #286 from typesafehub/get-is-null
Add Config.hasPathOrNull and Config.getIsNull
2015-03-25 18:04:28 -04:00
Havoc Pennington
c26d977884 Add "use hasPathOrNull/getIsNull" to README
Make these a sixth option in the list of things to
consider if you're looking for the "getOptional" kind
of method.
2015-03-25 18:01:18 -04:00
Preben Ingvaldsen
05e7a0e176 Add line numbers to ConfigDocumentParser errors
Add line numbers into the ConfigDocumentParser error messages,
as these were previously not being displayed.
2015-03-25 11:54:01 -07:00
Preben Ingvaldsen
7aff85dead Fix same-line comments bug in ConfigDocumentParser
Fix bug wherein putting a comment on the same line as a value
would cause an exception to be thrown by the ConfigDocumentParser
2015-03-25 11:28:15 -07:00
Preben Ingvaldsen
59981da04d Allow leading whitespace in ConfigDocumentParser
Fix a bug with the ConfigDocumentParser in which an exception
would be thrown when there was leading whitespace in front
of the top-level object.
2015-03-25 11:08:10 -07:00
Havoc Pennington
18e30353fd Fix bad html in hasPathOrNull doc comment 2015-03-24 13:44:05 -04:00
Havoc Pennington
92dc50ea0a Add Config.hasPathOrNull and Config.getIsNull
This is for #186 / #282 as an alternative to adding
a ton of getFooOrNull methods. With these methods apps
can handle null or missing settings in a special way
if they see fit.
2015-03-24 13:44:05 -04:00
Havoc Pennington
25a9f91230 Merge pull request #280 from fpringvaldsen/task/create-ConfigNode
Add ConfigDocument API
2015-03-24 13:37:01 -04:00
Preben Ingvaldsen
b70d4c1fc9 Update single value parsing
Update the single value parsing method to throw an exception
when there is leading or trailing whitespace. Modify concatenation
parsing in the ConfigDocumentParser to put back any trailing
whitespace. Add a hashCode method for AbstractConfigNodes.
2015-03-24 10:15:50 -07:00
Preben Ingvaldsen
1639a91481 Address further PR feedback before merge
Implement an `equals()` method for AbstractConfigNodes. Add a
test to ensure an exception is thrown when calling setValue()
on a ConfigDocument when passing in a value with HOCON syntax
when the document was parsed as JSON. Add a setValue() method to
the ConfigDocument interface that takes a ConfigValue instead of
a String. When parsing a single value, throw an exception if a
concatenation is seen when parsing JSON.
2015-03-23 15:55:38 -07:00
Preben Ingvaldsen
c3a2e07c6a Address some more PR feedback
Make the javadoc string for the ConfigDocument interface more
explicit about what it does with the value string when setting
a value. Add support for parsing a reader into a ConfigDocument.
2015-03-23 14:02:59 -07:00
Havoc Pennington
e8c51c4654 Merge pull request #285 from glenford/master
Add Beamly clojure wrapper to the README
2015-03-23 13:41:11 -04:00
Preben Ingvaldsen
28a096f157 Cleanup based on findbugs 2015-03-20 14:09:17 -07:00
Glen Ford
92a87dbc4f Add Beamly clojure wrapper to the README 2015-03-20 08:37:06 +00:00
Preben Ingvaldsen
4b61790fb4 Improve field addition in node replacement
Improve the field addition in node replacement so that it will
create any non-existent objects along the desired path to the
desired value. Modify Path Node parsing so that subpaths can
be retrieved with the necessary tokens for those subpaths.
Ensure that the addition of a new field in a JSON document
results in valid JSON.
2015-03-19 16:28:32 -07:00
Preben Ingvaldsen
639a3eae5b Add ConfigDocument tests
Add ConfigDocument tests that parse a String or a file, ensure
that the original text can be rendered, and test value
replacement.
2015-03-18 15:46:25 -07:00
Preben Ingvaldsen
c44ef1c6f7 Add new subclasses of ConfigNodeComplexValue
Add three new classes, ConfigNodeObject, ConfigNodeArray, and
ConfigNodeConcatenation, to differentiate the three types of
complex nodes. Disallow setting values outside of
ConfigNodeObjects.
2015-03-18 10:38:09 -07:00
Havoc Pennington
24c6b097cb Merge pull request #284 from jmccure/fix-hash-comment-test
Amend duplicated whitespace comment test
2015-03-17 16:54:51 -07:00
Jay McCure
1227c35ced Amend duplicated whitespace comment test 2015-03-17 20:20:21 +00:00
Preben Ingvaldsen
d3b33cc6c2 Refactor parseConcatenation() method
Refactor the parseConcatenation() method in ConfigDocumentParser
to not throw out parsed values if only one value was seen. Rename
parseConcatenation to consolidateValues().
2015-03-17 10:46:36 -07:00
Preben Ingvaldsen
f115731071 Add ConfigDocumentParser JSON tests
Add tests to ensure that the ConfigDocumentParser can parse
valid JSON, and that it throws the proper errors when parsing
invalid JSON.
2015-03-16 15:43:24 -07:00
Preben Ingvaldsen
4101f942d2 Create ConfigDocumentParser
Create a new Parser, ConfigDocumentParser, which can parse an
input reader into a ConfigNodeComplexValue, which can
then be used to reproduce the exact original text of the input.
2015-03-16 15:43:16 -07:00
Preben Ingvaldsen
2e6bc40490 Address further PR feedback
Address ConfigNode PR feedback, including
  * Add @Override tags for all tokens() methods
  * Make `children()` method in ConfigNodeComplexValue final
  * Rename ConfigNodeKey to ConfigNodePath
  * Rename ConfigNodeKeyValue to ConfigNodeField
  * Modify PathParser so it can parse a string into either a Path
    or a ConfigNodePath
2015-03-12 11:23:06 -07:00
Preben Ingvaldsen
b19e38f29b Extract Path parsing into new class
Extract the logic to parse a Path out of the Parser and into
a new PathParser class.
2015-03-11 13:59:57 -07:00
Preben Ingvaldsen
0a804deff5 Add docs and copyright information
Add copyright information to all ConfigNode classes. Document
the ConfigNode interface.
2015-03-11 13:35:06 -07:00
Preben Ingvaldsen
cce8c204ac Keep tokens in Path
Save the list of Tokens from which a Path was created when a
Path is parsed from a string in Parser.parsePath. Change
ConfigNodeKey to store a Path instead of a token.
2015-03-11 11:27:28 -07:00
Preben Ingvaldsen
e695543bf1 Address ConfigNode PR feedback
Address various PR feedback, including:
  * Remove unused map from ConfigNodeComplexValue
  * Stop caching KeyValue indexes in ConfigNodeComplexValue
  * Return an Iterable<Token> for the children() methods in
    ConfigNodeComplexValue and ConfigNodeKeyValue
  * Change all ConfigNode classes to implement AbstractConfigNode
  * Remove the constructor and the token instance variable
    from AbstractConfigNode. Make the render() method final and
    have it use a new tokens() method which returns the list
    of tokens contained by the node.
  * Stop caching values in ConfigNodeKeyValue
2015-03-11 09:41:32 -07:00
Preben Ingvaldsen
3166db4d72 Add more robust ConfigNode tests
Add more robust tests for ConfigNode classes. Add tests to
test arrays, duplicate removal, and addition of non-existent
paths.
2015-03-10 13:55:46 -07:00