Examples of BasePsiElement


Examples of com.dci.intellij.dbn.language.common.psi.BasePsiElement

public class PSQLLanguageAnnotator implements Annotator {

    public void annotate(@NotNull final PsiElement psiElement, @NotNull final AnnotationHolder holder) {
        if (psiElement instanceof BasePsiElement) {
            BasePsiElement basePsiElement = (BasePsiElement) psiElement;
            ElementType elementType = basePsiElement.getElementType();
            if (elementType.is(ElementTypeAttribute.OBJECT_SPECIFICATION) || elementType.is(ElementTypeAttribute.OBJECT_DECLARATION)) {
                annotateSpecDeclarationNavigable(basePsiElement, holder);
            }

        }
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.BasePsiElement

            annotation.setTextAttributes(PSQLTextAttributesKeys.UNKNOWN_IDENTIFIER);
        }*/
    }

    private void annotateSpecDeclarationNavigable(BasePsiElement basePsiElement, AnnotationHolder holder) {
        BasePsiElement subjectPsiElement = basePsiElement.lookupFirstPsiElement(ElementTypeAttribute.SUBJECT);
        if (subjectPsiElement instanceof IdentifierPsiElement) {
            IdentifierPsiElement identifierPsiElement = (IdentifierPsiElement) subjectPsiElement;
            DBObjectType objectType = identifierPsiElement.getObjectType();
            ElementType elementType = basePsiElement.getElementType();

            if (identifierPsiElement.isObject() && objectType.getGenericType() == DBObjectType.METHOD) {

                DBContentType targetContentType =
                        elementType.is(ElementTypeAttribute.OBJECT_DECLARATION) ? DBContentType.CODE_SPEC :
                        elementType.is(ElementTypeAttribute.OBJECT_SPECIFICATION) ? DBContentType.CODE_BODY : null;

                if (targetContentType != null && identifierPsiElement.getFile() instanceof PSQLFile) {
                    PSQLFile file = (PSQLFile) identifierPsiElement.getFile();
                    DBSchemaObject object = (DBSchemaObject) file.getUnderlyingObject();
                    VirtualFile virtualFile = file.getVirtualFile();

                    if (object == null || virtualFile.isInLocalFileSystem()) {
                        ElementTypeAttribute targetAttribute =
                                elementType.is(ElementTypeAttribute.OBJECT_DECLARATION) ? ElementTypeAttribute.OBJECT_SPECIFICATION :
                                elementType.is(ElementTypeAttribute.OBJECT_SPECIFICATION) ? ElementTypeAttribute.OBJECT_DECLARATION : null;

                        if (targetAttribute != null) {
                            BasePsiElement rootPsiElement = identifierPsiElement.lookupEnclosingPsiElement(ElementTypeAttribute.ROOT);

                            BasePsiElement targetElement = rootPsiElement == null ? null :
                                    rootPsiElement.lookupPsiElementBySubject(targetAttribute,
                                                identifierPsiElement.getChars(),
                                                identifierPsiElement.getObjectType());

                            if (targetElement != null) {
                                NavigationAction navigationAction = targetContentType == DBContentType.CODE_BODY ?
                                        new NavigateToDefinitionAction(null, targetElement, objectType) :
                                        new NavigateToSpecificationAction(null, targetElement, objectType);
                                Annotation annotation = holder.createInfoAnnotation(basePsiElement, null);
                                NavigationGutterRenderer gutterIconRenderer = new NavigationGutterRenderer(navigationAction, GutterIconRenderer.Alignment.RIGHT);
                                annotation.setGutterIconRenderer(gutterIconRenderer);
                            }
                            NavigateToObjectAction navigateToObjectAction = new NavigateToObjectAction(identifierPsiElement.resolveUnderlyingObject(), objectType);
                            Annotation annotation = holder.createInfoAnnotation(basePsiElement, null);
                            annotation.setGutterIconRenderer(new NavigationGutterRenderer(navigateToObjectAction, GutterIconRenderer.Alignment.LEFT));


                        }
                    } else if (object.getContentType() == DBContentType.CODE_SPEC_AND_BODY) {
                        SourceCodeManager codeEditorManager = SourceCodeManager.getInstance(object.getProject());


                        BasePsiElement targetElement = codeEditorManager.getObjectNavigationElement(object, targetContentType, identifierPsiElement.getObjectType(), identifierPsiElement.getChars());
                        if (targetElement != null) {
                            NavigationAction navigationAction = targetContentType == DBContentType.CODE_BODY ?
                                    new NavigateToDefinitionAction(object, targetElement, objectType) :
                                    new NavigateToSpecificationAction(object, targetElement, objectType);
                            Annotation annotation = holder.createInfoAnnotation(basePsiElement, null);
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.BasePsiElement

    public IterationChopDownIfLongStatementPreset() {
        super("chop_down_if_statement_long", "Chop down if statement long");
    }

    public Wrap getWrap(BasePsiElement psiElement, CodeStyleSettings settings) {
        BasePsiElement parentPsiElement = getParentPsiElement(psiElement);
        IterationElementType iterationElementType = (IterationElementType) parentPsiElement.getElementType();
        ElementType elementType = psiElement.getElementType();

        NamedPsiElement namedPsiElement = (NamedPsiElement) parentPsiElement.lookupEnclosingPsiElement(ElementTypeAttribute.EXECUTABLE);
        boolean shouldWrap = namedPsiElement.approximateLength() > settings.RIGHT_MARGIN;
        return getWrap(elementType, iterationElementType, shouldWrap);
    }
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.BasePsiElement

        boolean shouldWrap = namedPsiElement.approximateLength() > settings.RIGHT_MARGIN;
        return getWrap(elementType, iterationElementType, shouldWrap);
    }

    public Spacing getSpacing(BasePsiElement psiElement, CodeStyleSettings settings) {
        BasePsiElement parentPsiElement = getParentPsiElement(psiElement);
        IterationElementType iterationElementType = (IterationElementType) parentPsiElement.getElementType();
        ElementType elementType = psiElement.getElementType();

        NamedPsiElement namedPsiElement = (NamedPsiElement) parentPsiElement.lookupEnclosingPsiElement(ElementTypeAttribute.EXECUTABLE);
        boolean shouldWrap = namedPsiElement.approximateLength() > settings.RIGHT_MARGIN;
        return getSpacing(iterationElementType, elementType, shouldWrap);
    }
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.BasePsiElement

    public Wrap getWrap(BasePsiElement psiElement, CodeStyleSettings settings) {
        return null;
    }

    public Spacing getSpacing(BasePsiElement psiElement, CodeStyleSettings settings) {
        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)) {
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.BasePsiElement

        this.codeStyleCustomSettings = codeStyleCustomSettings;
    }

    private FormattingAttributes getFormattingAttributes() {
        if (psiElement instanceof BasePsiElement) {
            BasePsiElement basePsiElement = (BasePsiElement) psiElement;
            return basePsiElement.getFormattingAttributes();
        }
        return null;
    }
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.BasePsiElement

        }

        Indent indent = getIndentAttribute();
        if (indent == null) {
            if (psiElement instanceof BasePsiElement) {
                BasePsiElement basePsiElement = (BasePsiElement) psiElement;
                BasePsiElement parentPsiElement = getParentPsiElement(basePsiElement);
                if (parentPsiElement != null && parentPsiElement.getElementType() instanceof WrapperElementType) {
                    WrapperElementType wrapperElementType = (WrapperElementType) parentPsiElement.getElementType();
                    SharedTokenTypeBundle sharedTokenTypes = parentPsiElement.getLanguage().getSharedTokenTypes();
                    if (wrapperElementType.getBeginTokenElement().getTokenType() == sharedTokenTypes.getLeftParenthesis()) {
                        //FormattingBlock parentStatementBlock = getParentBlock(this, ElementTypeAttribute.STATEMENT);
                        //Indent parentStatementIndent = parentStatementBlock.getIndent();
                        //return Indent.getIndent(Indent.Type.SPACES, -1, false, false);
                        return Indent.getNoneIndent();
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.BasePsiElement

    public String getSignature(@NotNull PsiElement psiElement) {
        if (psiElement.getContainingFile() instanceof DBLanguageFile) {
            TextRange textRange = psiElement.getTextRange();
            String offsets = textRange.getStartOffset() + "#" + textRange.getEndOffset();
            if (psiElement instanceof BasePsiElement) {
                BasePsiElement basePsiElement = (BasePsiElement) psiElement;
                return basePsiElement.getElementType().getId() + "#" + offsets;
            }

            if (psiElement instanceof PsiComment) {
                return "comment#" + offsets;
            }
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.BasePsiElement

                int elementEndOffset = elementStartOffset + psiElement.getTextLength();
                if (elementStartOffset < startOffset || elementEndOffset > endOffset) {
                    break;
                }
                if (psiElement instanceof BasePsiElement) {
                    BasePsiElement basePsiElement = (BasePsiElement) psiElement;
                    if (basePsiElement.getElementType().getId().equals(id) &&
                            elementStartOffset == startOffset &&
                            elementEndOffset == endOffset) {
                        return basePsiElement;
                    }
                }
View Full Code Here

Examples of com.dci.intellij.dbn.language.common.psi.BasePsiElement

        if (psiElement instanceof PsiComment) {
            return null;
        }

        if (psiElement instanceof BasePsiElement) {
            BasePsiElement basePsiElement = (BasePsiElement) psiElement;

            Wrap wrap = getWrapAttribute();
            if (wrap != null) {
                return wrap;
            }
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.