Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
LakshanWeerasinghe committed Jun 4, 2024
1 parent 43849a2 commit f209fc0
Show file tree
Hide file tree
Showing 32 changed files with 193 additions and 193 deletions.
2 changes: 1 addition & 1 deletion build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ distribution = "2201.8.1"
graalvmCompatible = true

[[platform.java17.dependency]]
groupId = "io.ballerina.stdlib"
groupId = "io.ballerina.lib"
artifactId = "yaml-native"
version = "@toml.version@"
path = "../native/build/libs/[email protected]@.jar"
14 changes: 7 additions & 7 deletions native/src/main/java/io/ballerina/lib/data/yaml/Native.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml;
package io.ballerina.lib.data.yaml;

import io.ballerina.lib.data.yaml.emitter.Emitter;
import io.ballerina.lib.data.yaml.io.DataReaderTask;
import io.ballerina.lib.data.yaml.io.DataReaderThreadPool;
import io.ballerina.lib.data.yaml.parser.YamlParser;
import io.ballerina.lib.data.yaml.serializer.Serializer;
import io.ballerina.lib.data.yaml.utils.OptionsUtils;
import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.Future;
import io.ballerina.runtime.api.creators.ValueCreator;
Expand All @@ -28,12 +34,6 @@
import io.ballerina.runtime.api.values.BStream;
import io.ballerina.runtime.api.values.BString;
import io.ballerina.runtime.api.values.BTypedesc;
import io.ballerina.stdlib.data.yaml.emitter.Emitter;
import io.ballerina.stdlib.data.yaml.io.DataReaderTask;
import io.ballerina.stdlib.data.yaml.io.DataReaderThreadPool;
import io.ballerina.stdlib.data.yaml.parser.YamlParser;
import io.ballerina.stdlib.data.yaml.serializer.Serializer;
import io.ballerina.stdlib.data.yaml.utils.OptionsUtils;

import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.common;
package io.ballerina.lib.data.yaml.common;

