Class BslUtils

java.lang.Object
com.e1c.langtool.v8.dt.bsl.BslUtils

public final class BslUtils extends Object
  • Field Details

  • Method Details

    • splitStringKeys

      @Deprecated public static String[] splitStringKeys(String lines)
      Deprecated.
      Split string into valid keys.
      Parameters:
      lines - the lines
      Returns:
      the string[], never null.
    • splitStringKeys

      @Deprecated public static String[] splitStringKeys(StringLiteral literal)
      Deprecated.
      Split string literal lines into valid keys.
      Parameters:
      literal - the literal
      Returns:
      the string[], never null.
    • getNlsLocalStrings

      public static Map<String,String> getNlsLocalStrings(StringLiteral object)
      Gets the nls local strings as a map of language code and value.
      Parameters:
      object - the object
      Returns:
      the nls local strings, cannot return null
    • getString

      public static String getString(StringLiteral literal)
      Gets the content of the StringLiteral without "|" and without start-end quotes
      Parameters:
      literal - the literal, can't be null
      Returns:
      content of the StringLiteral without "|", never null
    • getQueryText

      public static String getQueryText(StringLiteral literal)
      Gets the query text from the string literal lines with removing query package separator or query union keyword. Lines of query text will be joined with STRING_LINE_SEPARATOR regardless current system line separator.
      Parameters:
      literal - the literal with one of query types, cannot be null.
      Returns:
      the query text, cannot return null.
    • formatForStringLiteral

      public static String formatForStringLiteral(String content, String prefixLine)
      Transform text to the StringLiteral content in Bsl module
      Parameters:
      content - transforming content, can't be null. Content lines must be speparated with LF or "\n" symbol or STRING_LINE_SEPARATOR
      prefixLine - the prefix line inserted before service symbol "|", can't be null
      Returns:
      text of the StringLiteral with service symbols "|", never null. Returning line joined with system line separator System.lineSeparator() can be CR+LF or LF
    • formatAndQuoteForStringLiteral

      public static String formatAndQuoteForStringLiteral(String content, String prefixLine)
      Format and quote for string literal.
      Parameters:
      content - the content
      prefixLine - the prefix line
      Returns:
      the string
    • formatAndQuoteForStringLiteral

      public static List<String> formatAndQuoteForStringLiteral(List<String> lines, String prefixLine)
      Format and quote for string literal.
      Parameters:
      lines - the lines
      prefixLine - the prefix line
      Returns:
      the list
    • formatNStrStringLiteral

      public static String formatNStrStringLiteral(Map<String,String> map, String[] indentation)
      Generate double-quoted string representation of map containing localized messages for zero or more languages. Second and following lines are indented with indentation lines, passed in indentation parameter. If resulting string lines count is greater than indentation.length value of indentation[indentation.length - 1] will be used for all exceeding lines. Resulting string is safe to be used as an parameter of NStr function in BSL file text.
      Parameters:
      map - Mapping from language code to localized message in that language.
      indentation - Array of strings to be used as an indentation prefixes.
      Returns:
      Double-quoted string with all entries from passed map indented with entries of indentation array.
    • formatNStrEntry

      public static String formatNStrEntry(String languageCode, String value)
      Format single NStr entry to string with pattern "langCode = 'value'" . Note that NStr-formatted pattern does NOT contains semicolon at the end of formated string;
      Parameters:
      languageCode - the language code
      value - the value of NStr for the language code
      Returns:
      the formatted string without semicolon at the end.
    • getLastLineIdentation

      public static String getLastLineIdentation(StringLiteral literal, int lengthDiff)
      Gets the last line identation.
      Parameters:
      literal - the literal
      lengthDiff - the length diff
      Returns:
      the last line identation
    • getNodeIdentation

      public static String getNodeIdentation(org.eclipse.xtext.nodemodel.INode node, int lengthDiff)
      Gets the node identation.
      Parameters:
      node - the node
      lengthDiff - the length diff
      Returns:
      the node identation
    • isEmptySource

      public static boolean isEmptySource(List<FeatureEntry> features)
      Checks if the some object's list of features is empty source.
      Parameters:
      features - the features of the object
      Returns:
      true, if it is empty source
    • isInlineDocCommentNode

      public static boolean isInlineDocCommentNode(org.eclipse.xtext.nodemodel.ILeafNode node)
      Checks if is inline doc comment node.
      Parameters:
      node - the node
      Returns:
      true, if is inline doc comment node
    • getCommentNodeVariable

      public static Variable getCommentNodeVariable(org.eclipse.xtext.nodemodel.ILeafNode node)
      Gets the comment node variable.
      Parameters:
      node - the node
      Returns:
      the comment node variable
    • getFeatrueKeyPreffix

      public static String getFeatrueKeyPreffix(BslDocumentationComment model)
      Gets the featrue key preffix.
      Parameters:
      model - the model
      Returns:
      the featrue key preffix
    • getUpAndDownCommentNodes

      public static List<org.eclipse.xtext.nodemodel.INode> getUpAndDownCommentNodes(org.eclipse.xtext.nodemodel.INode node)
      Collects all comment lines that are not separated from the incoming comment by a non-comment line.
      Parameters:
      node - the node of an incoming comment that is part of an entire block of comments. It can be the first line of the comment, the last, or any line between the first and the last.
      Returns:
      the nodes of all comment lines that are not separated from the incoming comment by a non-comment line.
    • getCommentLines

      public static List<String> getCommentLines(List<org.eclipse.xtext.nodemodel.INode> nodes)
      Gets string content of the comment lines.
      Parameters:
      nodes - the adjacent nodes
      Returns:
      the comment lines
    • getOwnerNode

      public static org.eclipse.emf.ecore.EObject getOwnerNode(List<org.eclipse.xtext.nodemodel.INode> lines)
      Gets the owner node.
      Parameters:
      lines - the lines
      Returns:
      the owner node
    • getOwnerDocNode

      public static org.eclipse.emf.ecore.EObject getOwnerDocNode(List<org.eclipse.xtext.nodemodel.INode> lines)
      Gets the owner doc node.
      Parameters:
      lines - the lines
      Returns:
      the owner doc node
    • getInlineCommentAfterObject

      public static List<String> getInlineCommentAfterObject(org.eclipse.emf.ecore.EObject expressionBeforeComment, org.eclipse.xtext.nodemodel.INode blockNode, boolean oldFormatComment)
      Provides the List of inlined comments for semantic element.
      Parameters:
      expressionBeforeComment - the element for which the inlined comment is being taken, cannot be null
      blockNode - the parent node for element, cannot be null
      oldFormatComment - true if comment in old format, false in new format
      Returns:
      the List of inlined comments, cannot be null
    • collectMultilineCommentAfterObject

      public static List<String> collectMultilineCommentAfterObject(org.eclipse.emf.ecore.EObject expressionBeforeComment, org.eclipse.xtext.nodemodel.INode blockNode)
      Collect multiline comment after object.
      Parameters:
      expressionBeforeComment - the expression before comment, cannot be null
      blockNode - the block node, cannot be null
      Returns:
      the list of comment lines
    • getTextWithoutSplashes

      public static String getTextWithoutSplashes(String text)
    • isNStr

      public static boolean isNStr(StringLiteral stringLiteral, IStringLiteralTypeComputer typeComputer)
      Checks if the string literal is nstr, using light-weght computing.
      Parameters:
      stringLiteral - the string literal, cannot be null
      typeComputer - the type computer, cannot be null
      Returns:
      true, if it is nstr