is there a way to know that a PsiLiteralExpression is on a modified line ?

Hi all,

I build my own LocalInspectionTool that is working great.

In fact it found so much problems that i often have a file with a lot of yellow highlighting in the code.

My idea : 
add an option to my plugin to choose if i want this inspection to work like today, or to only analyse modified lines.

that way if I plan to fix a full file i configure it like it is currently

but if i have no time to fix other coworkoer classes I can configure it to only check my modifications

Is this possible to do ? 
If yes what should I add to my javaElementVisitor ?


 

 

Thanks in advance for your help.

 

Alain

评论操作 固定链接

hum i got a solution but not sure if it is the best one

 

i'm doing something like this

LineStatusTracker lineStatusTracker = LineStatusTrackerManager.getInstance(this.project).getLineStatusTracker(virtualFile);
List<Range> ranges = lineStatusTracker == null ? Collections.emptyList() : lineStatusTracker.getRanges();
this.linesToCheck = ranges == null ? Collections.emptyList() : ranges.stream().map(Range::getLine1).collect(Collectors.toList());
int textOffset = psiElement.getTextOffset();
int lineNumber = StringUtil.offsetToLineNumber(psiElement.getContainingFile().getText(), textOffset);

then I simply check if my lineNumber is in the linkesToCheck array
it is working, but I don't know if this is the best option

 

0

请先登录再写评论。