/**
* Define basic types and schemas in YAML files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.common;
package io.ballerina.lib.data.yaml.common;

import io.ballerina.stdlib.data.yaml.common.Types.Collection;
import io.ballerina.lib.data.yaml.common.Types.Collection;

/**
* Parser Events when parsing yaml data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.emitter;
package io.ballerina.lib.data.yaml.emitter;

import io.ballerina.lib.data.yaml.common.Types;
import io.ballerina.lib.data.yaml.common.YamlEvent;
import io.ballerina.lib.data.yaml.utils.DiagnosticErrorCode;
import io.ballerina.lib.data.yaml.utils.DiagnosticLog;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.values.BString;
import io.ballerina.stdlib.data.yaml.common.Types;
import io.ballerina.stdlib.data.yaml.common.YamlEvent;
import io.ballerina.stdlib.data.yaml.utils.DiagnosticErrorCode;
import io.ballerina.stdlib.data.yaml.utils.DiagnosticLog;

import java.util.ArrayList;
import java.util.List;

import static io.ballerina.stdlib.data.yaml.utils.Constants.DEFAULT_GLOBAL_TAG_HANDLE;
import static io.ballerina.stdlib.data.yaml.utils.Constants.DEFAULT_LOCAL_TAG_HANDLE;
import static io.ballerina.stdlib.data.yaml.utils.Constants.END_OF_YAML_DOCUMENT;
import static io.ballerina.stdlib.data.yaml.utils.Constants.START_OF_YAML_DOCUMENT;
import static io.ballerina.lib.data.yaml.utils.Constants.DEFAULT_GLOBAL_TAG_HANDLE;
import static io.ballerina.lib.data.yaml.utils.Constants.DEFAULT_LOCAL_TAG_HANDLE;
import static io.ballerina.lib.data.yaml.utils.Constants.END_OF_YAML_DOCUMENT;
import static io.ballerina.lib.data.yaml.utils.Constants.START_OF_YAML_DOCUMENT;

/**
* Convert Yaml Event stream into list of YAML strings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.emitter;
package io.ballerina.lib.data.yaml.emitter;

import io.ballerina.stdlib.data.yaml.common.Types;
import io.ballerina.stdlib.data.yaml.common.YamlEvent;
import io.ballerina.lib.data.yaml.common.Types;
import io.ballerina.lib.data.yaml.common.YamlEvent;

/**
* Holds utilities use to emit YAML strings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.io;
package io.ballerina.lib.data.yaml.io;

import io.ballerina.lib.data.yaml.utils.DiagnosticLog;
import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.async.Callback;
import io.ballerina.runtime.api.async.StrandMetadata;
Expand All @@ -28,7 +29,6 @@
import io.ballerina.runtime.api.values.BMap;
import io.ballerina.runtime.api.values.BObject;
import io.ballerina.runtime.api.values.BString;
import io.ballerina.stdlib.data.yaml.utils.DiagnosticLog;

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.io;
package io.ballerina.lib.data.yaml.io;

import io.ballerina.lib.data.yaml.parser.YamlParser;
import io.ballerina.lib.data.yaml.utils.DiagnosticLog;
import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.Future;
import io.ballerina.runtime.api.types.MethodType;
Expand All @@ -27,8 +29,6 @@
import io.ballerina.runtime.api.values.BObject;
import io.ballerina.runtime.api.values.BString;
import io.ballerina.runtime.api.values.BTypedesc;
import io.ballerina.stdlib.data.yaml.parser.YamlParser;
import io.ballerina.stdlib.data.yaml.utils.DiagnosticLog;

import java.io.InputStreamReader;
import java.util.function.Consumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.io;
package io.ballerina.lib.data.yaml.io;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.lexer;
package io.ballerina.lib.data.yaml.lexer;

import io.ballerina.stdlib.data.yaml.utils.DiagnosticErrorCode;
import io.ballerina.stdlib.data.yaml.utils.DiagnosticLog;
import io.ballerina.stdlib.data.yaml.utils.Error;
import io.ballerina.lib.data.yaml.utils.DiagnosticErrorCode;
import io.ballerina.lib.data.yaml.utils.DiagnosticLog;
import io.ballerina.lib.data.yaml.utils.Error;

import java.io.IOException;
import java.io.Reader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.lexer;
package io.ballerina.lib.data.yaml.lexer;

import io.ballerina.stdlib.data.yaml.common.Types.Collection;
import io.ballerina.stdlib.data.yaml.utils.Error;
import io.ballerina.lib.data.yaml.common.Types.Collection;
import io.ballerina.lib.data.yaml.utils.Error;

import java.util.ArrayList;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,56 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.lexer;
package io.ballerina.lib.data.yaml.lexer;

import io.ballerina.stdlib.data.yaml.utils.Error;
import io.ballerina.lib.data.yaml.utils.Error;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

import static io.ballerina.stdlib.data.yaml.lexer.Scanner.COMMENT_SCANNER;
import static io.ballerina.stdlib.data.yaml.lexer.Scanner.VERBATIM_URI_SCANNER;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.ALIAS;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.ANCHOR;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.CHOMPING_INDICATOR;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.COMMENT;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.DECIMAL;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.DIRECTIVE;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.DIRECTIVE_MARKER;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.DOCUMENT_MARKER;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.DOT;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.DOUBLE_QUOTE_CHAR;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.DOUBLE_QUOTE_DELIMITER;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.EMPTY_LINE;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.EOL;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.FOLDED;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.LITERAL;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.MAPPING_END;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.MAPPING_KEY;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.MAPPING_START;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.MAPPING_VALUE;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.PLANAR_CHAR;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.PRINTABLE_CHAR;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.SEPARATION_IN_LINE;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.SEPARATOR;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.SEQUENCE_END;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.SEQUENCE_ENTRY;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.SEQUENCE_START;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.SINGLE_QUOTE_CHAR;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.SINGLE_QUOTE_DELIMITER;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.TAG;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.TAG_HANDLE;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.TAG_PREFIX;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.TRAILING_COMMENT;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.DECIMAL_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.FLOW_INDICATOR_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.URI_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.WHITE_SPACE_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.WORD_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.checkCharacters;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.discernPlanarFromIndicator;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.getWhitespace;
import static io.ballerina.lib.data.yaml.lexer.Scanner.COMMENT_SCANNER;
import static io.ballerina.lib.data.yaml.lexer.Scanner.VERBATIM_URI_SCANNER;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.ALIAS;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.ANCHOR;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.CHOMPING_INDICATOR;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.COMMENT;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.DECIMAL;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.DIRECTIVE;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.DIRECTIVE_MARKER;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.DOCUMENT_MARKER;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.DOT;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.DOUBLE_QUOTE_CHAR;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.DOUBLE_QUOTE_DELIMITER;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.EMPTY_LINE;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.EOL;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.FOLDED;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.LITERAL;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.MAPPING_END;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.MAPPING_KEY;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.MAPPING_START;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.MAPPING_VALUE;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.PLANAR_CHAR;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.PRINTABLE_CHAR;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.SEPARATION_IN_LINE;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.SEPARATOR;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.SEQUENCE_END;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.SEQUENCE_ENTRY;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.SEQUENCE_START;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.SINGLE_QUOTE_CHAR;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.SINGLE_QUOTE_DELIMITER;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.TAG;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.TAG_HANDLE;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.TAG_PREFIX;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.TRAILING_COMMENT;
import static io.ballerina.lib.data.yaml.lexer.Utils.DECIMAL_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.FLOW_INDICATOR_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.URI_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.WHITE_SPACE_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.WORD_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.checkCharacters;
import static io.ballerina.lib.data.yaml.lexer.Utils.discernPlanarFromIndicator;
import static io.ballerina.lib.data.yaml.lexer.Utils.getWhitespace;

/**
* State of the YAML Lexer.
Expand Down
26 changes: 13 additions & 13 deletions native/src/main/java/io/ballerina/lib/data/yaml/lexer/Scanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.lexer;
package io.ballerina.lib.data.yaml.lexer;

import io.ballerina.stdlib.data.yaml.utils.Error;
import io.ballerina.lib.data.yaml.utils.Error;

import java.util.HashMap;
import java.util.HexFormat;
import java.util.List;
import java.util.Map;

import static io.ballerina.stdlib.data.yaml.lexer.Utils.PRINTABLE_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.JSON_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.BOM_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.LINE_BREAK_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.WHITE_SPACE_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.DECIMAL_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.HEXA_DECIMAL_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.WORD_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.FLOW_INDICATOR_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.URI_PATTERN;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.matchPattern;
import static io.ballerina.lib.data.yaml.lexer.Utils.PRINTABLE_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.JSON_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.BOM_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.LINE_BREAK_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.WHITE_SPACE_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.DECIMAL_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.HEXA_DECIMAL_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.WORD_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.FLOW_INDICATOR_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.URI_PATTERN;
import static io.ballerina.lib.data.yaml.lexer.Utils.matchPattern;

/**
* This class will hold utility functions to scan and consume different character patterns.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.lexer;
package io.ballerina.lib.data.yaml.lexer;

/**
* Tokens used in YAML parser.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.lexer;
package io.ballerina.lib.data.yaml.lexer;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.lexer;
package io.ballerina.lib.data.yaml.lexer;

import io.ballerina.stdlib.data.yaml.utils.Error;
import io.ballerina.lib.data.yaml.utils.Error;

import static io.ballerina.stdlib.data.yaml.lexer.LexerState.LEXER_DOUBLE_QUOTE;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.EMPTY_LINE;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.TAG;
import static io.ballerina.stdlib.data.yaml.lexer.Token.TokenType.EOL;
import static io.ballerina.stdlib.data.yaml.lexer.Utils.isTagChar;
import static io.ballerina.lib.data.yaml.lexer.LexerState.LEXER_DOUBLE_QUOTE;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.EMPTY_LINE;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.TAG;
import static io.ballerina.lib.data.yaml.lexer.Token.TokenType.EOL;
import static io.ballerina.lib.data.yaml.lexer.Utils.isTagChar;

/**
* Core logic of the YAML Lexer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
* under the License.
*/

package io.ballerina.stdlib.data.yaml.parser;
package io.ballerina.lib.data.yaml.parser;


import io.ballerina.stdlib.data.yaml.lexer.LexerState;
import io.ballerina.stdlib.data.yaml.lexer.Token;
import io.ballerina.stdlib.data.yaml.utils.Error;
import io.ballerina.lib.data.yaml.lexer.LexerState;
import io.ballerina.lib.data.yaml.lexer.Token;
import io.ballerina.lib.data.yaml.utils.Error;

import java.util.List;

Expand Down
Loading

0 comments on commit f209fc0

Please sign in to comment.