public class LSCompiler extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
UNTITLED_BAL |
| Constructor and Description |
|---|
LSCompiler(WorkspaceDocumentManager documentManager) |
| Modifier and Type | Method and Description |
|---|---|
BallerinaFile |
compileContent(String content,
CompilerPhase phase) |
BallerinaFile |
compileContent(String content,
CompilerPhase phase,
boolean preserveWhitespace)
Returns a BallerinaFile compiling in-memory content.
|
BallerinaFile |
compileContent(String content,
Path filePath,
CompilerPhase phase) |
BallerinaFile |
compileContent(String content,
Path filePath,
CompilerPhase phase,
boolean preserveWhitespace) |
static BallerinaFile |
compileContent(String content,
Path filePath,
CompilerPhase phase,
WorkspaceDocumentManager documentManager,
boolean preserveWhitespace) |
static Path |
createAndGetTempFile(String tempFileId)
Create and returns temp file.
|
static String |
findProjectRoot(String parentDir)
Find project root directory.
|
static List<BLangPackage> |
getBLangPackage(LSContext context,
WorkspaceDocumentManager docManager,
boolean preserveWhitespace,
Class customErrorStrategy,
boolean compileFullProject)
Get the BLangPackage for a given program.
|
static String |
getPackageNameForGivenFile(String sourceRoot,
String filePath)
Get the package name for given file.
|
static String |
getSourceRoot(Path filePath)
Get the source root for the given package.
|
static String |
getUnsavedFileIdOrNull(String filePath)
Returns unsaved file id or null.
|
static boolean |
isProjectDir(String root,
String fileUri)
Check whether given directory is a project dir.
|
static CompilerContext |
prepareCompilerContext(PackageID packageID,
PackageRepository packageRepository,
LSDocument sourceRoot,
boolean preserveWhitespace,
WorkspaceDocumentManager documentManager)
Prepare the compiler context.
|
static CompilerContext |
prepareCompilerContext(PackageID packageID,
PackageRepository packageRepository,
LSDocument sourceRoot,
boolean preserveWhitespace,
WorkspaceDocumentManager documentManager,
CompilerPhase compilerPhase)
Prepare the compiler context.
|
public static final String UNTITLED_BAL
public LSCompiler(WorkspaceDocumentManager documentManager)
public BallerinaFile compileContent(String content, CompilerPhase phase)
public BallerinaFile compileContent(String content, CompilerPhase phase, boolean preserveWhitespace)
content - phase - public BallerinaFile compileContent(String content, Path filePath, CompilerPhase phase)
public BallerinaFile compileContent(String content, Path filePath, CompilerPhase phase, boolean preserveWhitespace)
public static BallerinaFile compileContent(String content, Path filePath, CompilerPhase phase, WorkspaceDocumentManager documentManager, boolean preserveWhitespace)
public static CompilerContext prepareCompilerContext(PackageID packageID, PackageRepository packageRepository, LSDocument sourceRoot, boolean preserveWhitespace, WorkspaceDocumentManager documentManager)
packageID - Package NamepackageRepository - Package RepositorysourceRoot - LSDocument for Source RootpreserveWhitespace - Preserve WhitespaceCompilerContext Compiler contextpublic static CompilerContext prepareCompilerContext(PackageID packageID, PackageRepository packageRepository, LSDocument sourceRoot, boolean preserveWhitespace, WorkspaceDocumentManager documentManager, CompilerPhase compilerPhase)
packageID - Package IDpackageRepository - Package RepositorysourceRoot - LSDocument for Source RootpreserveWhitespace - Preserve WhitespaceCompilerContext Compiler contextpublic static List<BLangPackage> getBLangPackage(LSContext context, WorkspaceDocumentManager docManager, boolean preserveWhitespace, Class customErrorStrategy, boolean compileFullProject)
context - Language Server ContextdocManager - Document managerpreserveWhitespace - Enable preserve whitespacecustomErrorStrategy - custom error strategy classcompileFullProject - compile full project from the source rootBLangPackage BLang Packagepublic static String findProjectRoot(String parentDir)
parentDir - current parent directoryString project root | nullpublic static String getSourceRoot(Path filePath)
filePath - current file's pathString program directory pathpublic static boolean isProjectDir(String root, String fileUri)
root - root pathBoolean true if project dir, else falsepublic static String getPackageNameForGivenFile(String sourceRoot, String filePath)
sourceRoot - source rootfilePath - full path of the fileString package namepublic static Path createAndGetTempFile(String tempFileId)
tempFileId - temp file idCopyright © 2018 WSO2. All rights reserved.