com.intellij.openapi.util.ProperTextRange Java Examples

The following examples show how to use com.intellij.openapi.util.ProperTextRange. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShredImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #2
Source File: InjectedSelfElementInfo.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
PsiElement restoreElement(@Nonnull SmartPointerManagerImpl manager) {
  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());
}
 
Example #3
Source File: TypedHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Editor injectedEditorIfCharTypedIsSignificant(final int charTyped, @Nonnull Editor editor, @Nonnull PsiFile oldFile) {
  int offset = editor.getCaretModel().getOffset();
  // even for uncommitted document try to retrieve injected fragment that has been there recently
  // we are assuming here that when user is (even furiously) typing, injected language would not change
  // and thus we can use its lexer to insert closing braces etc
  List<DocumentWindow> injected = InjectedLanguageManager.getInstance(oldFile.getProject()).getCachedInjectedDocumentsInRange(oldFile, ProperTextRange.create(offset, offset));
  for (DocumentWindow documentWindow : injected) {
    if (documentWindow.isValid() && documentWindow.containsRange(offset, offset)) {
      PsiFile injectedFile = PsiDocumentManager.getInstance(oldFile.getProject()).getPsiFile(documentWindow);
      if (injectedFile != null) {
        Editor injectedEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injectedFile);
        // IDEA-52375/WEB-9105 fix: last quote in editable fragment should be handled by outer language quote handler
        TextRange hostRange = documentWindow.getHostRange(offset);
        CharSequence sequence = editor.getDocument().getCharsSequence();
        if (sequence.length() > offset && charTyped != Character.codePointAt(sequence, offset) || hostRange != null && hostRange.contains(offset)) {
          return injectedEditor;
        }
      }
    }
  }

  return editor;
}
 
Example #4
Source File: DesktopEditorMarkupModelImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
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;
    }
  });
}
 
Example #5
Source File: DefaultHighlightInfoProcessor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void highlightsOutsideVisiblePartAreProduced(@Nonnull final HighlightingSession session,
                                                    @Nullable Editor editor,
                                                    @Nonnull final List<? extends 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) {
      repaintErrorStripeAndIcon(editor, project);
    }
  });
}
 
Example #6
Source File: DesktopEditorErrorPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void markDirtied(@Nonnull ProperTextRange yPositions) {
  ProperTextRange dirtyYPositions = getUI().getDirtyYPositions();

  if (dirtyYPositions != DesktopEditorErrorPanelUI.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));

    getUI().setDirtyYPositions(dirtyYPositions == null ? adj : dirtyYPositions.union(adj));
  }

  myEditorScrollbarTop = 0;
  myEditorSourceHeight = 0;
  myEditorTargetHeight = 0;
  dimensionsAreValid = false;
}
 
Example #7
Source File: ChameleonSyntaxHighlightingPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
private ChameleonSyntaxHighlightingPass(@Nonnull Project project,
                                        @Nonnull PsiFile file,
                                        @Nonnull Document document,
                                        @Nonnull ProperTextRange restrictRange,
                                        @Nonnull ProperTextRange priorityRange,
                                        @Nullable Editor editor,
                                        @Nonnull HighlightInfoProcessor highlightInfoProcessor) {
  super(project, file, document, restrictRange.getStartOffset(), restrictRange.getEndOffset(), true, priorityRange, editor, highlightInfoProcessor);
}
 
Example #8
Source File: SmartPointerManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public SmartPsiFileRange createSmartPsiFileRangePointer(@Nonnull PsiFile file, @Nonnull TextRange range, boolean forInjected) {
  PsiUtilCore.ensureValid(file);
  SmartPointerTracker.processQueue();
  SmartPsiFileRangePointerImpl pointer = new SmartPsiFileRangePointerImpl(this, file, ProperTextRange.create(range), forInjected);
  trackPointer(pointer, file.getViewProvider().getVirtualFile());

  return pointer;
}
 
