Java Code Examples for com.intellij.openapi.util.TextRange#areSegmentsEqual()
The following examples show how to use
com.intellij.openapi.util.TextRange#areSegmentsEqual() .
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: PsiMultiReference.java From consulo with Apache License 2.0 | 6 votes |
@Override public int compare(final PsiReference ref1, final PsiReference ref2) { if (ref1.isSoft() && !ref2.isSoft()) return 1; if (!ref1.isSoft() && ref2.isSoft()) return -1; boolean resolves1 = resolves(ref1); boolean resolves2 = resolves(ref2); if (resolves1 && !resolves2) return -1; if (!resolves1 && resolves2) return 1; final TextRange range1 = ref1.getRangeInElement(); final TextRange range2 = ref2.getRangeInElement(); if(TextRange.areSegmentsEqual(range1, range2)) return 0; if(range1.getStartOffset() >= range2.getStartOffset() && range1.getEndOffset() <= range2.getEndOffset()) return -1; if(range2.getStartOffset() >= range1.getStartOffset() && range2.getEndOffset() <= range1.getEndOffset()) return 1; return 0; }
Example 2
Source File: ShredImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PsiLanguageInjectionHost.Shred shred = (PsiLanguageInjectionHost.Shred)o; PsiLanguageInjectionHost host = getHost(); Segment hostRangeMarker = getHostRangeMarker(); Segment hostRangeMarker2 = shred.getHostRangeMarker(); return host != null && host.equals(shred.getHost()) && prefix.equals(shred.getPrefix()) && suffix.equals(shred.getSuffix()) && rangeInDecodedPSI.equals(shred.getRange()) && hostRangeMarker != null && hostRangeMarker2 != null && TextRange.areSegmentsEqual(hostRangeMarker, hostRangeMarker2); }
Example 3
Source File: DocumentFoldingInfo.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DocumentFoldingInfo info = (DocumentFoldingInfo)o; if (myFile != null ? !myFile.equals(info.myFile) : info.myFile != null) { return false; } if (!myProject.equals(info.myProject) || !myInfos.equals(info.myInfos)) { return false; } if (myRangeMarkers.size() != info.myRangeMarkers.size()) return false; for (int i = 0; i < myRangeMarkers.size(); i++) { RangeMarker marker = myRangeMarkers.get(i); RangeMarker other = info.myRangeMarkers.get(i); if (marker == other || !marker.isValid() || !other.isValid()) { continue; } if (!TextRange.areSegmentsEqual(marker, other)) return false; FoldingInfo fi = marker.getUserData(FOLDING_INFO_KEY); FoldingInfo ofi = other.getUserData(FOLDING_INFO_KEY); if (!Comparing.equal(fi, ofi)) return false; } return true; }
Example 4
Source File: SearchResults.java From consulo with Apache License 2.0 | 5 votes |
public boolean isExcluded(FindResult occurrence) { for (RangeMarker rangeMarker : myExcluded) { if (TextRange.areSegmentsEqual(rangeMarker, occurrence)) { return true; } } return false; }
Example 5
Source File: SearchResults.java From consulo with Apache License 2.0 | 5 votes |
public void exclude(FindResult occurrence) { boolean include = false; for (RangeMarker rangeMarker : myExcluded) { if (TextRange.areSegmentsEqual(rangeMarker, occurrence)) { myExcluded.remove(rangeMarker); rangeMarker.dispose(); include = true; break; } } if (!include) { myExcluded.add(myEditor.getDocument().createRangeMarker(occurrence.getStartOffset(), occurrence.getEndOffset(), true)); } notifyChanged(); }
Example 6
Source File: LivePreviewController.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean shouldReplace(TextRange range, String replace) { for (RangeMarker r : mySearchResults.getExcluded()) { if (TextRange.areSegmentsEqual(r, range)) { return false; } } return true; }