FileStatus (@NotNull PsiElement element) { if (!element.isValid()) return FileStatus.NOT_CHANGED; PsiFile file = element.getContainingFile(); if (file == null) return FileStatus.NOT_CHANGED; Document document = file.getViewProvider().getDocument(); LineStatusTracker<?> tracker = LineStatusTrackerManager.getInstance(myProject).getLineStatusTracker(document); if (tracker == null) return FileStatus.NOT_CHANGED; TextRange range = element.getTextRange(); if (range == null || range.getEndOffset() > document.getTextLength()) return FileStatus.NOT_CHANGED; int start = document.getLineNumber(range.getStartOffset()); int end = document.getLineNumber(range.getEndOffset()); BitSet set = new BitSet(); set.set(start, end + 1); List<? extends Range> ranges = tracker.getRangesForLines(set); if (ranges == null || ranges.isEmpty()) return FileStatus.NOT_CHANGED; if (ranges.size() == 1) { Range r = ranges.get(0); if (r.getType() == Range.INSERTED && r.getLine1() <= start && r.getLine2() > end) { return FileStatus.ADDED; } } return FileStatus.MODIFIED; }