Package com.intellij.psi

Examples of com.intellij.psi.PsiElement


    protected Spacing getSpacing(BasePsiElement psiElement, boolean shouldWrap) {
        if (shouldWrap) {
            return SPACING_ONE_LINE;
        } else {
            PsiElement previousPsiElement = psiElement.getPrevSibling();
            if (previousPsiElement instanceof TokenPsiElement) {
                TokenPsiElement previousToken = (TokenPsiElement) previousPsiElement;
                SharedTokenTypeBundle sharedTokenTypes = psiElement.getLanguage().getSharedTokenTypes();
                TokenType tokenType = previousToken.getElementType().getTokenType();
                return tokenType ==  sharedTokenTypes.getLeftParenthesis() ?
View Full Code Here


        this.parameters = parameters;
        this.result = result;
        this.extended = parameters.getCompletionType() == CompletionType.SMART;
        this.connectionHandler = file.getActiveConnection();

        PsiElement position = parameters.getPosition();
        if (parameters.getOffset() > position.getTextOffset()) {
            userInput = position.getText().substring(0, parameters.getOffset() - position.getTextOffset());
        }

        GlobalProjectSettings globalSettings = GlobalProjectSettings.getInstance(file.getProject());
        codeStyleSettings = globalSettings.getCodeStyleSettings();
        codeCompletionSettings = globalSettings.getCodeCompletionSettings();

        elementAtCaret = position instanceof BasePsiElement ? (BasePsiElement) position : PsiUtil.lookupLeafAtOffset(file, position.getTextOffset());
        elementAtCaret = elementAtCaret == null ? file : elementAtCaret;
    }
View Full Code Here

            StringTokenizer tokenizer = new StringTokenizer(signature, "#");
            String id = tokenizer.nextToken();
            int startOffset = Integer.parseInt(tokenizer.nextToken());
            int endOffset = Integer.parseInt(tokenizer.nextToken());

            PsiElement psiElement = psifile.findElementAt(startOffset);
            if (psiElement instanceof PsiComment) {
                if (id.equals("comment") && endOffset == startOffset + psiElement.getTextLength()) {
                    return psiElement;
                }
            }

            while (psiElement != null) {
                int elementStartOffset = psiElement.getTextOffset();
                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;
                    }
                }
                psiElement = psiElement.getParent();
            }
        }
        return null;
    }
View Full Code Here

            if (attribute != null) {
                return attribute;
            }

            if (type == FormattingAttributes.Type.SPACING_BEFORE || type == FormattingAttributes.Type.SPACING_AFTER) {
                PsiElement parent = psiElement.getParent();
                PsiElement child = type.isLeft() ? parent.getFirstChild() : parent.getLastChild();
                if (child != psiElement) {
                    attributes = psiElement.getFormattingAttributesRecursive(type.isLeft());
                    attribute = FormattingAttributes.getAttribute(attributes, type);
                    if (attribute != null) {
                        return attribute;
View Full Code Here

        if (leftBlock == null) {
            return null;
        }

        PsiElement leftPsiElement = leftBlock.getPsiElement();
        PsiElement rightPsiElement = rightBlock.getPsiElement();

        if (leftPsiElement instanceof PsiComment || rightPsiElement instanceof PsiComment) {
            return null;
        }
View Full Code Here

        }
        return SpacingDefinition.ONE_SPACE.getValue();
    }

    private BasePsiElement getParentPsiElement(PsiElement psiElement) {
        PsiElement parentPsiElement = psiElement.getParent();
        if (parentPsiElement instanceof BasePsiElement) {
            return (BasePsiElement) parentPsiElement;
        }
        return null;
    }
View Full Code Here

        return null;
    }

    private FormattingBlock getParentBlock(FormattingBlock block, ElementTypeAttribute typeAttribute) {
        if (block.parentBlock != null) {
            PsiElement psiElement = block.parentBlock.getPsiElement();
            if (psiElement instanceof BasePsiElement) {
                BasePsiElement basePsiElement = (BasePsiElement) psiElement;
                if (basePsiElement.getElementType().is(typeAttribute)) {
                    return block.parentBlock;
                }
View Full Code Here

    }

    @NotNull
    public synchronized List<Block> getSubBlocks() {
        if (childBlocks == null) {
            PsiElement child = psiElement.getFirstChild();
            while (child != null) {
                if (!(child instanceof PsiWhiteSpace) && !(child instanceof PsiErrorElement) && child.getTextLength() > 0) {
                    if (childBlocks == null) childBlocks = new ArrayList<Block>();
                    CodeStyleCustomSettings codeStyleCustomSettings = getCodeStyleSettings(child);
                    FormattingBlock childBlock = new FormattingBlock(codeStyleSettings, codeStyleCustomSettings, child, this, index);
                    childBlocks.add(childBlock);
                }
                child = child.getNextSibling();
            }

            if (childBlocks == null) childBlocks = EMPTY_LIST;
        }
        return childBlocks;
View Full Code Here

     */
    public BasePsiElement lookupPsiElement(PsiLookupAdapter lookupAdapter, int scopeCrossCount) {
        if (lookupAdapter instanceof IdentifierLookupAdapter) {
            IdentifierLookupAdapter identifierLookupAdapter = (IdentifierLookupAdapter) lookupAdapter;
            if (identifierLookupAdapter.matchesName(this)) {
                PsiElement parentPsiElement = getParent();
                if (parentPsiElement instanceof QualifiedIdentifierPsiElement) {
                    QualifiedIdentifierPsiElement qualifiedIdentifierPsiElement = (QualifiedIdentifierPsiElement) parentPsiElement;
                    QualifiedIdentifierElementType qualifiedIdentifierElementType = qualifiedIdentifierPsiElement.getElementType();
                    if (!qualifiedIdentifierElementType.containsObjectType(identifierLookupAdapter.getObjectType())) {
                        return null;
View Full Code Here

     * @return real underlying database object behind the identifier.
     */
    @Nullable
    public synchronized DBObject resolveUnderlyingObject() {
        DBObject underlyingObject = null;
        PsiElement psiElement = resolve();
        if (isObject()) {
            if (psiElement instanceof DBObject) {
                DBObject object = (DBObject) psiElement;
                underlyingObject = object.getUndisposedElement();
            } else if (psiElement instanceof IdentifierPsiElement) {
                IdentifierPsiElement identifierPsiElement = (IdentifierPsiElement) psiElement;
                PsiElement underlyingPsiElement = identifierPsiElement.resolve();
                if (underlyingPsiElement instanceof DBObject) {
                    underlyingObject = (DBObject) underlyingPsiElement;
                }
            }
        } else if (isAlias()) {
            BasePsiElement aliasDefinition;
            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) {
                    if (aliasedObject.isVirtualObject()) {
                        return aliasedObject.resolveUnderlyingObject();
                    } else if (aliasedObject instanceof IdentifierPsiElement) {
                        IdentifierPsiElement identifierPsiElement = (IdentifierPsiElement) aliasedObject;
                        PsiElement underlyingPsiElement = identifierPsiElement.resolve();
                        if (underlyingPsiElement != null && underlyingPsiElement instanceof DBObject) {
                            underlyingObject = (DBObject) underlyingPsiElement;
                        }
                    }
                }
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.