Package com.intellij.openapi.util

Examples of com.intellij.openapi.util.TextRange


        URL parsedURL = parseURL(value, actionExtension);
        if (parsedURL == null) return;

        if (buildTag("", parsedURL, "", false, actionExtension) == null) return;

        TextRange range = ElementManipulators.getValueTextRange(value);
        holder.registerProblem(value, range, "Use Struts <url> tag instead of hardcoded URL", new WrapWithSUrl(actionExtension));
      }
    };
  }
View Full Code Here


    private void wrapValue(String prefix, XmlAttributeValue value, URL url, boolean inline) {
      final JspFile jspFile = JspPsiUtil.getJspFile(value);
      assert jspFile != null;

      Project project = jspFile.getProject();
      TextRange range = value.getValueTextRange();
      Document document = PsiDocumentManager.getInstance(project).getDocument(jspFile);
      assert document != null;
      PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(document);

      int start = range.getStartOffset();
      int lineStart = document.getLineStartOffset(document.getLineNumber(start));
      String linePrefix = document.getCharsSequence().subSequence(lineStart, start).toString();
      linePrefix = linePrefix.substring(0, linePrefix.length() - linePrefix.trim().length());

      String indent = linePrefix;
      while (indent.length() < start - lineStart) indent += " ";

      Pair<String, String> tag_var = buildTag(prefix, url, indent, inline, myActionExtension);
      String tag = tag_var.getFirst();
      String var = tag_var.getSecond();

      int end = range.getEndOffset();

      int formattingStart;
      int formattingEnd;

      if (inline) {
View Full Code Here

      .withSuperParent(3, psiElement(FtlMacro.class).with(FreemarkerInjectionConstants.TAGLIB_PREFIX));

  @Override
  public void getLanguagesToInject(@NotNull final MultiHostRegistrar multiHostRegistrar, @NotNull final PsiElement psiElement) {
    if (CSS_ELEMENT_PATTERN.accepts(psiElement)) {
      final TextRange range = new TextRange(1, psiElement.getTextLength() - 1);
      multiHostRegistrar.startInjecting(CssFileType.INSTANCE.getLanguage())
        .addPlace("inline.style {", "}", (PsiLanguageInjectionHost) psiElement, range)
        .doneInjecting();
    }
  }
View Full Code Here

    if (offset == 0 || offset > editor.getDocument().getTextLength()) {
      return Result.CONTINUE;
    }

    String previousChar = editor.getDocument().getText(new TextRange(offset - 1, offset));

    if (file.getViewProvider() instanceof HbFileViewProvider) {
      PsiDocumentManager.getInstance(project).commitAllDocuments();

      // we suppress the built-in "}" auto-complete when we see "{{"
View Full Code Here

    if (offset < 2 || offset > editor.getDocument().getTextLength()) {
      return Result.CONTINUE;
    }

    String previousChar = editor.getDocument().getText(new TextRange(offset - 2, offset - 1));
    boolean closeBraceCompleted = false;

    if (provider instanceof HbFileViewProvider) {
      if (HbConfig.isAutocompleteMustachesEnabled() && c == '}' && !previousChar.equals("}")) {
        // we may be able to complete the second brace
View Full Code Here

        final HbCloseBlockMustache close = PsiTreeUtil.findChildOfType(block, HbCloseBlockMustache.class);
        if (open != null && close == null) {
          final HbMustacheName mustacheName = PsiTreeUtil.findChildOfType(open, HbMustacheName.class);
          if (mustacheName != null) {
            if (offset > 3) {
              final String prePreviousChar = editor.getDocument().getText(new TextRange(offset - 3, offset - 2));
              if (prePreviousChar.equals("{")) {
                editor.getDocument().insertString(offset, mustacheName.getText() + CLOSE_BRACES);
                editor.getCaretModel().moveToOffset(offset + mustacheName.getText().length() + CLOSE_BRACES.length());
              } else {
                editor.getDocument().replaceString(offset - 1, offset, OPEN_BRACE + '/' + mustacheName.getText() + CLOSE_BRACES);
View Full Code Here

          text = m.replaceAll("$1");
        }

        m = PARAMETERS_PATTERN.matcher(text);
        while (m.find()) {
          ranges.add(new TextRange(m.start(), m.end()));
        }

        final PsiElement element = definition.getElement();
        final LookupElementBuilder lookup = element != null
                                            ? LookupElementBuilder.create(element, text).bold()
View Full Code Here

                                final int offset,
                                final String text,
                                final boolean soft,
                                final StrutsModel strutsModel,
                                final List<String> actionExtensions) {
      super(element, new TextRange(offset, offset + text.length()), soft);
      this.strutsModel = strutsModel;
      this.actionExtensions = actionExtensions;

      fullActionPath = PathReference.trimPath(getValue());
      final int lastSlash = fullActionPath.lastIndexOf("/");
View Full Code Here

      allStrutsPackages = strutsModel.getStrutsPackages();
    }

    private static TextRange computeRange(final int offset, final String text) {
      final int lastSlash = text.lastIndexOf('/');
      return new TextRange(offset, offset + (lastSlash == -1 ? text.length() : lastSlash));
    }
View Full Code Here

    }

    HbPath path = PsiTreeUtil.findChildOfType(targetBlockMustache, HbPath.class);
    final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
    if (path != null && document != null) {
      final TextRange textRange = path.getTextRange();
      document.replaceString(textRange.getStartOffset(), textRange.getEndOffset(), myCorrectedName);
    }
  }
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.