Package com.dci.intellij.dbn.language.common.element

Examples of com.dci.intellij.dbn.language.common.element.TokenElementType


        if (object instanceof DBObject) {
            DBObject dbObject = (DBObject) object;
            lookupItemFactory = dbObject.getLookupItemFactory(context.getLanguage());

        } else if (object instanceof TokenElementType) {
            TokenElementType tokenElementType = (TokenElementType) object;
            lookupItemFactory = tokenElementType.getLookupItemFactory(context.getLanguage());
        }

        if (lookupItemFactory != null) {
            lookupItemFactory.createLookupItem(object, this);
        }
View Full Code Here


        BasePsiElement parentPsiElement = getParentPsiElement(psiElement);
        IterationElementType iterationElementType = (IterationElementType) parentPsiElement.getElementType();
        ElementType elementType = psiElement.getElementType();

        if (elementType instanceof TokenElementType) {
            TokenElementType tokenElementType = (TokenElementType) elementType;
            if (iterationElementType.isSeparator(tokenElementType)) {
                return tokenElementType.isCharacter() ?
                        SPACING_NO_SPACE :
                        SPACING_ONE_SPACE;
            }
        }
        return null;
View Full Code Here

            if (leafBeforeCaret == null) {
                ElementTypeBundle elementTypeBundle = file.getElementTypeBundle();
                Set<LeafElementType> firstPossibleLeafs = elementTypeBundle.getRootElementType().getLookupCache().getFirstPossibleLeafs();
                for (LeafElementType firstPossibleLeaf : firstPossibleLeafs) {
                    if (firstPossibleLeaf instanceof TokenElementType) {
                        TokenElementType tokenElementType = (TokenElementType) firstPossibleLeaf;
                        if (context.getCodeCompletionFilterSettings().acceptReservedWord(tokenElementType.getTokenTypeCategory())) {
                            LookupItemFactory lookupItemFactory = tokenElementType.getLookupItemFactory(language);
                            lookupItemFactory.createLookupItem(tokenElementType, consumer);
                        }
                    }
                }
            } else {
View Full Code Here

        }
    }

    private String getLeafUniqueKey(LeafElementType leaf) {
        if (leaf instanceof TokenElementType) {
            TokenElementType tokenElementType = (TokenElementType) leaf;
            return tokenElementType.getTokenType().getId();
        } else if (leaf instanceof IdentifierElementType){
            IdentifierElementType identifierElementType = (IdentifierElementType) leaf;
            return identifierElementType.getQualifiedObjectTypeName();
        }
        return null;
View Full Code Here

            //        nextPossibleLeaf.getLookupCache().getNextRequiredTokens().contains(
            //                element.getLanguage().getSharedTokenTypes().getLeftParenthesis());
            //consumer.setAddParenthesis(addParenthesis);

            if (nextPossibleLeaf instanceof TokenElementType) {
                TokenElementType tokenElementType = (TokenElementType) nextPossibleLeaf;
                //consumer.setAddParenthesis(addParenthesis && tokenType.isFunction());
                if (filterSettings.acceptReservedWord(tokenElementType.getTokenTypeCategory())) {
                    consumer.consume(tokenElementType);
                }
            }
            else if (nextPossibleLeaf instanceof IdentifierElementType) {
                IdentifierElementType identifierElementType = (IdentifierElementType) nextPossibleLeaf;
View Full Code Here

    }

    protected Wrap getWrap(ElementType elementType, IterationElementType iterationElementType, boolean shouldWrap) {
        if (shouldWrap) {
            if (elementType instanceof TokenElementType) {
                TokenElementType tokenElementType = (TokenElementType) elementType;
                return iterationElementType.isSeparator(tokenElementType) ? null : WRAP_ALWAYS;
            } else {
                return WRAP_ALWAYS;
            }
View Full Code Here

        }
    }

    protected Spacing getSpacing(IterationElementType iterationElementType, ElementType elementType, boolean shouldWrap) {
        if (elementType instanceof TokenElementType) {
            TokenElementType tokenElementType = (TokenElementType) elementType;
            if (iterationElementType.isSeparator(tokenElementType)) {
                return  tokenElementType.isCharacter() ?
                            SPACING_NO_SPACE :
                            SPACING_ONE_SPACE;
            }
        }
        return shouldWrap ? SPACING_LINE_BREAK : SPACING_ONE_SPACE;
View Full Code Here

        BasePsiElement parentPsiElement = getParentPsiElement(psiElement);
        IterationElementType iterationElementType = (IterationElementType) parentPsiElement.getElementType();
        ElementType elementType = psiElement.getElementType();

        if (elementType instanceof TokenElementType) {
            TokenElementType tokenElementType = (TokenElementType) elementType;
            if (iterationElementType.isSeparator(tokenElementType)) {
                return tokenElementType.isCharacter() ?
                        SPACING_NO_SPACE :
                        SPACING_ONE_SPACE;
            }
        }
        return SPACING_ONE_SPACE;
View Full Code Here

    public void handleInsert(InsertionContext insertionContext, DBLookupItem lookupElement) {
        char completionChar = insertionContext.getCompletionChar();

        Object lookupElementObject = lookupElement.getObject();
        if (lookupElementObject instanceof TokenElementType) {
            TokenElementType tokenElementType = (TokenElementType) lookupElementObject;
            if(tokenElementType.getTokenType().isReservedWord()) {
                Editor editor = insertionContext.getEditor();
                CaretModel caretModel = editor.getCaretModel();

                LeafPsiElement leafPsiElement = PsiUtil.lookupLeafAtOffset(insertionContext.getFile(), insertionContext.getTailOffset());
                if (leafPsiElement == null || leafPsiElement.getTextOffset() != caretModel.getOffset()) {
View Full Code Here

        loadWrappingAttributes(def);
    }

    private void loadWrappingAttributes(Element def) throws ElementTypeDefinitionException {
        String templateId = def.getAttributeValue("wrapping-template");
        TokenElementType beginTokenElement = null;
        TokenElementType endTokenElement = null;
        if (StringUtil.isEmpty(templateId)) {
            String beginTokenId = def.getAttributeValue("wrapping-begin-token");
            String endTokenId = def.getAttributeValue("wrapping-end-token");

            if (StringUtil.isNotEmpty(beginTokenId) && StringUtil.isNotEmpty(endTokenId)) {
                beginTokenElement = new TokenElementTypeImpl(bundle, this, beginTokenId, getId());
                endTokenElement = new TokenElementTypeImpl(bundle, this, endTokenId, getId());
            }
        } else {
            WrapperElementTypeTemplate template = WrapperElementTypeTemplate.valueOf(templateId);
            String beginTokenId = template.getBeginToken();
            String endTokenId = template.getEndToken();
            beginTokenElement = new TokenElementTypeImpl(bundle, this, beginTokenId, getId());
            endTokenElement = new TokenElementTypeImpl(bundle, this, endTokenId, getId());

            if (template.isBlock()) {
                beginTokenElement.setDefaultFormatting(FormattingDefinition.LINE_BREAK_AFTER);
                endTokenElement.setDefaultFormatting(FormattingDefinition.LINE_BREAK_BEFORE);
                setDefaultFormatting(FormattingDefinition.LINE_BREAK_BEFORE);
            }
        }

        if (beginTokenElement != null && endTokenElement != null) {
View Full Code Here

TOP

Related Classes of com.dci.intellij.dbn.language.common.element.TokenElementType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.