public class FormattingSourceGen extends Object
Constructor and Description |
---|
FormattingSourceGen() |
Modifier and Type | Method and Description |
---|---|
static void |
addNewWS(com.google.gson.JsonObject targetNode,
com.google.gson.JsonObject tree,
String ws,
String text,
boolean isStatic,
int startIndex)
Add new whitespace object to given target node on given start index
and then update the rest of the tree accordingly.
|
static com.google.gson.JsonObject |
build(com.google.gson.JsonObject json,
String parentKind)
process the given json before source generation.
|
static List<com.google.gson.JsonObject> |
extractWS(com.google.gson.JsonObject node)
Extract Whitespaces from the given node sorted by the token index.
|
static String |
getSourceOf(com.google.gson.JsonObject node)
Get the source of the given node.
|
static int |
getStartPosition(com.google.gson.JsonObject node,
String attachPoint,
int insertBefore)
Get the start position suitable in the given attach point where new node to be added.
|
static void |
reconcileWS(com.google.gson.JsonObject node,
com.google.gson.JsonArray attachPoint,
com.google.gson.JsonObject tree,
int startIndex)
Reconcile whitespaces for the given node as to the attach point and the start index.
|
public static com.google.gson.JsonObject build(com.google.gson.JsonObject json, String parentKind)
json
- Current JSON AST nodeparentKind
- Parent kindJsonObject
Processed AST nodepublic static String getSourceOf(com.google.gson.JsonObject node)
node
- Node to generate the ballerina source forString
Generated source stringpublic static List<com.google.gson.JsonObject> extractWS(com.google.gson.JsonObject node)
node
- node to extract the white spacesList
list of white spacespublic static void reconcileWS(com.google.gson.JsonObject node, com.google.gson.JsonArray attachPoint, com.google.gson.JsonObject tree, int startIndex)
node
- Json Node to be added in to the node treeattachPoint
- Attach point for the nodetree
- whole Json AST treestartIndex
- Start index where the node to be addedpublic static void addNewWS(com.google.gson.JsonObject targetNode, com.google.gson.JsonObject tree, String ws, String text, boolean isStatic, int startIndex)
targetNode
- target node where new WS to be addedtree
- AST for the whole source filews
- Whitespacetext
- text in the whitespaceisStatic
- set the Static state of the wsstartIndex
- start index for the whitespacepublic static int getStartPosition(com.google.gson.JsonObject node, String attachPoint, int insertBefore)
node
- Parent of the attach pointattachPoint
- Name of the attach point where the new node to be addedinsertBefore
- start position to add the new node above existing nodeint
start position suitable for the new node to be addedCopyright © 2019 WSO2. All rights reserved.