@@ -425,12 +425,14 @@ public void paint(@NotNull Editor editor, @NotNull RangeHighlighter highlighter,
425
425
private final Document myDocument ;
426
426
private final Project myProject ;
427
427
private final VirtualFile myFile ;
428
+ private final boolean convertOffsets ;
428
429
429
- WidgetIndentsHighlightingPass (@ NotNull Project project , @ NotNull EditorEx editor ) {
430
+ WidgetIndentsHighlightingPass (@ NotNull Project project , @ NotNull EditorEx editor , boolean convertOffsets ) {
430
431
this .myDocument = editor .getDocument ();
431
432
this .myEditor = editor ;
432
433
this .myProject = project ;
433
434
this .myFile = editor .getVirtualFile ();
435
+ this .convertOffsets = convertOffsets ;
434
436
}
435
437
436
438
private static void drawVerticalLineHelper (
@@ -524,8 +526,8 @@ public static void cleanupHighlighters(Editor editor) {
524
526
setIndentsPassData (editor , null );
525
527
}
526
528
527
- public static void run (@ NotNull Project project , @ NotNull EditorEx editor , @ NotNull FlutterOutline outline ) {
528
- final WidgetIndentsHighlightingPass widgetIndentsHighlightingPass = new WidgetIndentsHighlightingPass (project , editor );
529
+ public static void run (@ NotNull Project project , @ NotNull EditorEx editor , @ NotNull FlutterOutline outline , boolean convertOffsets ) {
530
+ final WidgetIndentsHighlightingPass widgetIndentsHighlightingPass = new WidgetIndentsHighlightingPass (project , editor , convertOffsets );
529
531
widgetIndentsHighlightingPass .setOutline (outline );
530
532
}
531
533
@@ -671,10 +673,28 @@ DartAnalysisServerService getAnalysisService() {
671
673
return DartAnalysisServerService .getInstance (myProject );
672
674
}
673
675
676
+ /**
677
+ * All calls to convert offsets for indent highlighting must go through this
678
+ * method.
679
+ *
680
+ * Sometimes we need to use the raw offsets and sometimes we need
681
+ * to use the converted offsets depending on whether the FlutterOutline
682
+ * matches the current document or the expectations given by the
683
+ * @param node
684
+ * @return
685
+ */
686
+ int getConvertedOffset (FlutterOutline node ) {
687
+ return getConvertedOffset (node .getOffset ());
688
+ }
689
+
690
+ int getConvertedOffset (int offset ) {
691
+ return convertOffsets ? getAnalysisService ().getConvertedOffset (myFile , offset ) : offset ;
692
+ }
693
+
674
694
private OutlineLocation computeLocation (FlutterOutline node ) {
675
695
assert (myDocument != null );
676
696
final int documentLength = myDocument .getTextLength ();
677
- final int rawOffset = getAnalysisService (). getConvertedOffset (myFile , node . getOffset () );
697
+ final int rawOffset = getConvertedOffset (node );
678
698
final int nodeOffset = min (rawOffset , documentLength );
679
699
final int line = myDocument .getLineNumber (nodeOffset );
680
700
final int lineStartOffset = myDocument .getLineStartOffset (line );
@@ -692,7 +712,7 @@ private OutlineLocation computeLocation(FlutterOutline node) {
692
712
}
693
713
}
694
714
695
- return new OutlineLocation (node , line , column , indent , myFile , getAnalysisService () );
715
+ return new OutlineLocation (node , line , column , indent , myFile , this );
696
716
}
697
717
698
718
private void buildWidgetDescriptors (
0 commit comments