Examples of PsiLookupAdapter


Examples of com.dci.intellij.dbn.language.common.psi.lookup.PsiLookupAdapter

    public BasePsiElement lookupObjectSpecification(DBObjectType objectType, CharSequence objectName) {
        for (PsiElement psiElement : getChildren()) {
            if (psiElement instanceof BasePsiElement) {
                BasePsiElement basePsiElement = (BasePsiElement) psiElement;
                PsiLookupAdapter lookupAdapter = new ObjectDefinitionLookupAdapter(null, objectType, objectName, ElementTypeAttribute.SUBJECT);
                BasePsiElement specObject = lookupAdapter.findInScope(basePsiElement);
                if (specObject != null) {
                    return specObject.lookupEnclosingPsiElement(ElementTypeAttribute.OBJECT_SPECIFICATION);
                }
            }
        }
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.lookup.PsiLookupAdapter

    public BasePsiElement lookupObjectDeclaration(DBObjectType objectType, CharSequence objectName) {
        for (PsiElement psiElement : getChildren()) {
            if (psiElement instanceof BasePsiElement) {
                BasePsiElement basePsiElement = (BasePsiElement) psiElement;
                PsiLookupAdapter lookupAdapter = new ObjectDefinitionLookupAdapter(null, objectType, objectName, ElementTypeAttribute.SUBJECT);
                BasePsiElement specObject = lookupAdapter.findInScope(basePsiElement);
                if (specObject != null) {
                    return specObject.lookupEnclosingPsiElement(ElementTypeAttribute.OBJECT_DECLARATION);
                }
            }
        }
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.lookup.PsiLookupAdapter

    public Set<BasePsiElement> lookupVariableDefinition(int offset) {
        BasePsiElement scope = PsiUtil.lookupElementAtOffset(this, ElementTypeAttribute.SCOPE_DEMARCATION, offset);
        Set<BasePsiElement> variableDefinitions = new THashSet<BasePsiElement>();
        while (scope != null) {
            PsiLookupAdapter lookupAdapter = new IdentifierDefinitionLookupAdapter(null, DBObjectType.ARGUMENT, null);
            variableDefinitions = scope.collectPsiElements(lookupAdapter, variableDefinitions, 0);

            lookupAdapter = new VariableDefinitionLookupAdapter(null, DBObjectType.ANY, null);
            variableDefinitions = scope.collectPsiElements(lookupAdapter, variableDefinitions, 0);
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.lookup.PsiLookupAdapter

                }
            }

            Set<BasePsiElement> parentObjectPsiElements = null;
            for (DBObjectType parentObjectType : parentTypes) {
                PsiLookupAdapter lookupAdapter = new ObjectDefinitionLookupAdapter(lookupIssuer, parentObjectType, null);
                parentObjectPsiElements = !objectType.isSchemaObject() && parentObjectType.isSchemaObject() ?
                        lookupAdapter.collectInScope(sourceScope, parentObjectPsiElements) :
                        lookupAdapter.collectInParentScopeOf(sourceScope, parentObjectPsiElements);
            }

            if (parentObjectPsiElements != null) {
                for (BasePsiElement parentObjectPsiElement : parentObjectPsiElements) {
                    if (!parentObjectPsiElement.containsPsiElement(sourceScope)) {
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.lookup.PsiLookupAdapter

            if (isDefinition()) {
                aliasDefinition = this;
            } else {
                BasePsiElement resolveScope = getEnclosingScopePsiElement();

                PsiLookupAdapter lookupAdapter = new AliasDefinitionLookupAdapter(this, getObjectType(), getUnquotedText());
                aliasDefinition = lookupAdapter.findInScope(resolveScope);
            }

            if (aliasDefinition != null && aliasDefinition instanceof IdentifierPsiElement) {
                BasePsiElement aliasedObject = PsiUtil.resolveAliasedEntityElement((IdentifierPsiElement) aliasDefinition);
                if (aliasedObject != null) {
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.lookup.PsiLookupAdapter

     *******************************************************/

    private Object[] buildAliasRefVariants() {
        SequencePsiElement statement = (SequencePsiElement) lookupEnclosingPsiElement(ElementTypeAttribute.STATEMENT);
        BasePsiElement sourceScope = getEnclosingScopePsiElement();
        PsiLookupAdapter lookupAdapter = new AliasDefinitionLookupAdapter(this, getObjectType(), null);
        Set<BasePsiElement> aliasDefinitions = lookupAdapter.collectInScope(statement, null);
        return aliasDefinitions == null ? new Object[0] : aliasDefinitions.toArray();
    }
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.lookup.PsiLookupAdapter

                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);
                        }
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.lookup.PsiLookupAdapter

                        return;
                    }
                }
            }
            if (!substitutionCandidate.isDefinition()){
                PsiLookupAdapter lookupAdapter = new ObjectDefinitionLookupAdapter(this, objectType, ref.getText());
                PsiElement referencedElement = lookupAdapter.findInParentScopeOf(this);
                if (referencedElement != this && isValidReference(referencedElement)) {
                    ref.setParent(null);
                    ref.setReferencedElement(referencedElement);
                    setElementType(substitutionCandidate);
                    return;
                }
            }
        } else if (substitutionCandidate.isAlias()) {
            PsiLookupAdapter lookupAdapter = new AliasDefinitionLookupAdapter(this, objectType, ref.getText());
            BasePsiElement referencedElement = lookupAdapter.findInParentScopeOf(this);
            if (referencedElement != null && referencedElement != this) {
                ref.setParent(null);
                ref.setReferencedElement(referencedElement);
            }
        } else if (substitutionCandidate.isVariable()) {
            PsiLookupAdapter lookupAdapter = new VariableDefinitionLookupAdapter(this, DBObjectType.ANY, ref.getText());
            BasePsiElement referencedElement = lookupAdapter.findInParentScopeOf(this);
            if (referencedElement != null && referencedElement != this) {
                ref.setParent(null);
                ref.setReferencedElement(referencedElement);
            }
        }
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.lookup.PsiLookupAdapter

            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);
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.lookup.PsiLookupAdapter

            BasePsiElement scope = aliasElement.getEnclosingScopePsiElement();

            for (int i = 0; i< aliasNames.length; i++) {
                while (true) {
                    PsiLookupAdapter lookupAdapter = new AliasDefinitionLookupAdapter(null, DBObjectType.ANY, aliasNames[i]);
                    boolean isExisting = lookupAdapter.findInScope(scope) != null;
                    boolean isKeyword = aliasElement.getLanguageDialect().isReservedWord(aliasNames[i]);
                    if (isKeyword || isExisting) {
                        aliasNames[i] = NamingUtil.getNextNumberedName(aliasNames[i], false);
                    } else {
                        break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.