Examples of TextRange


Examples of com.intellij.openapi.util.TextRange

    public String generateDoc(PsiElement element, PsiElement originalElement) {
        if (!(element instanceof HPAbstractIdent))
            return null;
        HPAbstractIdent ident = (HPAbstractIdent) element;
        TextRange range = ident.getTextRange();
        PsiFile psiFile = element.getContainingFile();
        VirtualFile file = psiFile.getVirtualFile();
        if (file == null)
            return null;
        // todo: run in event-dispatch thread
        //fdm.saveAllDocuments();
        // try this: PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
        int offset = range.getStartOffset();
        LineCol coord = LineCol.fromOffset(psiFile, offset);
        Module module = DeclarationPosition.getDeclModule(psiFile);
        if (module == null)
            return null;
        CompilerLocation compiler = CompilerLocation.get(module);
View Full Code Here

Examples of com.intellij.openapi.util.TextRange

        this.start = LineCol.parse(start);
        this.end = LineCol.parse(end);
    }

    public TextRange getRange(PsiFile file) {
        return new TextRange(start.getOffset(file), end.getOffset(file));
    }
View Full Code Here

Examples of com.intellij.openapi.util.TextRange

        if (elementAtSelection == null)
            return null;
        IElementType tokenType = elementAtSelection.getNode().getElementType();
        if (tokenType != HaskellTokenTypes.STRING)
            return null;
        TextRange textRange = elementAtSelection.getTextRange();
        if (selectionStart <= textRange.getStartOffset() || selectionEnd >= textRange.getEndOffset()) {
            return null;
        }
        return tokenType;
    }
View Full Code Here

Examples of com.intellij.openapi.util.TextRange

    public PsiElement getElement() {
        return this;
    }

    public TextRange getRangeInElement() {
        return new TextRange(0, getTextLength());
    }
View Full Code Here

Examples of com.intellij.openapi.util.TextRange

                PsiDocumentManager manager = PsiDocumentManager.getInstance(psiFile.getProject());
                Document document = manager.getDocument(psiFile);
                if (document == null)
                    return;
                manager.commitDocument(document);
                TextRange textRange = range.getRange(psiFile);
                int start = textRange.getStartOffset();
                int end = textRange.getEndOffset();
                int line = document.getLineNumber(end);
                int lineStart = document.getLineStartOffset(line);
                int lineEnd = document.getLineEndOffset(line);
                String functionName = document.getText(textRange);
                String importLine = document.getText().substring(lineStart, lineEnd);
View Full Code Here

Examples of com.intellij.openapi.util.TextRange

                        int subjectLineNumber = document.getLineNumber(subjectEndOffset);
                        int blockEndOffsetLineNumber = document.getLineNumber(blockEndOffset);

                        if (subjectLineNumber < blockEndOffsetLineNumber) {
                            TextRange textRange = new TextRange(subjectEndOffset, blockEndOffset);

                            FoldingDescriptor foldingDescriptor = new FoldingDescriptor(basePsiElement.getNode(), textRange);

                            foldingDescriptors.add(foldingDescriptor);
                            nestingIndex++;
                            folded = true;
                        }
                    }
                }

                if (!folded && elementType.is(ElementTypeAttribute.STATEMENT)) {
                    if (basePsiElement.containsLineBreaks()) {
                        TextRange textRange = null;

                        BasePsiElement firstPsiElement = basePsiElement.lookupFirstLeafPsiElement();
                        int firstElementEndOffset = firstPsiElement.getTextOffset() + firstPsiElement.getTextLength();
                        int firstElementLineNumber = document.getLineNumber(firstElementEndOffset);


                        BasePsiElement subjectPsiElement = basePsiElement.lookupFirstPsiElement(ElementTypeAttribute.SUBJECT);
                        if (subjectPsiElement != null && subjectPsiElement.getParent() == basePsiElement) {
                            int subjectEndOffset = subjectPsiElement.getTextOffset() + subjectPsiElement.getTextLength();
                            int subjectLineNumber = document.getLineNumber(subjectEndOffset);

                            if (subjectLineNumber == firstElementLineNumber) {
                                textRange = new TextRange(subjectEndOffset, blockEndOffset);
                            }
                        }

                        if (textRange == null) {
                            textRange = new TextRange(firstElementEndOffset, blockEndOffset);
                        }

                        FoldingDescriptor foldingDescriptor = new FoldingDescriptor(basePsiElement.getNode(), textRange);
                        foldingDescriptors.add(foldingDescriptor);
                        nestingIndex++;
View Full Code Here

Examples of com.intellij.openapi.util.TextRange

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

Examples of com.intellij.openapi.util.TextRange

    public boolean isReferenceTo(PsiElement element) {
        return false;
    }

    public TextRange getRangeInElement() {                                       
        return new TextRange(0, getTextLength());
    }
View Full Code Here

Examples of com.intellij.openapi.util.TextRange

import java.util.StringTokenizer;

public class DBLanguageElementSignatureProvider implements ElementSignatureProvider {
    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;
            }
View Full Code Here

Examples of com.intellij.openapi.util.TextRange

  private static void addAnnotation(final ExtendedProblemDescriptor problemDescriptor, final List<ExtendedProblemDescriptor> matchingDescriptors, final PsiElement psiElement, @NotNull final AnnotationHolder annotationHolder) {
    final BugInstance bugInstance = problemDescriptor.getBugInstance();
    final int priority = bugInstance.getPriority();
    final Annotation annotation;
    final PsiElement problemElement = problemDescriptor.getPsiElement();
    final TextRange textRange = problemElement.getTextRange();


    switch (priority) {
      case Detector.HIGH_PRIORITY:
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.