use of com.intellij.psi.tree.IElementType in project kotlin by JetBrains.
the class KtNamedFunction method getReceiverTypeRefByTree.
@Nullable
private KtTypeReference getReceiverTypeRefByTree() {
PsiElement child = getFirstChild();
while (child != null) {
IElementType tt = child.getNode().getElementType();
if (tt == KtTokens.LPAR || tt == KtTokens.COLON)
break;
if (child instanceof KtTypeReference) {
return (KtTypeReference) child;
}
child = child.getNextSibling();
}
return null;
}
use of com.intellij.psi.tree.IElementType in project kotlin by JetBrains.
the class KtStubElementType method createStubDependingOnParent.
private static boolean createStubDependingOnParent(ASTNode node) {
ASTNode parent = node.getTreeParent();
IElementType parentType = parent.getElementType();
if (parentType instanceof IStubElementType) {
return ((IStubElementType) parentType).shouldCreateStub(parent);
}
if (parentType instanceof IStubFileElementType) {
return true;
}
return false;
}
use of com.intellij.psi.tree.IElementType in project kotlin by JetBrains.
the class SemanticWhitespaceAwarePsiBuilderImpl method advanceLexer.
@Override
public void advanceLexer() {
if (!joinComplexTokens()) {
super.advanceLexer();
return;
}
IElementType tokenType = getTokenType();
if (complexTokens.contains(tokenType)) {
Marker mark = mark();
super.advanceLexer();
super.advanceLexer();
mark.collapse(tokenType);
} else {
super.advanceLexer();
}
}
use of com.intellij.psi.tree.IElementType in project kotlin by JetBrains.
the class SemanticWhitespaceAwarePsiBuilderImpl method newlineBeforeCurrentToken.
@Override
public boolean newlineBeforeCurrentToken() {
if (!newlinesEnabled.peek())
return false;
if (eof())
return true;
// TODO: maybe, memoize this somehow?
for (int i = 1; i <= getCurrentOffset(); i++) {
IElementType previousToken = rawLookup(-i);
if (previousToken == KtTokens.BLOCK_COMMENT || previousToken == KtTokens.DOC_COMMENT || previousToken == KtTokens.EOL_COMMENT || previousToken == SHEBANG_COMMENT) {
continue;
}
if (previousToken != TokenType.WHITE_SPACE) {
break;
}
int previousTokenStart = rawTokenTypeStart(-i);
int previousTokenEnd = rawTokenTypeStart(-i + 1);
assert previousTokenStart >= 0;
assert previousTokenEnd < getOriginalText().length();
for (int j = previousTokenStart; j < previousTokenEnd; j++) {
if (getOriginalText().charAt(j) == '\n') {
return true;
}
}
}
return false;
}
use of com.intellij.psi.tree.IElementType in project intellij-community by JetBrains.
the class GroovySmartCompletionContributor method inferDiamond.
@Nullable
private static PsiType inferDiamond(PsiElement place) {
if (!GroovyConfigUtils.getInstance().isVersionAtLeast(place, GroovyConfigUtils.GROOVY1_8)) {
return null;
}
final PsiElement parent = place.getParent().getParent();
if (!(parent instanceof GrNewExpression))
return null;
final PsiElement pparent = parent.getParent();
if (pparent instanceof GrVariable) {
return ((GrVariable) pparent).getDeclaredType();
} else if (pparent instanceof GrAssignmentExpression) {
GrAssignmentExpression assignment = (GrAssignmentExpression) pparent;
IElementType optoken = assignment.getOperationTokenType();
GrExpression lvalue = assignment.getLValue();
GrExpression rvalue = assignment.getRValue();
if (parent == rvalue && optoken == GroovyTokenTypes.mASSIGN) {
return lvalue.getNominalType();
}
} else if (pparent instanceof GrApplicationStatement) {
PsiElement ppparent = pparent.getParent();
if (ppparent instanceof GrAssignmentExpression) {
GrAssignmentExpression assignment = (GrAssignmentExpression) ppparent;
IElementType optoken = assignment.getOperationTokenType();
GrExpression lvalue = assignment.getLValue();
GrExpression rvalue = assignment.getRValue();
if (pparent == rvalue && optoken == GroovyTokenTypes.mASSIGN) {
return lvalue.getNominalType();
}
}
}
return null;
}
Aggregations