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

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


    PsiResolveResult(IdentifierPsiElement element) {
        this.activeConnection = element.getActiveConnection();
        this.element = element;
        this.isNew = true;
        IdentifierElementType elementType = element.getElementType();
    }
View Full Code Here


        for (QualifiedIdentifierVariant parseVariant : qualifiedIdentifier.getParseVariants()) {
            LeafElementType parseVariantElementType = parseVariant.getLeaf(index);

            if (parseVariantElementType instanceof IdentifierElementType) {
                IdentifierElementType substitutionCandidate = (IdentifierElementType) parseVariantElementType;
                DBObjectType objectType = substitutionCandidate.getObjectType();

                if (parentObject == null) {  // index == 0
                    if (substitutionCandidate.isObject()) {
                        resolveWithScopeParentLookup(objectType, substitutionCandidate);
                    } else if (substitutionCandidate.isAlias()) {
                        PsiLookupAdapter lookupAdapter = new AliasDefinitionLookupAdapter(this, objectType, ref.getText());
                        BasePsiElement referencedElement = lookupAdapter.findInParentScopeOf(this);
                        if (referencedElement != this && isValidReference(referencedElement)) {
                            setElementType(parseVariantElementType);
                            ref.setReferencedElement(referencedElement);
                            ref.setParent(null);
                        }

                    } else if (substitutionCandidate.isVariable()) {
                        PsiLookupAdapter lookupAdapter = new VariableDefinitionLookupAdapter(this, DBObjectType.ANY, ref.getText());
                        BasePsiElement referencedElement = lookupAdapter.findInParentScopeOf(this);
                        if (referencedElement != this && isValidReference(referencedElement)) {
                            setElementType(parseVariantElementType);
                            ref.setReferencedElement(referencedElement);
                            ref.setParent(null);
                        }

                    }
                } else { // index > 0
                    IdentifierElementType parentElementType = (IdentifierElementType) parseVariant.getLeaf(index - 1);
                    if (parentObject.isOfType(parentElementType.getObjectType())) {
                        DBObject referencedElement = parentObject.getChildObject(objectType, ref.getText().toString(), false);
                        if (isValidReference(referencedElement)) {
                            setElementType(parseVariantElementType);
                            ref.setReferencedElement(referencedElement);
                            ref.setParent(parentObjectElement);
View Full Code Here

        return objectType.matches(type);
    }

    public boolean isSameAs(LeafElementType elementType) {
        if (elementType instanceof IdentifierElementType) {
            IdentifierElementType identifierElementType = (IdentifierElementType) elementType;
            return  identifierElementType.getObjectType() == objectType &&
                    identifierElementType.getIdentifierType() == identifierType &&
                    identifierElementType.getIdentifierCategory() == identifierCategory;
        }
        return false;
    }
View Full Code Here

            Element child = (Element) o;
            List<LeafElementType[]> childVariants = createVariants(child);
            for (LeafElementType[] childVariant : childVariants) {
                for (LeafElementType leafElementType : childVariant) {
                    if (leafElementType instanceof IdentifierElementType) {
                        IdentifierElementType identifierElementType = (IdentifierElementType) leafElementType;
                        objectTypeCache.add(identifierElementType.getObjectType());
                    }
                }
            }
            variants.addAll(childVariants);
        }
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

                if (filterSettings.acceptReservedWord(tokenElementType.getTokenTypeCategory())) {
                    consumer.consume(tokenElementType);
                }
            }
            else if (nextPossibleLeaf instanceof IdentifierElementType) {
                IdentifierElementType identifierElementType = (IdentifierElementType) nextPossibleLeaf;
                if (identifierElementType.isReference()) {
                    DBObjectType objectType = identifierElementType.getObjectType();
                    if (identifierElementType.isObject()) {
                        PsiLookupAdapter lookupAdapter = new ObjectDefinitionLookupAdapter(null, objectType,  null);
                        Set<BasePsiElement> objectDefinitions = lookupAdapter.collectInParentScopeOf(element);
                        if (objectDefinitions != null) {
                            for (BasePsiElement psiElement : objectDefinitions) {
                                if (psiElement instanceof IdentifierPsiElement) {
                                    IdentifierPsiElement identifierPsiElement = (IdentifierPsiElement) psiElement;
                                    PsiElement referencedPsiElement = identifierPsiElement.resolve();
                                    if (referencedPsiElement instanceof DBObject) {
                                        DBObject object = (DBObject) referencedPsiElement;
                                        LookupItemFactory lookupItemFactory = object.getLookupItemFactory(identifierElementType.getLanguage());
                                        lookupItemFactory.createLookupItem(object, consumer);
                                    }
                                }
                            }
                        }
                       
                        if (connectionHandler != null && !connectionHandler.isVirtual()) {
                            if (parentObject == null) {
                                BasePsiElement scope = element.getEnclosingScopePsiElement();
                                collectObjectMatchingScope(consumer, identifierElementType, filterSettings, scope, context);
                            } else {
                                for (DBObject object : parentObject.getChildObjects(identifierElementType.getObjectType())) {
                                    consumer.check();
                                    consumer.consume(object);
                                }
                            }
                        }

                    } else if (identifierElementType.isAlias()) {
                        PsiLookupAdapter lookupAdapter = new AliasDefinitionLookupAdapter(null, objectType,  null);
                        Set<BasePsiElement> aliasDefinitions = lookupAdapter.collectInParentScopeOf(element);
                        if (aliasDefinitions != null) {
                            for (PsiElement psiElement : aliasDefinitions) {
                                IdentifierPsiElement identifierPsiElement = (IdentifierPsiElement) psiElement;
                                AliasLookupItemFactory lookupItemFactory = new AliasLookupItemFactory(identifierPsiElement.getChars(), true);
                                lookupItemFactory.createLookupItem(identifierPsiElement, consumer);
                            }
                        }
                    } else if (identifierElementType.isVariable()) {
                        PsiLookupAdapter lookupAdapter = new VariableDefinitionLookupAdapter(null, objectType, null);
                        Set<BasePsiElement> aliasDefinitions = lookupAdapter.collectInParentScopeOf(element);
                        if (aliasDefinitions != null) {
                            for (BasePsiElement psiElement : aliasDefinitions) {
                                IdentifierPsiElement identifierPsiElement = (IdentifierPsiElement) psiElement;
                                VariableLookupItemFactory lookupItemFactory = new VariableLookupItemFactory(identifierPsiElement.getChars(), true);
                                lookupItemFactory.createLookupItem(identifierPsiElement, consumer);
                            }
                        }
                    }
                } else if (identifierElementType.isDefinition()) {
                    if (identifierElementType.isAlias()) {
                        String[] aliasNames = buildAliasDefinitionNames(element);
                        for (String aliasName : aliasNames) {
                            AliasLookupItemFactory lookupItemFactory = new AliasLookupItemFactory(aliasName, true);
                            lookupItemFactory.createLookupItem(aliasName, consumer);
                        }
View Full Code Here

                allPossibleTokens.add(leaf.getTokenType());
            }

            // register identifiers
            if (leaf instanceof IdentifierElementType) {
                IdentifierElementType identifierElementType = (IdentifierElementType) leaf;
                if (!containsIdentifier(identifierElementType)) {
                    addIdentifier(
                            identifierElementType.getObjectType(),
                            identifierElementType.getIdentifierType(),
                            identifierElementType.isReference() ? IdentifierCategory.REFERENCE : IdentifierCategory.DEFINITION);
                }

            }

        }
View Full Code Here

        if (elementType instanceof SequenceElementType) return "sequence";
        if (elementType instanceof IterationElementType) return "iteration";
        if (elementType instanceof QualifiedIdentifierElementType) return "qualified-identifier";
        if (elementType instanceof OneOfElementType) return "one-of";
        if (elementType instanceof IdentifierElementType) {
            IdentifierElementType iet = (IdentifierElementType) elementType;
            return  iet.getDebugName();
        }
        return null;
    }
View Full Code Here

        return identifierName == null || identifierPsiElement.textMatches(identifierName);

    }

    private boolean matchesRole(IdentifierPsiElement identifierPsiElement) {
        IdentifierElementType elementType = identifierPsiElement.getElementType();
        IdentifierCategory role = elementType.getIdentifierCategory();
        switch (identifierCategory) {
            case ALL: return true;
            case DEFINITION: return role == IdentifierCategory.DEFINITION || identifierPsiElement.isReferenceable();
            case REFERENCE: return role == IdentifierCategory.REFERENCE;
        }
View Full Code Here

    public String toString() {
        StringBuilder buffer = new StringBuilder();
        for (LeafElementType leaf : leafs) {
            if (leaf instanceof IdentifierElementType) {
                IdentifierElementType identifierElementType = (IdentifierElementType) leaf;
                buffer.append(identifierElementType.getObjectTypeName());
            } else if (leaf instanceof TokenElementType) {
                TokenElementType tokenElementType = (TokenElementType) leaf;
                buffer.append(tokenElementType.getTokenType().getValue());
            }
            if (leaf != leafs[leafs.length-1]) {
View Full Code Here

TOP

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

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.