public class CommonUtil extends Object
Constructor and Description |
---|
CommonUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
calculateEndColumnOfGivenName(DiagnosticPos position,
String name,
String pkgAlias)
Calculate the user defined type position.
|
static List<org.eclipse.lsp4j.Command> |
getCommandsByDiagnostic(org.eclipse.lsp4j.Diagnostic diagnostic,
org.eclipse.lsp4j.CodeActionParams params,
WorkspaceDocumentManager documentManager,
BLangPackageContext pkgContext)
Get the command instances for a given diagnostic.
|
static org.antlr.v4.runtime.Token |
getNextDefaultToken(org.antlr.v4.runtime.TokenStream tokenStream,
int startIndex)
Get the next default token from the given start index.
|
static org.antlr.v4.runtime.Token |
getNthDefaultTokensToLeft(org.antlr.v4.runtime.TokenStream tokenStream,
int startIndex,
int offset)
Get the Nth Default token to the left of current token index.
|
static org.antlr.v4.runtime.Token |
getNthDefaultTokensToRight(org.antlr.v4.runtime.TokenStream tokenStream,
int startIndex,
int offset)
Get the Nth Default token to the right of current token index.
|
static String |
getPackageURI(List<Name> pkgName,
String currentPkgPath,
List<Name> currentPkgName)
Get the package URI to the given package name.
|
static Path |
getPath(String uri)
Common utility to get a Path from the given uri string.
|
static org.antlr.v4.runtime.Token |
getPreviousDefaultToken(org.antlr.v4.runtime.TokenStream tokenStream,
int startIndex)
Get the previous default token from the given start index.
|
static DiagnosticPos |
toZeroBasedPosition(DiagnosticPos diagnosticPos)
Convert the diagnostic position to a zero based positioning diagnostic position.
|
public static String getPackageURI(List<Name> pkgName, String currentPkgPath, List<Name> currentPkgName)
pkgName
- Name of the package that need the URI forcurrentPkgPath
- String URI of the current packagecurrentPkgName
- Name of the current packagepublic static List<org.eclipse.lsp4j.Command> getCommandsByDiagnostic(org.eclipse.lsp4j.Diagnostic diagnostic, org.eclipse.lsp4j.CodeActionParams params, WorkspaceDocumentManager documentManager, BLangPackageContext pkgContext)
diagnostic
- Diagnostic to get the command againstparams
- Code Action parametersdocumentManager
- Document Manager instancepkgContext
- BLang Package ContextList
List of commands related to the given diagnosticpublic static Path getPath(String uri)
uri
- URI of the file to get as a PathPath
Path of the uripublic static void calculateEndColumnOfGivenName(DiagnosticPos position, String name, String pkgAlias)
position
- position of the nodename
- name of the user defined typepkgAlias
- package alias name of the user defined typepublic static DiagnosticPos toZeroBasedPosition(DiagnosticPos diagnosticPos)
diagnosticPos
- - diagnostic position to be clonedDiagnosticPos
converted diagnostic positionpublic static org.antlr.v4.runtime.Token getPreviousDefaultToken(org.antlr.v4.runtime.TokenStream tokenStream, int startIndex)
tokenStream
- Token StreamstartIndex
- Start token indexToken
Previous default tokenpublic static org.antlr.v4.runtime.Token getNextDefaultToken(org.antlr.v4.runtime.TokenStream tokenStream, int startIndex)
tokenStream
- Token StreamstartIndex
- Start token indexToken
Previous default tokenpublic static org.antlr.v4.runtime.Token getNthDefaultTokensToLeft(org.antlr.v4.runtime.TokenStream tokenStream, int startIndex, int offset)
tokenStream
- Token Stream to traversestartIndex
- Start position of the token streamoffset
- Number of tokens to traverse leftToken
Nth Tokenpublic static org.antlr.v4.runtime.Token getNthDefaultTokensToRight(org.antlr.v4.runtime.TokenStream tokenStream, int startIndex, int offset)
tokenStream
- Token Stream to traversestartIndex
- Start position of the token streamoffset
- Number of tokens to traverse rightToken
Nth TokenCopyright © 2018 WSO2. All rights reserved.