use of com.intellij.lang.ASTNode in project intellij-community by JetBrains.
the class PyStringLiteralExpressionImpl method getStringValueTextRanges.
@NotNull
public List<TextRange> getStringValueTextRanges() {
if (valueTextRanges == null) {
int elStart = getTextRange().getStartOffset();
List<TextRange> ranges = new ArrayList<>();
for (ASTNode node : getStringNodes()) {
TextRange range = getNodeTextRange(node.getText());
int nodeOffset = node.getStartOffset() - elStart;
ranges.add(TextRange.from(nodeOffset + range.getStartOffset(), range.getLength()));
}
valueTextRanges = Collections.unmodifiableList(ranges);
}
return valueTextRanges;
}
use of com.intellij.lang.ASTNode in project intellij-community by JetBrains.
the class PyBinaryExpressionImpl method isOperator.
public boolean isOperator(String chars) {
ASTNode child = getNode().getFirstChildNode();
StringBuilder buf = new StringBuilder();
while (child != null) {
IElementType elType = child.getElementType();
if (elType instanceof PyElementType && PyElementTypes.BINARY_OPS.contains(elType)) {
buf.append(child.getText());
}
child = child.getTreeNext();
}
return buf.toString().equals(chars);
}
use of com.intellij.lang.ASTNode in project intellij-community by JetBrains.
the class PyTargetExpressionImpl method getName.
@Nullable
@Override
public String getName() {
final PyTargetExpressionStub stub = getStub();
if (stub != null) {
return stub.getName();
}
ASTNode node = getNameElement();
return node != null ? node.getText() : null;
}
use of com.intellij.lang.ASTNode in project intellij-community by JetBrains.
the class PyDecoratorImpl method isBuiltin.
public boolean isBuiltin() {
ASTNode node = getNode().findChildByType(PythonDialectsTokenSetProvider.INSTANCE.getReferenceExpressionTokens());
if (node != null) {
PyReferenceExpression ref = (PyReferenceExpression) node.getPsi();
PsiElement target = ref.getReference().resolve();
return PyBuiltinCache.getInstance(this).isBuiltin(target);
}
return false;
}
use of com.intellij.lang.ASTNode in project intellij-community by JetBrains.
the class PyDecoratorImpl method setName.
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
final ASTNode node = getNode();
final ASTNode nameNode = node.findChildByType(PyTokenTypes.IDENTIFIER);
if (nameNode != null) {
final ASTNode nameElement = PyUtil.createNewName(this, name);
node.replaceChild(nameNode, nameElement);
return this;
} else {
throw new IncorrectOperationException("No name node");
}
}
Aggregations