mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Methods to find significant leaf elements in PyPsiUtil have consistent names
This commit is contained in:
@@ -75,7 +75,7 @@ public class PyPsiUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Find first non-whitespace sibling before given AST node.
|
||||
* Finds first non-whitespace sibling before given AST node.
|
||||
*/
|
||||
@Nullable
|
||||
public static ASTNode getPrevNonWhitespaceSibling(@NotNull ASTNode node) {
|
||||
@@ -83,7 +83,7 @@ public class PyPsiUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Find first sibling that is neither comment, nor whitespace before given element.
|
||||
* Finds first sibling that is neither comment, nor whitespace before given element.
|
||||
* @param strict prohibit returning element itself
|
||||
*/
|
||||
@Nullable
|
||||
@@ -112,7 +112,7 @@ public class PyPsiUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Find first non-whitespace sibling after given AST node.
|
||||
* Finds first non-whitespace sibling after given AST node.
|
||||
*/
|
||||
@Nullable
|
||||
public static ASTNode getNextNonWhitespaceSibling(@NotNull ASTNode after) {
|
||||
@@ -120,7 +120,7 @@ public class PyPsiUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Find first sibling that is neither comment, nor whitespace after given element.
|
||||
* Finds first sibling that is neither comment, nor whitespace after given element.
|
||||
* @param strict prohibit returning element itself
|
||||
*/
|
||||
@Nullable
|
||||
@@ -131,6 +131,30 @@ public class PyPsiUtils {
|
||||
return PsiTreeUtil.skipSiblingsForward(start, PsiWhiteSpace.class, PsiComment.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds first token after given element that doesn't consist solely of spaces and is not empty (e.g. error marker).
|
||||
* @param ignoreComments ignore commentaries as well
|
||||
*/
|
||||
@Nullable
|
||||
public static PsiElement getNextSignificantLeaf(@Nullable PsiElement element, boolean ignoreComments) {
|
||||
while (element != null && StringUtil.isEmptyOrSpaces(element.getText()) || ignoreComments && element instanceof PsiComment) {
|
||||
element = PsiTreeUtil.nextLeaf(element);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds first token before given element that doesn't consist solely of spaces and is not empty (e.g. error marker).
|
||||
* @param ignoreComments ignore commentaries as well
|
||||
*/
|
||||
@Nullable
|
||||
public static PsiElement getPrevSignificantLeaf(@Nullable PsiElement element, boolean ignoreComments) {
|
||||
while (element != null && StringUtil.isEmptyOrSpaces(element.getText()) || ignoreComments && element instanceof PsiComment) {
|
||||
element = PsiTreeUtil.prevLeaf(element);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the closest comma looking for the next comma first and then for the preceding one.
|
||||
*/
|
||||
@@ -436,22 +460,6 @@ public class PyPsiUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement getSignificantToTheRight(PsiElement element, final boolean ignoreComments) {
|
||||
while (element != null && StringUtil.isEmptyOrSpaces(element.getText()) || ignoreComments && element instanceof PsiComment) {
|
||||
element = PsiTreeUtil.nextLeaf(element);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiElement getSignificantToTheLeft(PsiElement element, final boolean ignoreComments) {
|
||||
while (element != null && StringUtil.isEmptyOrSpaces(element.getText()) || ignoreComments && element instanceof PsiComment) {
|
||||
element = PsiTreeUtil.prevLeaf(element);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public static int findArgumentIndex(PyCallExpression call, PsiElement argument) {
|
||||
final PyExpression[] args = call.getArguments();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user