Search in sources :

Example 41 with IElementType

use of com.intellij.psi.tree.IElementType in project intellij-community by JetBrains.

the class XmlElementDeclImpl method getChildRole.

@Override
public int getChildRole(ASTNode child) {
    LOG.assertTrue(child.getTreeParent() == this);
    IElementType i = child.getElementType();
    if (i == XML_NAME) {
        return XmlChildRole.XML_NAME;
    } else if (i == XML_ELEMENT_CONTENT_SPEC) {
        return XmlChildRole.XML_ELEMENT_CONTENT_SPEC;
    } else {
        return ChildRoleBase.NONE;
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType)

Example 42 with IElementType

use of com.intellij.psi.tree.IElementType in project intellij-community by JetBrains.

the class XmlDoctypeImpl method getChildRole.

@Override
public int getChildRole(ASTNode child) {
    LOG.assertTrue(child.getTreeParent() == this);
    IElementType i = child.getElementType();
    if (i == XmlTokenType.XML_DOCTYPE_PUBLIC) {
        return XmlChildRole.XML_DOCTYPE_PUBLIC;
    } else if (i == XmlTokenType.XML_DOCTYPE_SYSTEM) {
        return XmlChildRole.XML_DOCTYPE_SYSTEM;
    } else if (i == XmlTokenType.XML_NAME) {
        return XmlChildRole.XML_NAME;
    } else {
        return ChildRoleBase.NONE;
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType)

Example 43 with IElementType

use of com.intellij.psi.tree.IElementType in project intellij-community by JetBrains.

the class XmlElementContentSpecImpl method getChildRole.

@Override
public int getChildRole(ASTNode child) {
    LOG.assertTrue(child.getTreeParent() == this);
    IElementType i = child.getElementType();
    if (i == XML_CONTENT_ANY) {
        return XmlChildRole.XML_CONTENT_ANY;
    } else if (i == XML_CONTENT_EMPTY) {
        return XmlChildRole.XML_CONTENT_EMPTY;
    } else if (i == XML_PCDATA) {
        return XmlChildRole.XML_PCDATA;
    } else {
        return ChildRoleBase.NONE;
    }
}
Also used : IElementType(com.intellij.psi.tree.IElementType)

Example 44 with IElementType

use of com.intellij.psi.tree.IElementType in project intellij-community by JetBrains.

the class GroovyCompletionUtil method addRParenth.

public static int addRParenth(Editor editor, int oldTail, boolean space_within_cast_parentheses) {
    int offset = -1;
    final HighlighterIterator iterator = ((EditorEx) editor).getHighlighter().createIterator(oldTail);
    while (!iterator.atEnd()) {
        final IElementType tokenType = iterator.getTokenType();
        if (TokenSets.WHITE_SPACES_OR_COMMENTS.contains(tokenType)) {
            iterator.advance();
            continue;
        }
        if (tokenType == GroovyTokenTypes.mRPAREN) {
            offset = iterator.getEnd();
        }
        break;
    }
    if (offset != -1)
        return offset;
    offset = oldTail;
    if (space_within_cast_parentheses) {
        offset = TailType.insertChar(editor, oldTail, ' ');
    }
    return TailType.insertChar(editor, offset, ')');
}
Also used : IElementType(com.intellij.psi.tree.IElementType) HighlighterIterator(com.intellij.openapi.editor.highlighter.HighlighterIterator)

Example 45 with IElementType

use of com.intellij.psi.tree.IElementType in project intellij-community by JetBrains.

the class GroovyCompletionUtil method isWildcardCompletion.

/*
  we are here:  foo(List<? <caret> ...
   */
public static boolean isWildcardCompletion(PsiElement position) {
    PsiElement prev = PsiUtil.getPreviousNonWhitespaceToken(position);
    if (prev instanceof PsiErrorElement)
        prev = PsiUtil.getPreviousNonWhitespaceToken(prev);
    if (prev == null || prev.getNode().getElementType() != GroovyTokenTypes.mQUESTION)
        return false;
    final PsiElement pprev = PsiUtil.getPreviousNonWhitespaceToken(prev);
    if (pprev == null)
        return false;
    final IElementType t = pprev.getNode().getElementType();
    return t == GroovyTokenTypes.mLT || t == GroovyTokenTypes.mCOMMA;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) GroovyPsiElement(org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement) LeafPsiElement(com.intellij.psi.impl.source.tree.LeafPsiElement)

Aggregations

IElementType (com.intellij.psi.tree.IElementType)843 ASTNode (com.intellij.lang.ASTNode)127 PsiBuilder (com.intellij.lang.PsiBuilder)121 Nullable (org.jetbrains.annotations.Nullable)100 NotNull (org.jetbrains.annotations.NotNull)78 PsiElement (com.intellij.psi.PsiElement)77 TextRange (com.intellij.openapi.util.TextRange)43 HighlighterIterator (com.intellij.openapi.editor.highlighter.HighlighterIterator)26 ArrayList (java.util.ArrayList)22 GrExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression)22 Lexer (com.intellij.lexer.Lexer)17 GrBinaryExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression)15 NonNls (org.jetbrains.annotations.NonNls)14 Document (com.intellij.openapi.editor.Document)13 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)13 LighterASTNode (com.intellij.lang.LighterASTNode)12 BracePair (com.intellij.lang.BracePair)10 Project (com.intellij.openapi.project.Project)9 PsiFile (com.intellij.psi.PsiFile)9 IncorrectOperationException (com.intellij.util.IncorrectOperationException)9