public class ParserUtils extends Object
Modifier and Type | Field and Description |
---|---|
static Function<BLangIdentifier,String> |
B_LANG_IDENTIFIER_TO_STRING
Function to convert org.wso2.ballerinalang.compiler.tree.BLangIdentifier instance to
java.lang.String instance.
|
Constructor and Description |
---|
ParserUtils() |
Modifier and Type | Method and Description |
---|---|
static BallerinaFile |
compile(String content,
Path path)
Compile a Ballerina file.
|
static BallerinaFile |
compile(String content,
Path path,
CompilerPhase compilerPhase)
Compile a Ballerina file.
|
static BLangCompilationUnit |
compileFragment(String content)
Return a compilation unit for a given text.
|
static Map<String,ModelPackage> |
getAllPackages()
Get All Native Packages.
|
static BallerinaFile |
getBallerinaFile(String programDir,
String compilationUnitName)
This method is designed to generate the Ballerina model and Diagnostic information for a given Ballerina file.
|
static BallerinaFile |
getBallerinaFileForContent(Path filePath,
String fileName,
String source,
CompilerPhase compilerPhase)
This method is designed to generate the Ballerina model and Diagnostic information for a given Ballerina content.
|
static List<SymbolInformation> |
getBuiltinTypes()
Get the builtin types.
|
static Path |
getProgramDirectory(int directoryCount,
Path filePath) |
static void |
loadPackageMap(String packageName,
BLangPackage pkg,
Map<String,ModelPackage> packages)
Add connectors, functions, annotations etc.
|
static void |
removeConstructsOfFile(String pkgName,
String fileName,
Map<String,ModelPackage> packageMap)
Remove constructs from given file in given package from given package map.
|
public static final Function<BLangIdentifier,String> B_LANG_IDENTIFIER_TO_STRING
public static Path getProgramDirectory(int directoryCount, Path filePath)
directoryCount
- - packagePathfilePath
- - file path to parent directory of the .bal filepublic static BallerinaFile getBallerinaFile(String programDir, String compilationUnitName)
programDir
- - Path of the program directory.compilationUnitName
- - compilationUnitName name.public static BallerinaFile getBallerinaFileForContent(Path filePath, String fileName, String source, CompilerPhase compilerPhase)
fileName
- - File name. This can be any arbitrary name as as we haven't save the file yet.source
- - Ballerina source content that needs to be parsed.compilerPhase
- - This will tell up to which point(compiler phase) we should process the modelpublic static Map<String,ModelPackage> getAllPackages()
Map
Package name, package functions and connectorspublic static List<SymbolInformation> getBuiltinTypes()
List
list of builtin typespublic static void loadPackageMap(String packageName, BLangPackage pkg, Map<String,ModelPackage> packages)
packageName
- package namepkg
- BLangPackage instancepackages
- packages mappublic static void removeConstructsOfFile(String pkgName, String fileName, Map<String,ModelPackage> packageMap)
pkgName
- Name of the packagefileName
- Name of the FilepackageMap
- Package constructs mappublic static BLangCompilationUnit compileFragment(String content)
content
- public static BallerinaFile compile(String content, Path path)
content
- file contentpath
- file pathpublic static BallerinaFile compile(String content, Path path, CompilerPhase compilerPhase)
content
- file contentpath
- file pathcompilerPhase
- {CompilerPhase} set phase for the compiler.Copyright © 2018 WSO2. All rights reserved.