Package com.intellij.psi

Examples of com.intellij.psi.PsiElement


            variableDefinitions = scope.collectPsiElements(lookupAdapter, variableDefinitions, 0);

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

            PsiElement parent = scope.getParent();
            if (parent instanceof BasePsiElement) {
                BasePsiElement basePsiElement = (BasePsiElement) parent;
                scope = basePsiElement.lookupEnclosingPsiElement(ElementTypeAttribute.SCOPE_DEMARCATION);
                if (scope == null) scope = basePsiElement.lookupEnclosingPsiElement(ElementTypeAttribute.SCOPE_ISOLATION);
            } else {
View Full Code Here


        createFoldingDescriptors(node.getPsi(), document, foldingDescriptors, 0);
        return foldingDescriptors.toArray(new FoldingDescriptor[foldingDescriptors.size()]);
    }

    private void createFoldingDescriptors(PsiElement psiElement, Document document, List<FoldingDescriptor> foldingDescriptors, int nestingIndex) {
        PsiElement child = psiElement.getFirstChild();
        while (child != null) {
            if (child instanceof PsiComment) {
                String text = child.getText();
                if (text.startsWith("/*") && text.indexOf('\n') > -1) {
                    FoldingDescriptor foldingDescriptor = new FoldingDescriptor(
                            child.getNode(),
                            child.getTextRange());

                    foldingDescriptors.add(foldingDescriptor);
                }
            }
            if (child instanceof BasePsiElement) {
                BasePsiElement basePsiElement = (BasePsiElement) child;
                ElementType elementType = basePsiElement.getElementType();
                int blockEndOffset = basePsiElement.getTextOffset() + basePsiElement.getTextLength();

                boolean folded = false;

                if (elementType.is(ElementTypeAttribute.FOLDABLE_BLOCK)) {
                    BasePsiElement subjectPsiElement = basePsiElement.lookupFirstPsiElement(ElementTypeAttribute.SUBJECT);
                    if (subjectPsiElement == null) {
                        PsiElement firstChild = basePsiElement.getFirstChild();
                        if (firstChild instanceof TokenPsiElement) {
                            subjectPsiElement = (BasePsiElement) firstChild;
                        }
                    }
                    if (subjectPsiElement != null && subjectPsiElement.getParent() == basePsiElement) {
View Full Code Here

            child = child.getNextSibling();
        }
    }

    public String getPlaceholderText(@NotNull ASTNode node) {
        PsiElement psiElement = node.getPsi();
        if (psiElement instanceof BasePsiElement) {
            /*BasePsiElement basePsiElement = (BasePsiElement) psiElement;
            PsiElement subject = basePsiElement.lookupFirstSubjectPsiElement();
            StringBuilder buffer = new StringBuilder(basePsiElement.getElementType().getDescription());
            if (subject != null) {
View Full Code Here

        annotation.setTextAttributes(SQLTextAttributesKeys.ALIAS);*/
    }

    private void annotateObject(IdentifierPsiElement objectReference, AnnotationHolder holder) {
        if (!objectReference.isResolving() && !objectReference.isDefinition()) {
            PsiElement reference = objectReference.resolve();
            if (reference == null && checkConnection(objectReference)) {
                if (objectReference.getResolveTrialsCount() > 3) {
                    Annotation annotation = holder.createWarningAnnotation(objectReference.getNode(),
                            "Unknown identifier");
                    annotation.setTextAttributes(SQLTextAttributesKeys.UNKNOWN_IDENTIFIER);
View Full Code Here

    @NotNull
    public FoldingDescriptor[] buildFoldRegions(@NotNull ASTNode node, @NotNull Document document) {
        List<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();

        PsiElement child = node.getPsi().getFirstChild();
        while (child != null) {
            if (child instanceof RootPsiElement) {
                RootPsiElement rootPsiElement = (RootPsiElement) child;
                /*FoldingDescriptor rootFoldingDescriptor = new FoldingDescriptor(
                            rootPsiElement.getAstNode(),
                            rootPsiElement.getTextRange());
                foldingDescriptors.add(rootFoldingDescriptor);*/

                for (ExecutablePsiElement executablePsiElement : rootPsiElement.getExecutablePsiElements()) {
                    FoldingDescriptor foldingDescriptor = new FoldingDescriptor(
                            executablePsiElement.getNode(),
                            executablePsiElement.getTextRange());
                    descriptors.add(foldingDescriptor);
                }
            } else if (child instanceof ChameleonPsiElement) {
                ChameleonPsiElement chameleonPsiElement = (ChameleonPsiElement) child;
                FoldingDescriptor foldingDescriptor = new FoldingDescriptor(
                        chameleonPsiElement.getNode(),
                        chameleonPsiElement.getTextRange());
                descriptors.add(foldingDescriptor);


                FoldingBuilder foldingBuilder = LanguageFolding.INSTANCE.forLanguage(chameleonPsiElement.getLanguage());
                FoldingDescriptor[] nestedDescriptors = foldingBuilder.buildFoldRegions(chameleonPsiElement.getNode(), document);
                descriptors.addAll(Arrays.asList(nestedDescriptors));

            }
            child = child.getNextSibling();
        }
        return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
    }
View Full Code Here

        getChildren(psiElement, elements);
        return elements.toArray(new StructureViewTreeElement[elements.size()]);
    }

    private void getChildren(PsiElement parent, List<SQLStructureViewElement> elements) {
        PsiElement child = parent.getFirstChild();
        while (child != null) {
            if (child instanceof BasePsiElement) {
                BasePsiElement basePsiElement = (BasePsiElement) child;
                if (basePsiElement.getElementType().is(ElementTypeAttribute.STRUCTURE)) {
                    elements.add(new SQLStructureViewElement(child));
                } else {
                    getChildren(basePsiElement, elements);
                }
            }
            if (child instanceof ChameleonPsiElement) {
                elements.add(new SQLStructureViewElement(child));
            }
            child = child.getNextSibling();
        }
    }
View Full Code Here

    private void format(Document document, PsiElement psiElement, int startOffset, int endOffset){
        Language language = PsiUtil.getLanguage(psiElement);
        if (language instanceof DBLanguage) {
            CodeStyleCaseSettings styleCaseSettings = getCodeStyleCaseSettings((DBLanguage) language);
            PsiElement child = psiElement.getFirstChild();
            while (child != null) {
                if (child instanceof LeafPsiElement) {
                    TextRange textRange = child.getTextRange();
                    boolean isInRange =
                            startOffset == endOffset || (
                                    textRange.getStartOffset() >= startOffset &&
                                            textRange.getEndOffset() <= endOffset);
                    if (isInRange) {
                        CodeStyleCaseOption caseOption = null;
                        if (child instanceof IdentifierPsiElement) {
                            IdentifierPsiElement identifierPsiElement = (IdentifierPsiElement) child;
                            if (identifierPsiElement.isObject()) {
                                caseOption = styleCaseSettings.getObjectCaseOption();
                            }
                        }
                        else if (child instanceof TokenPsiElement) {
                            TokenPsiElement tokenPsiElement = (TokenPsiElement) child;
                            TokenType tokenType = tokenPsiElement.getElementType().getTokenType();
                            caseOption =
                                    tokenType.isKeyword() ? styleCaseSettings.getKeywordCaseOption() :
                                            tokenType.isFunction() ? styleCaseSettings.getFunctionCaseOption() :
                                                    tokenType.isParameter() ? styleCaseSettings.getParameterCaseOption() :
                                                            tokenType.isDataType() ? styleCaseSettings.getDatatypeCaseOption() : null;
                        }

                        if (caseOption != null) {
                            String text = child.getText();
                            String newText = caseOption.changeCase(text);

                            if (newText != null && !newText.equals(text))
                                document.replaceString(textRange.getStartOffset(), textRange.getEndOffset(), newText);

                        }
                    }
                } else {
                    format(document, child, startOffset, endOffset);
                }
                child = child.getNextSibling();
            }
        }
    }
View Full Code Here

        Annotation annotation = holder.createInfoAnnotation(aliasDefinition, null);
        annotation.setTextAttributes(SQLTextAttributesKeys.DATA_TYPE);*/
    }

    private void annotateObject(IdentifierPsiElement objectReference, AnnotationHolder holder) {
        PsiElement reference = objectReference.resolve();
        /*ConnectionHandler connectionHandler = objectReference.getActiveConnection();
        if (reference == null && connectionHandler != null && connectionHandler.getConnectionStatus().isValid()) {
            Annotation annotation = holder.createErrorAnnotation(objectReference.getAstNode(),
                    "Unknown " + objectReference.getObjectTypeName());
            annotation.setTextAttributes(PSQLTextAttributesKeys.UNKNOWN_IDENTIFIER);
View Full Code Here

            }
        }
    }

    public boolean contains(NamedPsiElement element, boolean leniant) {
        PsiElement child = getFirstChild();
        while (child != null) {
            if (child instanceof NamedPsiElement) {
                NamedPsiElement namedPsiElement = (NamedPsiElement) child;
                if (namedPsiElement == element) {
                    return true;
                }
            }
            child = child.getNextSibling();
        }
        if (leniant) {
            child = getFirstChild();
            while (child != null) {
                if (child instanceof NamedPsiElement) {
                    NamedPsiElement namedPsiElement = (NamedPsiElement) child;
                    if (namedPsiElement.matches(element)) {
                        return true;
                    }
                }
                child = child.getNextSibling();
            }
        }

        return false;
    }
View Full Code Here

        collectExecutablePsiElements(bucket, this);
        return bucket;
    }

    private void collectExecutablePsiElements(List<ExecutablePsiElement> bucket, PsiElement element) {
        PsiElement child = element.getFirstChild();
        while (child != null) {
            if (child instanceof ExecutablePsiElement) {
                ExecutablePsiElement executablePsiElement = (ExecutablePsiElement) child;
                bucket.add(executablePsiElement);
            } else {
                collectExecutablePsiElements(bucket, child);
            }
            child = child.getNextSibling();
        }
    }
View Full Code Here

TOP

Related Classes of com.intellij.psi.PsiElement

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.