Example #9
Source File: MarkerCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
static Segment getUpdatedRange(@Nonnull PsiFile containingFile, @Nonnull Segment segment, boolean isSegmentGreedy, @Nonnull FrozenDocument frozen, @Nonnull List<? extends DocumentEvent> events) {
  SelfElementInfo info = new SelfElementInfo(ProperTextRange.create(segment), new Identikit() {
    @Nullable
    @Override
    public PsiElement findPsiElement(@Nonnull PsiFile file, int startOffset, int endOffset) {
      return null;
    }

    @Nonnull
    @Override
    public Language getFileLanguage() {
      throw new IllegalStateException();
    }

    @Override
    public boolean isForPsiFile() {
      return false;
    }
  }, containingFile, isSegmentGreedy);
  List<SelfElementInfo> infos = Collections.singletonList(info);

  boolean greedy = info.isGreedy();
  int start = info.getPsiStartOffset();
  int end = info.getPsiEndOffset();
  boolean surviveOnExternalChange = events.stream().anyMatch(event -> isWholeDocumentReplace(frozen, (DocumentEventImpl)event));
  ManualRangeMarker marker = new ManualRangeMarker(start, end, greedy, greedy, surviveOnExternalChange, null);

  UpdatedRanges ranges = new UpdatedRanges(0, frozen, infos, new ManualRangeMarker[]{marker});
  // NB: convert events from completion to whole doc change event to more precise translation
  List<DocumentEvent> newEvents = ContainerUtil.map(events, event -> isWholeDocumentReplace(frozen, (DocumentEventImpl)event)
                                                                     ? new DocumentEventImpl(event.getDocument(), event.getOffset(), event.getOldFragment(), event.getNewFragment(), event.getOldTimeStamp(), true,
                                                                                             ((DocumentEventImpl)event).getInitialStartOffset(), ((DocumentEventImpl)event).getInitialOldLength()) : event);
  UpdatedRanges updated = applyEvents(newEvents, ranges);
  return updated.myMarkers[0];
}
 
Example #10
Source File: InjectedSelfElementInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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((SmartPointerManagerImpl)SmartPointerManager.getInstance(getProject())), myAffixOffsets);
}
 
Example #11
Source File: ChangedPsiRangeUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
static ProperTextRange getChangedPsiRange(@Nonnull PsiFile file, @Nonnull Document document, @Nonnull CharSequence oldDocumentText, @Nonnull CharSequence newDocumentText) {
  int psiLength = oldDocumentText.length();
  if (!file.getViewProvider().supportsIncrementalReparse(file.getLanguage())) {
    return new ProperTextRange(0, psiLength);
  }
  List<DocumentEvent> events = ((PsiDocumentManagerBase)PsiDocumentManager.getInstance(file.getProject())).getEventsSinceCommit(document);
  int prefix = Integer.MAX_VALUE;
  int suffix = Integer.MAX_VALUE;
  int lengthBeforeEvent = psiLength;
  for (DocumentEvent event : events) {
    prefix = Math.min(prefix, event.getOffset());
    suffix = Math.min(suffix, lengthBeforeEvent - event.getOffset() - event.getOldLength());
    lengthBeforeEvent = lengthBeforeEvent - event.getOldLength() + event.getNewLength();
  }
  if ((prefix == psiLength || suffix == psiLength) && newDocumentText.length() == psiLength) {
    return null;
  }
  //Important! delete+insert sequence can give some of same chars back, lets grow affixes to include them.
  int shortestLength = Math.min(psiLength, newDocumentText.length());
  while (prefix < shortestLength && oldDocumentText.charAt(prefix) == newDocumentText.charAt(prefix)) {
    prefix++;
  }
  while (suffix < shortestLength - prefix && oldDocumentText.charAt(psiLength - suffix - 1) == newDocumentText.charAt(newDocumentText.length() - suffix - 1)) {
    suffix++;
  }
  int end = Math.max(prefix, psiLength - suffix);
  if (end == prefix && newDocumentText.length() == oldDocumentText.length()) return null;
  return ProperTextRange.create(prefix, end);
}
 
Example #12
Source File: BashEnhancedLiteralTextEscaper.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
protected boolean decodeText(String content, @NotNull TextRange rangeInsideHost, @NotNull StringBuilder outChars) {
    ProperTextRange.assertProperRange(rangeInsideHost);

    Ref<int[]> sourceOffsetsRef = new Ref<int[]>();
    boolean result = TextProcessorUtil.enhancedParseStringCharacters(content, outChars, sourceOffsetsRef);
    this.outSourceOffsets = sourceOffsetsRef.get();

    return result;
}
 
