public class TextDocumentFormatUtil extends Object
Constructor and Description |
---|
TextDocumentFormatUtil() |
Modifier and Type | Method and Description |
---|---|
static com.google.gson.JsonElement |
generateJSON(Node node,
Map<String,Node> anonStructs,
Map<BLangNode,List<SymbolMetaInfo>> symbolMetaInfoMap)
Generate json representation for the given node.
|
static com.google.gson.JsonObject |
getAST(Path file,
LSCompiler lsCompiler,
WorkspaceDocumentManager documentManager,
LSContext context)
Get the AST for the current text document's content.
|
static com.google.gson.JsonArray |
getType(Node node)
Get Type of the node as an Json Array.
|
static String |
toJsonName(String name,
int prefixLen)
Convert given name to the Json object name.
|
public static com.google.gson.JsonObject getAST(Path file, LSCompiler lsCompiler, WorkspaceDocumentManager documentManager, LSContext context) throws JSONGenerationException, LSCompilerException
file
- File path as a URIlsCompiler
- Language server compilerdocumentManager
- Workspace document manager instancecontext
- Document formatting contextJsonObject
AST as a Json ObjectJSONGenerationException
- when AST build failsLSCompilerException
- when compilation failspublic static com.google.gson.JsonElement generateJSON(Node node, Map<String,Node> anonStructs, Map<BLangNode,List<SymbolMetaInfo>> symbolMetaInfoMap) throws JSONGenerationException
node
- Node to get the json representationanonStructs
- Map of anonymous structssymbolMetaInfoMap
- symbol meta information mapJsonElement
Json Representation of the nodeJSONGenerationException
- when Json error occurspublic static String toJsonName(String name, int prefixLen)
name
- Name to be convertedprefixLen
- Length of prefixString
Converted valuepublic static com.google.gson.JsonArray getType(Node node)
node
- Node to get the typesJsonArray
Converted array valueCopyright © 2019 WSO2. All rights reserved.