• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ProperTextRange类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.intellij.openapi.util.ProperTextRange的典型用法代码示例。如果您正苦于以下问题:Java ProperTextRange类的具体用法?Java ProperTextRange怎么用?Java ProperTextRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ProperTextRange类属于com.intellij.openapi.util包,在下文中一共展示了ProperTextRange类的37个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: inspectEx

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@NotNull
public static Map<String, List<ProblemDescriptor>> inspectEx(@NotNull final List<LocalInspectionToolWrapper> toolWrappers,
                                                             @NotNull final PsiFile file,
                                                             @NotNull final InspectionManager iManager,
                                                             final boolean isOnTheFly,
                                                             boolean failFastOnAcquireReadAction,
                                                             @NotNull final ProgressIndicator indicator) {
  if (toolWrappers.isEmpty()) return Collections.emptyMap();
  final List<PsiElement> elements = new ArrayList<PsiElement>();

  TextRange range = file.getTextRange();
  Divider.divideInsideAndOutside(file, range.getStartOffset(), range.getEndOffset(), range, elements, new ArrayList<ProperTextRange>(),
                                 Collections.<PsiElement>emptyList(), Collections.<ProperTextRange>emptyList(), true, Conditions.<PsiFile>alwaysTrue());

  return inspectElements(toolWrappers, file, iManager, isOnTheFly, failFastOnAcquireReadAction, indicator, elements,
                         calcElementDialectIds(elements));
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:18,
代码来源:InspectionEngine.java

示例2: divideInsideAndOutside

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
public static void divideInsideAndOutside(@NotNull PsiFile file,
                                          int startOffset,
                                          int endOffset,
                                          @NotNull TextRange range,
                                          @NotNull List<PsiElement> inside,
                                          @NotNull List<ProperTextRange> insideRanges,
                                          @NotNull List<PsiElement> outside,
                                          @NotNull List<ProperTextRange> outsideRanges,
                                          boolean includeParents,
                                          @NotNull Condition<PsiFile> filter) {
  final FileViewProvider viewProvider = file.getViewProvider();
  for (Language language : viewProvider.getLanguages()) {
    final PsiFile psiRoot = viewProvider.getPsi(language);
    if (filter.value(psiRoot)) {
      divideInsideAndOutside(psiRoot, startOffset, endOffset, range, inside, insideRanges, outside, outsideRanges, includeParents);
    }
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:19,
代码来源:Divider.java

示例3: getRangeInElement

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
/**
 * @return range in element
 */
@Nullable("null means range is invalid")
public ProperTextRange getRangeInElement() {
  PsiElement element = getElement();
  if (element == null) return null;
  TextRange elementRange = element.getTextRange();
  ProperTextRange result;
  if (myPsiFileRange == null) {
    int startOffset = element.getTextOffset();
    result = ProperTextRange.create(startOffset, elementRange.getEndOffset());
  }
  else {
    Segment rangeInFile = myPsiFileRange.getRange();
    if (rangeInFile == null) return null;
    result = ProperTextRange.create(rangeInFile);
  }
  int delta = elementRange.getStartOffset();
  return result.getStartOffset() < delta ? null : result.shiftRight(-delta);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:22,
代码来源:UsageInfo.java

示例4: getNearestHighlighters

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
private void getNearestHighlighters(@NotNull MarkupModelEx markupModel,
                                    final int scrollBarY,
                                    @NotNull final Collection<RangeHighlighter> nearest) {
  int startOffset = yPositionToOffset(scrollBarY - myMinMarkHeight, true);
  int endOffset = yPositionToOffset(scrollBarY + myMinMarkHeight, false);
  markupModel.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor<RangeHighlighterEx>() {
    @Override
    public boolean process(@NotNull RangeHighlighterEx highlighter) {
      if (!highlighter.getEditorFilter().avaliableIn(myEditor)) return true;

      if (highlighter.getErrorStripeMarkColor() != null) {
        ProperTextRange range = offsetsToYPositions(highlighter.getStartOffset(), highlighter.getEndOffset());
        if (scrollBarY >= range.getStartOffset() - myMinMarkHeight * 2 &&
            scrollBarY <= range.getEndOffset() + myMinMarkHeight * 2) {
          nearest.add(highlighter);
        }
      }
      return true;
    }
  });
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:22,
代码来源:EditorMarkupModelImpl.java

示例5: repaint

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
private void repaint(@NotNull final Graphics g, int gutterWidth, @NotNull ProperTextRange yrange) {
  final Rectangle clip = new Rectangle(0, yrange.getStartOffset(), gutterWidth, yrange.getLength() + myMinMarkHeight);
  paintTrackBasement(g, clip);

  Document document = myEditor.getDocument();
  int startOffset = yPositionToOffset(clip.y - myMinMarkHeight, true);
  int endOffset = yPositionToOffset(clip.y + clip.height, false);

  Shape oldClip = g.getClip();
  g.clipRect(clip.x, clip.y, clip.width, clip.height);

  drawMarkup(g, startOffset, endOffset,
             (MarkupModelEx)DocumentMarkupModel.forDocument(document, myEditor.getProject(), true), EditorMarkupModelImpl.this);

  g.setClip(oldClip);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:17,
代码来源:EditorMarkupModelImpl.java

示例6: markDirtied

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
public void markDirtied(@NotNull ProperTextRange yPositions) {
  if (myDirtyYPositions != WHOLE_DOCUMENT) {
    int start = Math.max(0, yPositions.getStartOffset() - myEditor.getLineHeight());
    int end = myEditorScrollbarTop + myEditorTargetHeight == 0 ? yPositions.getEndOffset() + myEditor.getLineHeight()
                                                               : Math
                .min(myEditorScrollbarTop + myEditorTargetHeight, yPositions.getEndOffset() + myEditor.getLineHeight());
    ProperTextRange adj = new ProperTextRange(start, Math.max(end, start));

    myDirtyYPositions = myDirtyYPositions == null ? adj : myDirtyYPositions.union(adj);
  }

  myEditorScrollbarTop = 0;
  myEditorSourceHeight = 0;
  myEditorTargetHeight = 0;
  dimensionsAreValid = false;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:17,
代码来源:EditorMarkupModelImpl.java

示例7: processIfOnePoint

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Nullable
private static ProperTextRange processIfOnePoint(@NotNull DocumentEvent e, int intervalStart, int intervalEnd, boolean greedyRight) {
  int offset = e.getOffset();
  int oldLength = e.getOldLength();
  int oldEnd = offset + oldLength;
  if (offset < intervalStart && intervalStart < oldEnd) {
    return null;
  }

  if (offset == intervalStart && oldLength == 0 && greedyRight) {
    return new ProperTextRange(intervalStart, intervalEnd + e.getNewLength());
  }

  if (intervalStart > oldEnd || intervalStart == oldEnd  && oldLength > 0) {
    return new ProperTextRange(intervalStart + e.getNewLength() - oldLength, intervalEnd + e.getNewLength() - oldLength);
  }

  return new ProperTextRange(intervalStart, intervalEnd);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:20,
代码来源:RangeMarkerImpl.java

示例8: translateViaDiff

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Nullable
private static Pair<ProperTextRange, LinesCols> translateViaDiff(final DocumentEventImpl event, LinesCols linesCols) {
  try {
    int myStartLine = event.translateLineViaDiffStrict(linesCols.myStartLine);
    Document document = event.getDocument();
    if (myStartLine < 0 || myStartLine >= document.getLineCount()) {
      return null;
    }

    int start = document.getLineStartOffset(myStartLine) + linesCols.myStartColumn;
    if (start >= document.getTextLength()) return null;

    int myEndLine = event.translateLineViaDiffStrict(linesCols.myEndLine);
    if (myEndLine < 0 || myEndLine >= document.getLineCount()) {
      return null;
    }

    int end = document.getLineStartOffset(myEndLine) + linesCols.myEndColumn;
    if (end > document.getTextLength() || end < start) return null;

    return Pair.create(new ProperTextRange(start, end), new LinesCols(myStartLine, linesCols.myStartColumn, myEndLine, linesCols.myEndColumn));
  }
  catch (FilesTooBigForDiffException e) {
    return null;
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:27,
代码来源:PersistentRangeMarker.java

示例9: applyChange

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Nullable
static Pair<ProperTextRange, LinesCols> applyChange(DocumentEvent event, Segment range, int intervalStart, int intervalEnd, boolean greedyLeft, boolean greedyRight, LinesCols linesCols) {
  final boolean shouldTranslateViaDiff = PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, range);
  Pair<ProperTextRange, LinesCols> translated = null;
  if (shouldTranslateViaDiff) {
    translated = translateViaDiff((DocumentEventImpl)event, linesCols);
  }
  if (translated == null) {
    ProperTextRange fallback = applyChange(event, intervalStart, intervalEnd, greedyLeft, greedyRight);
    if (fallback == null) return null;

    LinesCols lc = storeLinesAndCols(fallback, event.getDocument());
    if (lc == null) return null;

    translated = Pair.create(fallback, lc);
  }
  if (translated.first.getEndOffset() > event.getDocument().getTextLength() ||
      translated.second.myEndLine < translated.second.myStartLine ||
      translated.second.myStartLine == translated.second.myEndLine && translated.second.myEndColumn < translated.second.myStartColumn ||
      event.getDocument().getLineCount() < translated.second.myEndLine) {
    return null;
  }

  return translated;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:26,
代码来源:PersistentRangeMarker.java

示例10: restoreElement

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
public PsiElement restoreElement() {
  PsiFile hostFile = myHostContext.getContainingFile();
  if (hostFile == null || !hostFile.isValid()) return null;

  PsiElement hostContext = myHostContext.getElement();
  if (hostContext == null) return null;

  Segment segment = myInjectedFileRangeInHostFile.getPsiRange();
  if (segment == null) return null;

  PsiFile injectedPsi = getInjectedFileIn(hostContext, hostFile, TextRange.create(segment));
  ProperTextRange rangeInInjected = hostToInjected(true, segment, injectedPsi, myAffixOffsets);
  if (rangeInInjected == null) return null;

  return SelfElementInfo.findElementInside(injectedPsi, rangeInInjected.getStartOffset(), rangeInInjected.getEndOffset(), anchorClass, anchorLanguage);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:18,
代码来源:InjectedSelfElementInfo.java

示例11: getRangeInsideHost

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
@NotNull
public TextRange getRangeInsideHost() {
  PsiLanguageInjectionHost host = getHost();
  Segment psiRange = relevantRangeInHost.getPsiRange();
  TextRange textRange = psiRange == null ? null : TextRange.create(psiRange);
  if (host == null) {
    if (textRange != null) return textRange;
    Segment fromSP = hostElementPointer.getPsiRange();
    if (fromSP != null) return TextRange.create(fromSP);
    return new TextRange(0,0);
  }
  TextRange hostTextRange = host.getTextRange();
  textRange = textRange == null ? null : textRange.intersection(hostTextRange);
  if (textRange == null) return new ProperTextRange(0, hostTextRange.getLength());
  return textRange.shiftRight(-hostTextRange.getStartOffset());
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:18,
代码来源:ShredImpl.java

示例12: getNearestHighlighters

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
private void getNearestHighlighters(MarkupModelEx markupModel,
                                    MouseEvent e,
                                    final double width,
                                    final Collection<RangeHighlighter> nearest) {
  if (0 > e.getX() || e.getX() >= width) return;
  final int y = e.getY();
  int startOffset = yPositionToOffset(y - getMinHeight(), true);
  int endOffset = yPositionToOffset(y + getMinHeight(), false);
  markupModel.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor<RangeHighlighterEx>() {
    @Override
    public boolean process(RangeHighlighterEx highlighter) {
      if (highlighter.getErrorStripeMarkColor() != null) {
        ProperTextRange range = offsetsToYPositions(highlighter.getStartOffset(), highlighter.getEndOffset());
        if (y >= range.getStartOffset() - getMinHeight() * 2 &&
            y <= range.getEndOffset() + getMinHeight() * 2) {
          nearest.add(highlighter);
        }
      }
      return true;
    }
  });
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:23,
代码来源:EditorMarkupModelImpl.java

示例13: getRangeInsideHost

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
@NotNull
public TextRange getRangeInsideHost() {
  PsiLanguageInjectionHost host = getHost();
  ProperTextRange textRange =
    relevantRangeInHost.isValid() ? new ProperTextRange(relevantRangeInHost.getStartOffset(), relevantRangeInHost.getEndOffset()) : null;
  if (host == null) {
    if (textRange != null) return textRange;
    Segment fromSP = hostElementPointer.getRange();
    if (fromSP != null) return TextRange.create(fromSP);
    return new TextRange(0,0);
  }
  TextRange hostTextRange = host.getTextRange();
  textRange = textRange == null ? null : textRange.intersection(hostTextRange);
  if (textRange == null) return new ProperTextRange(0, hostTextRange.getLength());
  return textRange.shiftRight(-hostTextRange.getStartOffset());
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:18,
代码来源:ShredImpl.java

示例14: decode

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
public boolean decode(@NotNull TextRange rangeInsideHost, @NotNull StringBuilder outChars) {
  ProperTextRange.assertProperRange(rangeInsideHost);
  String subText = rangeInsideHost.substring(myHost.getText());
  outSourceOffsets = new int[subText.length() + 1];
  boolean b = PropertyImpl.parseCharacters(subText, outChars, outSourceOffsets);
  if (b) {
    for (int i=0; i<outChars.length(); i++) {
      if (outChars.charAt(i) != subText.charAt(outSourceOffsets[i])) {
        if (subText.charAt(outSourceOffsets[i]) != '\\') {
          throw new IllegalStateException();
        }
      }
    }
  }
  return b;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:18,
代码来源:PropertyImplEscaper.java

示例15: decode

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
public boolean decode(@NotNull TextRange rangeInsideHost, @NotNull StringBuilder outChars) {
  ProperTextRange.assertProperRange(rangeInsideHost);
  String subText = rangeInsideHost.substring(myHost.getText());
  outSourceOffsets = new int[subText.length() + 1];

  final IElementType elementType = myHost.getFirstChild().getNode().getElementType();
  if (elementType == GroovyTokenTypes.mSTRING_LITERAL || elementType == GroovyTokenTypes.mGSTRING_LITERAL || elementType == GroovyTokenTypes.mGSTRING_CONTENT) {
    return GrStringUtil.parseStringCharacters(subText, outChars, outSourceOffsets);
  }
  else if (elementType == GroovyTokenTypes.mREGEX_LITERAL || elementType == GroovyTokenTypes.mREGEX_CONTENT) {
    return GrStringUtil.parseRegexCharacters(subText, outChars, outSourceOffsets, true);
  }
  else if (elementType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL || elementType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_CONTENT) {
    return GrStringUtil.parseRegexCharacters(subText, outChars, outSourceOffsets, false);
  }
  else return false;
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:19,
代码来源:GrLiteralEscaper.java

示例16: getNearestHighlighters

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
private void getNearestHighlighters(MarkupModelEx markupModel, final int scrollBarY, final Collection<RangeHighlighter> nearest) {
  int startOffset = yPositionToOffset(scrollBarY - myMinMarkHeight, true);
  int endOffset = yPositionToOffset(scrollBarY + myMinMarkHeight, false);
  markupModel.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor<RangeHighlighterEx>() {
    @Override
    public boolean process(RangeHighlighterEx highlighter) {
      if (highlighter.getErrorStripeMarkColor() != null) {
        ProperTextRange range = offsetsToYPositions(highlighter.getStartOffset(), highlighter.getEndOffset());
        if (scrollBarY >= range.getStartOffset() - myMinMarkHeight * 2 && scrollBarY <= range.getEndOffset() + myMinMarkHeight * 2) {
          nearest.add(highlighter);
        }
      }
      return true;
    }
  });
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:17,
代码来源:EditorMarkupModelImpl.java

示例17: markDirtied

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
public void markDirtied(@Nonnull ProperTextRange yPositions) {
  if (myDirtyYPositions != WHOLE_DOCUMENT) {
    int start = Math.max(0, yPositions.getStartOffset() - myEditor.getLineHeight());
    int end = myEditorScrollbarTop + myEditorTargetHeight == 0
              ? yPositions.getEndOffset() + myEditor.getLineHeight()
              : Math.min(myEditorScrollbarTop + myEditorTargetHeight, yPositions.getEndOffset() + myEditor.getLineHeight());
    ProperTextRange adj = new ProperTextRange(start, Math.max(end, start));

    myDirtyYPositions = myDirtyYPositions == null ? adj : myDirtyYPositions.union(adj);
  }

  myEditorScrollbarTop = 0;
  myEditorSourceHeight = 0;
  myEditorTargetHeight = 0;
  dimensionsAreValid = false;
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:17,
代码来源:EditorMarkupModelImpl.java

示例18: restoreElement

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
PsiElement restoreElement() {
  PsiFile hostFile = myHostContext.getContainingFile();
  if (hostFile == null || !hostFile.isValid()) return null;

  PsiElement hostContext = myHostContext.getElement();
  if (hostContext == null) return null;

  Segment segment = myInjectedFileRangeInHostFile.getPsiRange();
  if (segment == null) return null;

  PsiFile injectedPsi = getInjectedFileIn(hostContext, hostFile, TextRange.create(segment));
  ProperTextRange rangeInInjected = hostToInjected(true, segment, injectedPsi, myAffixOffsets);
  if (rangeInInjected == null) return null;

  return myType.findPsiElement(injectedPsi, rangeInInjected.getStartOffset(), rangeInInjected.getEndOffset());
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:18,
代码来源:InjectedSelfElementInfo.java

示例19: highlightsOutsideVisiblePartAreProduced

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
public void highlightsOutsideVisiblePartAreProduced(@Nonnull final HighlightingSession session,
                                                    @Nullable Editor editor,
                                                    @Nonnull final List<HighlightInfo> infos,
                                                    @Nonnull final TextRange priorityRange,
                                                    @Nonnull final TextRange restrictedRange, final int groupId) {
  final PsiFile psiFile = session.getPsiFile();
  final Project project = psiFile.getProject();
  final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
  if (document == null) return;
  final long modificationStamp = document.getModificationStamp();
  ((HighlightingSessionImpl)session).applyInEDT(() -> {
    if (project.isDisposed() || modificationStamp != document.getModificationStamp()) return;

    EditorColorsScheme scheme = session.getColorsScheme();

    UpdateHighlightersUtil.setHighlightersOutsideRange(project, document, psiFile, infos, scheme,
                                                       restrictedRange.getStartOffset(), restrictedRange.getEndOffset(),
                                                       ProperTextRange.create(priorityRange),
                                                       groupId);
    if (editor != null) {
      DaemonListeners.repaintErrorStripeRenderer(editor, project);
    }
  });

}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:27,
代码来源:DefaultHighlightInfoProcessor.java

示例20: calcRangeInsideHostElement

点赞 3

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Nonnull
private TextRange calcRangeInsideHostElement(boolean usePsiRange) {
  PsiLanguageInjectionHost host = getHost();
  Segment psiRange = usePsiRange ? relevantRangeInHost.getPsiRange() : relevantRangeInHost.getRange();
  TextRange textRange = psiRange == null ? null : TextRange.create(psiRange);
  if (host == null) {
    if (textRange != null) return textRange;
    Segment fromSP = usePsiRange ? hostElementPointer.getPsiRange() : hostElementPointer.getRange();
    if (fromSP != null) return TextRange.create(fromSP);
    return new TextRange(0, 0);
  }
  TextRange hostTextRange = host.getTextRange();
  textRange = textRange == null ? null : textRange.intersection(hostTextRange);
  if (textRange == null) return new ProperTextRange(0, hostTextRange.getLength());

  return textRange.shiftLeft(hostTextRange.getStartOffset());
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:18,
代码来源:ShredImpl.java

示例21: getParentFromUsage

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
private static PsiElement getParentFromUsage(UsageInfo usage) {
  ProperTextRange range = usage.getRangeInElement();
  assertNotNull(range);
  PsiElement element = usage.getElement();
  assertNotNull(element);
  PsiElement elementAt = element.findElementAt(range.getStartOffset());
  assertNotNull(elementAt);
  return elementAt.getParent();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:10,
代码来源:FindManagerTest.java

示例22: addRangeHighlighter

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
@NotNull
public RangeHighlighter addRangeHighlighter(final int startOffset,
                                            final int endOffset,
                                            final int layer,
                                            final TextAttributes textAttributes,
                                            @NotNull final HighlighterTargetArea targetArea) {
  TextRange hostRange = myDocument.injectedToHost(new ProperTextRange(startOffset, endOffset));
  return myHostModel.addRangeHighlighter(hostRange.getStartOffset(), hostRange.getEndOffset(), layer, textAttributes, targetArea);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:11,
代码来源:MarkupModelWindow.java

示例23: addRangeHighlighterAndChangeAttributes

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@NotNull
@Override
public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset,
                                                                 int endOffset,
                                                                 int layer,
                                                                 TextAttributes textAttributes,
                                                                 @NotNull HighlighterTargetArea targetArea,
                                                                 boolean isPersistent,
                                                                 Consumer<RangeHighlighterEx> changeAttributesAction) {
  TextRange hostRange = myDocument.injectedToHost(new ProperTextRange(startOffset, endOffset));
  return myHostModel.addRangeHighlighterAndChangeAttributes(hostRange.getStartOffset(), hostRange.getEndOffset(), layer, textAttributes,
                                                            targetArea, isPersistent, changeAttributesAction);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:14,
代码来源:MarkupModelWindow.java

示例24: calculateVisibleRange

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@NotNull
public static ProperTextRange calculateVisibleRange(@NotNull Editor editor) {
  Rectangle rect = editor.getScrollingModel().getVisibleArea();
  LogicalPosition startPosition = editor.xyToLogicalPosition(new Point(rect.x, rect.y));

  int visibleStart = editor.logicalPositionToOffset(startPosition);
  LogicalPosition endPosition = editor.xyToLogicalPosition(new Point(rect.x + rect.width, rect.y + rect.height));

  int visibleEnd = editor.logicalPositionToOffset(new LogicalPosition(endPosition.line + 1, 0));

  return new ProperTextRange(visibleStart, Math.max(visibleEnd, visibleStart));
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:13,
代码来源:VisibleHighlightingPassFactory.java

示例25: doPaintTrack

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
protected void doPaintTrack(@NotNull Graphics g, @NotNull JComponent c, @NotNull Rectangle bounds) {
  if (isMacScrollbarHiddenAndXcodeLikeScrollbar()) {
    paintTrackBasement(g, bounds);
    return;
  }
  Rectangle clip = g.getClipBounds().intersection(bounds);
  if (clip.height == 0) return;

  Rectangle componentBounds = c.getBounds();
  ProperTextRange docRange = ProperTextRange.create(0, componentBounds.height);
  if (myCachedTrack == null || myCachedHeight != componentBounds.height) {
    myCachedTrack = UIUtil.createImage(componentBounds.width, componentBounds.height, BufferedImage.TYPE_INT_ARGB);
    myCachedHeight = componentBounds.height;
    myDirtyYPositions = docRange;
    paintTrackBasement(myCachedTrack.getGraphics(), new Rectangle(0, 0, componentBounds.width, componentBounds.height));
  }
  if (myDirtyYPositions == WHOLE_DOCUMENT) {
    myDirtyYPositions = docRange;
  }
  if (myDirtyYPositions != null) {
    final Graphics2D imageGraphics = myCachedTrack.createGraphics();

    ((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();

    try {
      myDirtyYPositions = myDirtyYPositions.intersection(docRange);
      if (myDirtyYPositions == null) myDirtyYPositions = docRange;
      repaint(imageGraphics, componentBounds.width, myDirtyYPositions);
      myDirtyYPositions = null;
    }
    finally {
      ((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish();
    }
  }

  UIUtil.drawImage(g, myCachedTrack, null, 0, 0);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:39,
代码来源:EditorMarkupModelImpl.java

示例26: offsetsToYPositions

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@NotNull
private ProperTextRange offsetsToYPositions(int start, int end) {
  if (!dimensionsAreValid) {
    recalcEditorDimensions();
  }
  Document document = myEditor.getDocument();
  int startLineNumber = end == -1 ? 0 : offsetToLine(start, document);
  int startY;
  int lineCount;
  int editorTargetHeight = Math.max(0, myEditorTargetHeight);
  if (myEditorSourceHeight < editorTargetHeight) {
    lineCount = 0;
    startY = myEditorScrollbarTop + startLineNumber * myEditor.getLineHeight();
  }
  else {
    lineCount = myEditorSourceHeight / myEditor.getLineHeight();
    startY = myEditorScrollbarTop + (int)((float)startLineNumber / lineCount * editorTargetHeight);
  }

  int endY;
  int endLineNumber = offsetToLine(end, document);
  if (end == -1 || start == -1) {
    endY = Math.min(myEditorSourceHeight, editorTargetHeight);
  }
  else if (start == end || offsetToLine(start, document) == endLineNumber) {
    endY = startY; // both offsets are on the same line, no need to recalc Y position
  }
  else {
    if (myEditorSourceHeight < editorTargetHeight) {
      endY = myEditorScrollbarTop + endLineNumber * myEditor.getLineHeight();
    }
    else {
      endY = myEditorScrollbarTop + (int)((float)endLineNumber / lineCount * editorTargetHeight);
    }
  }
  if (endY < startY) endY = startY;
  return new ProperTextRange(startY, endY);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:39,
代码来源:EditorMarkupModelImpl.java

示例27: changedUpdateImpl

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
protected void changedUpdateImpl(@NotNull DocumentEvent e) {
  if (!isValid()) return;

  ProperTextRange newRange = applyChange(e, intervalStart(), intervalEnd(), isGreedyToLeft(), isGreedyToRight());
  if (newRange == null) {
    invalidate(e);
    return;
  }

  setIntervalStart(newRange.getStartOffset());
  setIntervalEnd(newRange.getEndOffset());
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:13,
代码来源:RangeMarkerImpl.java

示例28: changedUpdateImpl

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
protected void changedUpdateImpl(@NotNull DocumentEvent e) {
  if (!isValid()) return;

  Pair<ProperTextRange, LinesCols> pair =
    applyChange(e, this, intervalStart(), intervalEnd(), isGreedyToLeft(), isGreedyToRight(), myLinesCols);
  if (pair == null) {
    invalidate(e);
    return;
  }

  setIntervalStart(pair.first.getStartOffset());
  setIntervalEnd(pair.first.getEndOffset());
  myLinesCols = pair.second;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:16,
代码来源:PersistentRangeMarker.java

示例29: ManualRangeMarker

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
private ManualRangeMarker(@NotNull ProperTextRange range,
                          boolean greedyLeft,
                          boolean greedyRight,
                          @Nullable PersistentRangeMarker.LinesCols linesCols) {
  myRange = range;
  myGreedyLeft = greedyLeft;
  myGreedyRight = greedyRight;
  myLinesCols = linesCols;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:10,
代码来源:ManualRangeMarker.java

示例30: createElementInfo

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@NotNull
private static SmartPointerElementInfo createElementInfo(@NotNull PsiFile containingFile, @NotNull ProperTextRange range, boolean forInjected) {
  Project project = containingFile.getProject();
  if (containingFile.getViewProvider() instanceof FreeThreadedFileViewProvider) {
    PsiLanguageInjectionHost host = InjectedLanguageManager.getInstance(project).getInjectionHost(containingFile);
    if (host != null) {
      SmartPsiElementPointer<PsiLanguageInjectionHost> hostPointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(host);
      return new InjectedSelfElementInfo(project, containingFile, range, containingFile, hostPointer);
    }
  }
  if (range.equals(containingFile.getTextRange())) return new FileElementInfo(containingFile);
  return new SelfElementInfo(project, range, PsiElement.class, containingFile, containingFile.getLanguage(), forInjected);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:14,
代码来源:SmartPsiFileRangePointerImpl.java

示例31: getInjectedRange

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Nullable
private ProperTextRange getInjectedRange(boolean psi) {
  PsiElement hostContext = myHostContext.getElement();
  if (hostContext == null) return null;

  Segment hostElementRange = psi ? myInjectedFileRangeInHostFile.getPsiRange() : myInjectedFileRangeInHostFile.getRange();
  if (hostElementRange == null) return null;

  return hostToInjected(psi, hostElementRange, restoreFile(), myAffixOffsets);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:11,
代码来源:InjectedSelfElementInfo.java

示例32: createHighlightingPass

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@NotNull PsiFile file, @NotNull final Editor editor) {
  TextRange textRange = FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL);
  if (textRange == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(myProject, editor.getDocument());
  ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
  return new InjectedGeneralHighlightingPass(myProject, file, editor.getDocument(), textRange.getStartOffset(), textRange.getEndOffset(), true, visibleRange, editor,
                                             new DefaultHighlightInfoProcessor());
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:10,
代码来源:InjectedGeneralHighlightingPassFactory.java

示例33: createMainHighlightingPass

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
public TextEditorHighlightingPass createMainHighlightingPass(@NotNull PsiFile file,
                                                             @NotNull Document document,
                                                             @NotNull HighlightInfoProcessor highlightInfoProcessor) {
  return new InjectedGeneralHighlightingPass(myProject, file, document, 0, document.getTextLength(), true, new ProperTextRange(0,document.getTextLength()), null,
                                             highlightInfoProcessor);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:8,
代码来源:InjectedGeneralHighlightingPassFactory.java

示例34: highlightsOutsideVisiblePartAreProduced

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
public void highlightsOutsideVisiblePartAreProduced(@NotNull final HighlightingSession session,
                                                    @NotNull final List<HighlightInfo> infos,
                                                    @NotNull final TextRange priorityRange,
                                                    @NotNull final TextRange restrictedRange, final int groupId) {
  final PsiFile psiFile = session.getPsiFile();
  final Project project = psiFile.getProject();
  final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
  if (document == null) return;
  final long modificationStamp = document.getModificationStamp();
  UIUtil.invokeLaterIfNeeded(new Runnable() {
    @Override
    public void run() {
      if (project.isDisposed() || modificationStamp != document.getModificationStamp()) return;

      EditorColorsScheme scheme = session.getColorsScheme();

      UpdateHighlightersUtil.setHighlightersOutsideRange(project, document, psiFile, infos, scheme,
                                                         restrictedRange.getStartOffset(), restrictedRange.getEndOffset(),
                                                         ProperTextRange.create(priorityRange),
                                                         groupId);
      Editor editor = session.getEditor();
      if (editor != null) {
        DaemonListeners.repaintErrorStripeRenderer(editor, project);
      }
    }
  });

}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:30,
代码来源:DefaultHighlightInfoProcessor.java

示例35: createHighlightingPass

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@NotNull PsiFile file, @NotNull final Editor editor) {
  TextRange textRange = FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL);
  if (textRange == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(myProject, editor.getDocument());
  ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
  return new GeneralHighlightingPass(myProject, file, editor.getDocument(), textRange.getStartOffset(), textRange.getEndOffset(), true, visibleRange, editor, new DefaultHighlightInfoProcessor());
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:9,
代码来源:GeneralHighlightingPassFactory.java

示例36: createMainHighlightingPass

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
public TextEditorHighlightingPass createMainHighlightingPass(@NotNull PsiFile file,
                                                             @NotNull Document document,
                                                             @NotNull HighlightInfoProcessor highlightInfoProcessor) {
  // no applying to the editor - for read-only analysis only
  return new GeneralHighlightingPass(myProject, file, document, 0, file.getTextLength(),
                                     true, new ProperTextRange(0, document.getTextLength()), null, highlightInfoProcessor);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:9,
代码来源:GeneralHighlightingPassFactory.java

示例37: serializeMe

点赞 2

import com.intellij.openapi.util.ProperTextRange; //导入依赖的package包/类
@Override
public void serializeMe(UsageInfo info, StringBuilder os) throws IOException {
  //final SmartPsiElementPointer<?> pointer = info.getSmartPointer();
  final GenericElementSignatureProvider provider = new GenericElementSignatureProvider();
  final String signature = provider.getSignature(info.getElement());
  append(os, info.getFile().getVirtualFile().getPath());
  os.append(separator);
  append(os, signature);
  os.append(separator);
  final ProperTextRange rangeInElement = info.getRangeInElement();
  if (rangeInElement == null) {
    append(os, "-1");
    os.append(separator);
    append(os, "-1");
    os.append(separator);
  }
  else {
    append(os, String.valueOf(rangeInElement.getStartOffset()));
    os.append(separator);
    append(os, String.valueOf(rangeInElement.getEndOffset()));
    os.append(separator);
  }
  append(os, String.valueOf(info.isNonCodeUsage()));
  os.append(separator);
  append(os, String.valueOf(info.isDynamicUsage()));
  os.append(separator);
  final String text = new UsageInfo2UsageAdapter(info).getPlainText();
  append(os, text);
  os.append(separator);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:31,
代码来源:UsageSerializable.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)