Example #13
Source File: InjectedGeneralHighlightingPassFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public TextEditorHighlightingPass createMainHighlightingPass(@Nonnull PsiFile file,
                                                             @Nonnull Document document,
                                                             @Nonnull HighlightInfoProcessor highlightInfoProcessor) {
  Project project = file.getProject();
  return new InjectedGeneralHighlightingPass(project, file, document, 0, document.getTextLength(), true, new ProperTextRange(0,document.getTextLength()), null,
                                             highlightInfoProcessor);
}
 
Example #14
Source File: ChameleonSyntaxHighlightingPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public TextEditorHighlightingPass createHighlightingPass(@Nonnull PsiFile file, @Nonnull Editor editor) {
  Project project = file.getProject();
  TextRange restrict = FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL);
  if (restrict == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(project, editor.getDocument());
  ProperTextRange priority = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
  return new ChameleonSyntaxHighlightingPass(project, file, editor.getDocument(), ProperTextRange.create(restrict), priority, editor, new DefaultHighlightInfoProcessor());
}
 
Example #15
Source File: InjectedGeneralHighlightingPassFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@Nonnull PsiFile file, @Nonnull final Editor editor) {
  Project project = file.getProject();
  TextRange textRange = FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL);
  if (textRange == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(project, editor.getDocument());
  ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
  return new InjectedGeneralHighlightingPass(project, file, editor.getDocument(), textRange.getStartOffset(), textRange.getEndOffset(), true, visibleRange, editor,
                                             new DefaultHighlightInfoProcessor());
}
 
Example #16
Source File: LineMarkersPassFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@Nonnull PsiFile file, @Nonnull final Editor editor) {
  TextRange restrictRange = FileStatusMap.getDirtyTextRange(editor, Pass.LINE_MARKERS);
  Document document = editor.getDocument();
  if (restrictRange == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(file.getProject(), document);
  ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
  return new LineMarkersPass(file.getProject(), file, document, expandRangeToCoverWholeLines(document, visibleRange), expandRangeToCoverWholeLines(document, restrictRange));
}
 
Example #17
Source File: GeneralHighlightingPassFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@Nonnull PsiFile file, @Nonnull final Editor editor) {
  TextRange textRange = FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL);
  if (textRange == null) return new EmptyPass(file.getProject(), editor.getDocument());
  ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
  return new GeneralHighlightingPass(file.getProject(), file, editor.getDocument(), textRange.getStartOffset(), textRange.getEndOffset(), true, visibleRange, editor, new DefaultHighlightInfoProcessor());
}
 
Example #18
Source File: VisibleHighlightingPassFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ProperTextRange calculateVisibleRange(@Nonnull 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));
}
 
Example #19
Source File: InjectedGeneralHighlightingPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
InjectedGeneralHighlightingPass(@Nonnull Project project,
                                @Nonnull PsiFile file,
                                @Nonnull Document document,
                                int startOffset,
                                int endOffset,
                                boolean updateAll,
                                @Nonnull ProperTextRange priorityRange,
                                @Nullable Editor editor,
                                @Nonnull HighlightInfoProcessor highlightInfoProcessor) {
  super(project, file, document, startOffset, endOffset, updateAll, priorityRange, editor, highlightInfoProcessor);
}
 
Example #20
Source File: InjectedGeneralHighlightingPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * finds the first nearest text range
 * @param documentWindow
 * @param startOffset
 * @return null means invalid
 */
@Nullable
private static TextRange findNearestTextRange(final DocumentWindow documentWindow, final int startOffset) {
  TextRange textRange = null;
  for (Segment marker : documentWindow.getHostRanges()) {
    TextRange curRange = ProperTextRange.create(marker);
    if (curRange.getStartOffset() > startOffset && textRange != null) break;
    textRange = curRange;
  }
  return textRange;
}
 
