Package com.intellij.openapi.util

Examples of com.intellij.openapi.util.TextRange


    return getDartPackageReferences(psiElement, DartUrlResolver.getInstance(psiElement.getProject(), file));
  }

  private static FileReference[] getDartPackageReferences(@NotNull final PsiElement psiElement,
                                                          @NotNull final DartUrlResolver dartResolver) {
    final TextRange textRange = ElementManipulators.getValueTextRange(psiElement);
    final String referenceText = psiElement.getText().substring(textRange.getStartOffset(), textRange.getEndOffset());

    final FileReferenceSet referenceSet = new FileReferenceSet(referenceText, psiElement, textRange.getStartOffset(), null, true) {
      public FileReference createFileReference(final TextRange range, final int index, final String text) {
        return new DartPackageAwareFileReference(this, range, index, text, dartResolver);
      }
    };
View Full Code Here


    return null;
  }

  @Override
  public TextRange getRangeInElement() {
    final TextRange textRange = getTextRange();
    return new TextRange(0, textRange.getEndOffset() - textRange.getStartOffset());
  }
View Full Code Here

    int highlightingStart = message.getOffset();
    int highlightingEnd = message.getOffset() + message.getLength();
    if (highlightingEnd > fileTextLength) highlightingEnd = fileTextLength;
    if (highlightingStart >= highlightingEnd) highlightingStart = highlightingEnd - 1;

    final TextRange textRange = new TextRange(highlightingStart, highlightingEnd);
    final ErrorCode errorCode = message.getErrorCode();

    switch (errorCode.getErrorSeverity()) {
      case NONE:
        return null;
View Full Code Here

    assert pattern != null;

    String patternText = pattern.getText();

    builder.replaceElement(pattern,
                           new TextRange(1, patternText.length() - 1),
                           patternText.substring(1, patternText.length() - 1));

    // block vars
    GrClosableBlock closure = methodCall.getClosureArguments()[0];
    final GrParameter[] blockVars = closure.getAllParameters();
    for (GrParameter var : blockVars) {
      PsiElement identifier = var.getNameIdentifierGroovy();
      builder.replaceElement(identifier, identifier.getText());
    }

    TemplateManager manager = TemplateManager.getInstance(project);

    final Editor editorToRunTemplate;
    if (editor == null) {
      editorToRunTemplate = IntentionUtils.positionCursor(project, file, methodCall);
    }
    else {
      editorToRunTemplate = editor;
    }

    Template template = builder.buildTemplate();

    TextRange range = methodCall.getTextRange();
    editorToRunTemplate.getDocument().deleteString(range.getStartOffset(), range.getEndOffset());
    editorToRunTemplate.getCaretModel().moveToOffset(range.getStartOffset());

    manager.startTemplate(editorToRunTemplate, template, new TemplateEditingAdapter() {
      @Override
      public void templateFinished(Template template, boolean brokenOff) {
        if (brokenOff) return;
View Full Code Here

      Runnable createFormatRunnable(final PsiFile file) {
        return new Runnable() {
          @Override
          public void run() {
            try {
              TextRange rangeToUse = file.getTextRange();
              CodeStyleManager styleManager = CodeStyleManager.getInstance(getProject());
              styleManager.reformatText(file, rangeToUse.getStartOffset(), rangeToUse.getEndOffset());
            }
            catch (IncorrectOperationException e) {
              assertTrue(e.getLocalizedMessage(), false);
            }
          }
View Full Code Here

        final GherkinExamplesBlockImpl block = PsiTreeUtil.getChildOfType(outline, GherkinExamplesBlockImpl.class);
        if (block == null) {
          final PsiElement descriptionLine = outline.getShortDescriptionText();
          if (descriptionLine != null) {
            holder.registerProblem(outline,
                                   new TextRange(0, descriptionLine.getTextRange().getEndOffset() - outline.getTextOffset()),
                                   CucumberBundle.message("inspection.missed.example.msg.name"),
                                   new CucumberCreateExamplesSectionFix());
          }
        }
      }
View Full Code Here

    if (fileType != StdFileTypes.JSP && fileType != StdFileTypes.JSPX) {
      return;
    }

    if (CSS_ELEMENT_PATTERN.accepts(context)) {
      final TextRange range = new TextRange(1, context.getTextLength() - 1);
      registrar.startInjecting(CssFileType.INSTANCE.getLanguage())
        .addPlace("inline.style {", "}", (PsiLanguageInjectionHost)context, range)
        .doneInjecting();
    }
  }
View Full Code Here

          }

          @NotNull
          @Override
          protected BeanPropertyPathReference createReference(final TextRange range, final int index) {
            final TextRange shift = TextRange.from(range.getStartOffset() + tagValueStartOffset,
                                                   range.getLength()); // shift range to XmlTag value range
            return createBeanPropertyPathReference(shift, index);
          }
        };
View Full Code Here

          return false;
        }
      }
    }

    TextRange range = reference.getRangeInElement().shiftRight(reference.getElement().getTextOffset());
    holder.createErrorAnnotation(range, OsmorcBundle.message("manifest.activator.class.invalid"));
    return true;
  }
View Full Code Here

    if (parent instanceof XmlAttribute) {
      String name = ((XmlAttribute)parent).getLocalName();
      if ("expression".equals(name) || "templateExpression".equals(name)) {
        DomElement domElement = DomManager.getDomManager(context.getProject()).getDomElement((XmlTag)parent.getParent());
        if (domElement instanceof Put || domElement instanceof Add || domElement instanceof Definition) {
          final TextRange attributeTextRange = ElementManipulators.getValueTextRange(context);
          final TextRange ognlTextRange = TextRange.from(attributeTextRange.getStartOffset() + OGNL_PREFIX.length(),
                                                         attributeTextRange.getLength() - OGNL_PREFIX.length());
          registrar.startInjecting(OgnlLanguage.INSTANCE)
            .addPlace(OgnlLanguage.EXPRESSION_PREFIX, OgnlLanguage.EXPRESSION_SUFFIX,
                      (PsiLanguageInjectionHost)context, ognlTextRange)
            .doneInjecting();
View Full Code Here

TOP

Related Classes of com.intellij.openapi.util.TextRange

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.