public class PsiLiteralUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
_2_IN_31 |
static java.lang.String |
_2_IN_63 |
static java.lang.String |
BIN_PREFIX |
static java.lang.String |
HEX_PREFIX |
Constructor and Description |
---|
PsiLiteralUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
escapeBackSlashesInTextBlock(java.lang.String str)
Escapes backslashes in a text block (even if they're represented as an escape sequence).
|
static java.lang.String |
escapeTextBlockCharacters(java.lang.String s)
Converts given string to text block content.
|
static java.lang.String |
escapeTextBlockCharacters(java.lang.String s,
boolean escapeStartQuote,
boolean escapeEndQuote,
boolean escapeSpacesInTheEnd)
Converts given string to text block content.
|
static int |
getTextBlockIndent(java.lang.String [] lines)
Determines how many whitespaces would be excluded at the beginning of each line of text block content.
|
static int |
getTextBlockIndent(java.lang.String [] lines,
boolean preserveContent,
boolean ignoreLastLine) |
static boolean |
isUnsafeLiteral(PsiLiteralExpression expression)
Returns true if given literal expression is invalid and reusing its text representation
in refactorings/quick-fixes may result in parse errors.
|
static TextRange |
mapBackStringRange(java.lang.String text,
int from,
int to)
Maps the substring range inside Java String literal value back into the source code range.
|
static TextRange |
mapBackTextBlockRange(java.lang.String text,
int from,
int to,
int indent)
Maps the substring range inside Java Text Block literal value back into the source code range.
|
static int |
parseBackSlash(java.lang.String str,
int idx)
Parse backslash at given index.
|
static long |
parseDigits(java.lang.String text,
int bitsInRadix,
int maxBits) |
static java.lang.Double |
parseDouble(java.lang.String text) |
static java.lang.Float |
parseFloat(java.lang.String text) |
static java.lang.Integer |
parseInteger(java.lang.String text) |
static java.lang.Integer |
parseIntegerNoPrefix(java.lang.String text) |
static java.lang.Long |
parseLong(java.lang.String text) |
static java.lang.String |
stringForCharLiteral(java.lang.String charLiteral)
Converts passed character literal (like 'a') to string literal (like "a").
|
public static final java.lang.String HEX_PREFIX
public static final java.lang.String BIN_PREFIX
public static final java.lang.String _2_IN_31
public static final java.lang.String _2_IN_63
public static java.lang.Integer parseInteger(java.lang.String text)
public static java.lang.Integer parseIntegerNoPrefix(java.lang.String text)
public static java.lang.Long parseLong(java.lang.String text)
public static java.lang.Float parseFloat(java.lang.String text)
public static java.lang.Double parseDouble(java.lang.String text)
public static long parseDigits(java.lang.String text, int bitsInRadix, int maxBits) throws java.lang.NumberFormatException
java.lang.NumberFormatException
public static java.lang.String stringForCharLiteral(java.lang.String charLiteral)
charLiteral
- character literal to convert.public static boolean isUnsafeLiteral(PsiLiteralExpression expression)
expression
- a literal expression to checkpublic static java.lang.String escapeTextBlockCharacters(java.lang.String s)
s
- original textescapeTextBlockCharacters(String, boolean, boolean, boolean)
public static java.lang.String escapeTextBlockCharacters(java.lang.String s, boolean escapeStartQuote, boolean escapeEndQuote, boolean escapeSpacesInTheEnd)
During conversion:
s
- original textescapeStartQuote
- true if first quote should be escaped (e.g. when copy-pasting into text block after two quotes)escapeEndQuote
- true if last quote should be escaped (e.g. inserting text into text block before closing quotes)escapeSpacesInTheEnd
- true if spaces in the end of the line should be preserved even if no new line in the end is presentpublic static java.lang.String escapeBackSlashesInTextBlock(java.lang.String str)
public static int parseBackSlash(java.lang.String str, int idx)
str
- textidx
- parse frompublic static int getTextBlockIndent(java.lang.String [] lines)
lines
- text block contentpublic static int getTextBlockIndent(java.lang.String [] lines, boolean preserveContent, boolean ignoreLastLine)
getTextBlockIndent(String[])
public static TextRange mapBackStringRange(java.lang.String text, int from, int to)
text
- string literal as present in source code (including quotes)from
- start offset inside the represented stringto
- end offset inside the represented stringpublic static TextRange mapBackTextBlockRange(java.lang.String text, int from, int to, int indent)
indent
- text block indent