Example #21
Source File: TemplateManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static OffsetsInFile insertDummyIdentifierWithCache(PsiFile file, int startOffset, int endOffset, String replacement) {
  ProperTextRange editRange = ProperTextRange.create(startOffset, endOffset);
  assertRangeWithinDocument(editRange, file.getViewProvider().getDocument());

  ConcurrentMap<Pair<ProperTextRange, String>, OffsetsInFile> map = CachedValuesManager.getCachedValue(file, () -> CachedValueProvider.Result
          .create(ConcurrentFactoryMap.createMap(key -> copyWithDummyIdentifier(new OffsetsInFile(file), key.first.getStartOffset(), key.first.getEndOffset(), key.second)), file,
                  file.getViewProvider().getDocument()));
  return map.get(Pair.create(editRange, replacement));
}
 
Example #22
Source File: UsageSerializable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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.getElement().getContainingFile().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);
}
 
Example #23
Source File: MoveDirectoryWithClassesHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public PsiReference getReference() {
  PsiElement element = getElement();
  if (element == null) {
    return null;
  }
  else {
    final ProperTextRange rangeInElement = getRangeInElement();
    return rangeInElement != null ? element.findReferenceAt(rangeInElement.getStartOffset()) : element.getReference();
  }
}
 
Example #24
Source File: SmartPsiFileRangePointerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static SmartPointerElementInfo createElementInfo(@Nonnull PsiFile containingFile, @Nonnull 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 (!forInjected && range.equals(containingFile.getTextRange())) return new FileElementInfo(containingFile);
  return new SelfElementInfo(range, Identikit.fromTypes(PsiElement.class, null, Language.ANY), containingFile, forInjected);
}
 
Example #25
Source File: CSharpStringLiteralEscaper.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
public boolean decode(@Nonnull final TextRange rangeInsideHost, @Nonnull StringBuilder outChars)
{
	ProperTextRange.assertProperRange(rangeInsideHost);
	String subText = rangeInsideHost.substring(myHost.getText());
	myOutSourceOffsets = new int[subText.length() + 1];
	return parseStringCharacters(subText, outChars, myOutSourceOffsets);
}
 
Example #26
Source File: MarkupModelWindow.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset,
                                                                 int endOffset,
                                                                 int layer,
                                                                 TextAttributes textAttributes,
                                                                 @Nonnull HighlighterTargetArea targetArea,
                                                                 boolean isPersistent,
                                                                 Consumer<? super RangeHighlighterEx> changeAttributesAction) {
  TextRange hostRange = myDocument.injectedToHost(new ProperTextRange(startOffset, endOffset));
  return myHostModel.addRangeHighlighterAndChangeAttributes(hostRange.getStartOffset(), hostRange.getEndOffset(), layer, textAttributes, targetArea, isPersistent, changeAttributesAction);
}
 
Example #27
Source File: HeredocLiteralEscaper.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@Override
public boolean decode(@NotNull final TextRange rangeInsideHost, @NotNull StringBuilder outChars) {
    ProperTextRange.assertProperRange(rangeInsideHost);

    outChars.append(rangeInsideHost.substring(myHost.getText()));

    return true;
}
 
Example #28
Source File: DesktopEditorErrorPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void repaint(int startOffset, int endOffset) {
  ProperTextRange range = offsetsToYPositions(startOffset, endOffset);
  markDirtied(range);
  if (startOffset == -1 || endOffset == -1) {
    getUI().setDirtyYPositions(DesktopEditorErrorPanelUI.WHOLE_DOCUMENT);
  }

  if (isVisible()) {
    repaint(0, range.getStartOffset(), getWidth(), range.getLength() + myMarkupModel.getMinMarkHeight());
  }
}
 
Example #29
Source File: BashIdentityStringLiteralEscaper.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@Override
public boolean decode(@NotNull final TextRange rangeInsideHost, @NotNull StringBuilder outChars) {
    ProperTextRange.assertProperRange(rangeInsideHost);

    outChars.append(rangeInsideHost.substring(myHost.getText()));

    return true;
}
 
Example #30
Source File: BashSimpleTextLiteralEscaper.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@Override
public boolean decode(@NotNull final TextRange rangeInsideHost, @NotNull StringBuilder outChars) {
    ProperTextRange.assertProperRange(rangeInsideHost);
    String subText = rangeInsideHost.substring(myHost.getText());

    Ref<int[]> sourceOffsetsRef = new Ref<int[]>();
    boolean result = TextProcessorUtil.parseStringCharacters(subText, outChars, sourceOffsetsRef);
    this.outSourceOffsets = sourceOffsetsRef.get();

    return result;
}