Package com.intellij.openapi.util

Examples of com.intellij.openapi.util.TextRange


public class RegexLanguageInjector implements LanguageInjector {
  @Override
  public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
    if (host instanceof HaxeRegularExpression) {
      final String text = host.getText();
      final TextRange textRange = new TextRange(text.indexOf('/') + 1, text.lastIndexOf('/'));
      injectionPlacesRegistrar.addPlace(RegExpLanguage.INSTANCE, textRange, null, null);
    }
  }
View Full Code Here


  private static TextRange getTextRangeForLine(Document document, int line) {
    try {
      int lineStartOffset = document.getLineStartOffset(line);
      int lineEndOffset = document.getLineEndOffset(line);
      return new TextRange(lineStartOffset, lineEndOffset);
    } catch (IndexOutOfBoundsException e) {
      // Local file should be different than remote
      return TextRange.EMPTY_RANGE;
    }
  }
View Full Code Here

    if (document == null) {
      return TextRange.EMPTY_RANGE;
    }
    int line = document.getLineNumber(psiElement.getTextOffset());
    int lineEndOffset = document.getLineEndOffset(line);
    return new TextRange(psiElement.getTextOffset(), lineEndOffset);
  }
View Full Code Here

    final Set<SonarIssue> issues;

    if (!DocumentChangeListener.CHANGED_FILES.contains(psiFile.getVirtualFile())) {
      issues = IssuesByFileIndex.getIssuesForFile(psiFile);
      for (SonarIssue issue : issues) {
        final TextRange textRange = Finders.getLineRange(psiFile, issue.getLine());
        createInvisibleHighlighter(psiFile, issue, textRange);
      }
    } else {
      final Set<SonarIssue> issuesFromHighlighters = Sets.newLinkedHashSet();
View Full Code Here

      Optional<PsiElement> startElement = Finders.findFirstElementAtLine(psiFile, issue.getLine());
      if (!startElement.isPresent()) {
        // There is no AST element on this line. Maybe a tabulation issue on a blank line?
        annotation = createAnnotation(holder, issue.formattedMessage(), Finders.getLineRange(psiFile, issue.getLine()), severity);
      } else if (startElement.get().isValid()) {
        TextRange lineRange = Finders.getLineRange(startElement.get());
        annotation = createAnnotation(holder, issue.formattedMessage(), lineRange, severity);
      } else {
        annotation = null;
      }
    }
View Full Code Here

    Set<SonarIssue> issues = IssuesByFileIndex.getIssuesForFile(psiFile);
    for (final SonarIssue issue : issues) {
      if (!processIssue(issue)) continue;
      final ProblemHighlightType severity = SonarToIjSeverityMapping.toProblemHighlightType(issue.getSeverity());
      final TextRange textRange = Finders.getLineRange(psiFile, issue.getLine());
      final ProblemDescriptor problemDescriptor = problemsHolder.getManager().createProblemDescriptor(psiFile, textRange,
          issue.formattedMessage() + " " + issue.getRuleKey(),
          severity,
          false
      );
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

            // only on alias and namespace use main ns
            if(tagName.contains("\\")) {
                rangeEnd = tagName.indexOf("\\") + rangeStart;
            }

            return new TextRange(rangeStart, rangeEnd);
        }
View Full Code Here

    public PsiElement getElement() {
        return this.element;
    }

    public TextRange getRangeInElement() {
        return new TextRange(1, element.getTextLength() - 1);
    }
View Full Code Here

                                .replace(basePath, ""));
                        String protectedPath = YiiRefsHelper.getCurrentProtected(path);
                        protectedPath = protectedPath.replace(basePath, "");

                        String str = element.getText();
                        TextRange textRange = CommonHelper.getTextRange(element, str);
                        String uri = str.substring(textRange.getStartOffset(), textRange.getEndOffset());
                        int start = textRange.getStartOffset();
                        int len = textRange.getLength();

                        if (!uri.endsWith(".tpl") && !uri.startsWith("smarty:")) {
                            uri += ".php";
                        }

                        VirtualFile appDir = baseDir.findFileByRelativePath(viewPath);
                        VirtualFile protectedPathDir = (!protectedPath.equals(""))
                                ? baseDir.findFileByRelativePath(protectedPath) : null;

                        String filepath = viewPath + "/" + uri;
                        if (uri.matches("^//.+")) {
                            filepath = viewAbsolutePath + "/" + uri.replace("//", "");
                        }
                        VirtualFile viewfile = baseDir.findFileByRelativePath(filepath);

                        if (viewfile != null && appDir != null) {
                            PsiReference ref = new FileReference(
                                    viewfile,
                                    uri,
                                    element,
                                    new TextRange(start, start + len),
                                    project,
                                    protectedPathDir,
                                    appDir);
                            return new PsiReference[]{ref};
                        }
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.