IDEA-173600 Provide public API to get changed document lines

This commit is contained in:
peter
2017-05-30 20:10:36 +02:00
parent 592e9012e5
commit 4ac53a4d01
3 changed files with 18 additions and 0 deletions
@@ -141,6 +141,13 @@ public interface Document extends UserDataHolder {
@Contract(pure=true)
int getLineEndOffset(int line);
/**
* @return whether the line with the given index has been modified since the document has been saved
*/
default boolean isLineModified(int line) {
return false;
}
/**
* Inserts the specified text at the specified offset in the document. Line breaks in
* the inserted text must be normalized as \n.
@@ -180,6 +180,12 @@ public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
return stripTrailingSpaces(project, inChangedLinesOnly, true, new int[0]);
}
@Override
public boolean isLineModified(int line) {
LineSet lineSet = myLineSet;
return lineSet != null && lineSet.isModified(line);
}
/**
* @return true if stripping was completed successfully, false if the document prevented stripping by e.g. caret(s) being in the way
*/
@@ -518,6 +518,11 @@ public class DocumentWindowImpl extends UserDataHolderBase implements Disposable
}
}
@Override
public boolean isLineModified(int line) {
return myDelegate.isLineModified(injectedToHostLine(line));
}
@Override
@NotNull
public Segment[] getHostRanges() {