Package com.intellij.openapi.editor

Examples of com.intellij.openapi.editor.DocumentFragment


  private static void annotateBasePath(@NotNull BasePathInfo basePathInfo,
                                       @NotNull AnnotationHolder holder) {
    YAMLKeyValue keyValue = basePathInfo.getKeyValue();
    if (keyValue != null) {
      DocumentFragment documentFragment = basePathInfo.getValueAsDocumentFragment();
      if (documentFragment == null) {
        int offset = keyValue.getTextRange().getEndOffset();
        holder.createErrorAnnotation(TextRange.create(offset - 1, offset), "path is unspecified");
      }
      else {
View Full Code Here


      holder.createErrorAnnotation(sequence, "Unexpected multiline path");
      return;
    }
    PsiElementFragment<YAMLSequence> sequenceTextFragment = JstdConfigFileUtils.buildSequenceTextFragment(sequence);
    if (basePath != null && sequenceTextFragment != null) {
      DocumentFragment documentFragment = sequenceTextFragment.toDocumentFragment();
      if (documentFragment != null) {
        annotatePath(basePath, documentFragment, holder, true, false);
      }
    }
  }
View Full Code Here

  }

  private static boolean isOneLineText(@NotNull YAMLSequence sequence) {
    PsiElementFragment<YAMLSequence> textSequenceFragment = JstdConfigFileUtils.buildSequenceTextFragment(sequence);
    if (textSequenceFragment != null) {
      DocumentFragment textFragment = textSequenceFragment.toDocumentFragment();
      if (textFragment != null) {
        Document document = textFragment.getDocument();
        TextRange textRange = textFragment.getTextRange();
        int startLine = document.getLineNumber(textRange.getStartOffset());
        int endLine = document.getLineNumber(textRange.getEndOffset());
        return startLine == endLine;
      }
    }
View Full Code Here

    if (endLineNumber > 0 && document.getLineStartOffset(endLineNumber) == contentTextRange.getEndOffset()) {
      endLineNumber--;
    }
    int documentEndOffset = document.getLineEndOffset(endLineNumber);

    DocumentFragment fragment = new DocumentFragment(document, contentTextRange.getStartOffset(), documentEndOffset);
    return UnquotedText.unquoteDocumentFragment(fragment);
  }
View Full Code Here

    });
  }

  @Nullable
  private static PsiReference createBasePathRef(@NotNull BasePathInfo basePathInfo) {
    DocumentFragment documentFragment = basePathInfo.getValueAsDocumentFragment();
    YAMLKeyValue keyValue = basePathInfo.getKeyValue();
    if (documentFragment != null && keyValue != null) {
      PsiElementFragment<YAMLKeyValue> keyValueFragment = PsiElementFragment.create(keyValue, documentFragment);
      if (keyValueFragment != null) {
        return new MyPsiReference(keyValueFragment, basePathInfo, ".");
View Full Code Here

    Document document = JsPsiUtils.getDocument(myElement);
    if (document == null) {
      return null;
    }
    TextRange documentTextRange = getDocumentTextRange();
    return new DocumentFragment(document, documentTextRange.getStartOffset(), documentTextRange.getEndOffset());
  }
View Full Code Here

    yamlDocument.acceptChildren(new PsiElementVisitor() {
      @Override
      public void visitElement(PsiElement element) {
        YAMLKeyValue keyValue = ObjectUtils.tryCast(element, YAMLKeyValue.class);
        if (keyValue != null && isBasePathKey(keyValue) && result.isNull()) {
          DocumentFragment valueFragment = JstdConfigFileUtils.extractValueAsDocumentFragment(keyValue);
          result.set(Pair.create(keyValue, valueFragment));
        }
      }
    });
    return result.get();
View Full Code Here

  }

  public static DocumentFragment unquoteDocumentFragment(@NotNull DocumentFragment fragment) {
    String str = fragment.getDocument().getText(fragment.getTextRange());
    TextRange unquoted = calcUnquotedDocumentTextRange(str, fragment.getTextRange());
    return new DocumentFragment(fragment.getDocument(), unquoted.getStartOffset(), unquoted.getEndOffset());
  }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.editor.DocumentFragment

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.