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

Examples of com.dci.intellij.dbn.language.common.element.impl.QualifiedIdentifierVariant


                        break;
                    }
                }
            }
            if (resultType != ParseResultType.NO_MATCH) {
                parseVariants.add(new QualifiedIdentifierVariant(elementTypes, resultType == ParseResultType.PARTIAL_MATCH));
            }
        }
        Collections.sort(parseVariants);
        return parseVariants;
    }
View Full Code Here


        TokenElementType separatorToken = getElementType().getSeparatorToken();

        PsiBuilder.Marker marker = builder.mark(node);
        int matchedTokens = 0;

        QualifiedIdentifierVariant variant = getMostProbableParseVariant(builder, node);
        if (variant != null) {
            LeafElementType[] elementTypes = variant.getLeafs();

            int currentSiblingPosition = 0;
            for (LeafElementType elementType : elementTypes) {
                ParseResult result = elementType.getParser().parse(node, true, depth + 1, context);
                if (result.isNoMatch()) breakelse matchedTokens = matchedTokens + result.getMatchedTokens();

                if (elementType != elementTypes[elementTypes.length -1])  {
                    result = separatorToken.getParser().parse(node, true, depth + 1, context);
                    if (result.isNoMatch()) break; else matchedTokens = matchedTokens + result.getMatchedTokens();
                }
                node.incrementIndex(builder.getCurrentOffset());
            }

            if (variant.isIncomplete()) {
                Set<TokenType> expected = new THashSet<TokenType>();
                expected.add(separatorToken.getTokenType());
                ParseBuilderErrorHandler.updateBuilderError(expected, context);
                return stepOut(marker, depth, ParseResultType.PARTIAL_MATCH, matchedTokens, node, context);
            } else {
View Full Code Here

            offset++;
            tokenType = builder.lookAhead(offset);
            if (tokenType == null && wasSeparator) chan.add(identifier);
        }

        QualifiedIdentifierVariant mostProbableVariant = null;

        for (LeafElementType[] elementTypes : getElementType().getVariants()) {
            if (elementTypes.length <= chan.size()) {
                int matchedTokens = 0;
                for (int i=0; i<elementTypes.length; i++) {
                    if (elementTypes[i].getTokenType().matches(chan.get(i))) {
                        matchedTokens++;
                    }
                }
                if (mostProbableVariant == null || mostProbableVariant.getMatchedTokens() < matchedTokens) {
                    mostProbableVariant = mostProbableVariant == null ?
                            new QualifiedIdentifierVariant(elementTypes, matchedTokens) :
                            mostProbableVariant.replace(elementTypes, matchedTokens);
                }

            }
        }
View Full Code Here

    private QualifiedIdentifierVariant getMostProbableParseVariant_(ParserBuilder builder, ParsePathNode node) {

        TokenElementType separatorToken = getElementType().getSeparatorToken();

        QualifiedIdentifierVariant mostProbableVariant = null;
        int initialSiblingIndex = node.getCurrentSiblingIndex();

        try {
            for (LeafElementType[] variants : getElementType().getVariants()) {
                int offset = 0;
                //PsiBuilder.Marker marker = builder.mark();
                int matchedTokens = 0;
                for (int i=0; i< variants.length; i++) {
                    TokenType tokenType = builder.lookAhead(offset);
                    // if no mach -> consider as partial if not first element

                    node.setCurrentSiblingIndex(i);
                    if (match(variants[i], tokenType, node, true)) {
                        matchedTokens++;
                        offset++;


                        tokenType = builder.lookAhead(offset);
                        boolean isSeparator = tokenType == separatorToken.getTokenType();
                        boolean isFullMatch = matchedTokens == variants.length;
                        boolean isLastElement = i == variants.length - 1;

                        if (isLastElement) {
                            QualifiedIdentifierVariant variant = new QualifiedIdentifierVariant(variants, matchedTokens);
                            if ((isFullMatch && !isSeparator) || variant.containsNonIdentifierTokens()) {
                                //markerRollbackTo(marker);
                                return variant;
                            }

                            if (mostProbableVariant == null || matchedTokens > mostProbableVariant.getMatchedTokens()) {
                                mostProbableVariant = variant;
                            }
                            break;
                        } else {
                            if (!isSeparator) {  // is not separator token
                                QualifiedIdentifierVariant variant = new QualifiedIdentifierVariant(variants, matchedTokens);
                                if (mostProbableVariant == null || mostProbableVariant.getMatchedTokens() < variant.getMatchedTokens()) {
                                    mostProbableVariant = variant;
                                }
                                break;
                            }
                        }
                        offset++;
                    } else {
                        if (matchedTokens > 0)  {
                            QualifiedIdentifierVariant variant = new QualifiedIdentifierVariant(variants, matchedTokens);
                            if (variant.containsNonIdentifierTokens()) {
                                //markerRollbackTo(marker);
                                return variant;
                            }
                            if (mostProbableVariant == null || mostProbableVariant.getMatchedTokens() < variant.getMatchedTokens()) {
                                mostProbableVariant = variant;
                            }
                        }
                        break;
                    }
View Full Code Here

TOP

Related Classes of com.dci.intellij.dbn.language.common.element.impl.QualifiedIdentifierVariant

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.