Skip to content

Commit

Permalink
Compute field in getter and cache it
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdallo committed Feb 11, 2025
1 parent efb2fa2 commit 507ef5c
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class DocumentSymbolData extends FakePsiElement {
private final @NotNull PsiFile psiFile;
private final DocumentSymbolData parent;
private final @NotNull LanguageServerItem languageServer;
private final @NotNull TextRange textRange;
private TextRange textRange;
private DocumentSymbolData[] cachedChildren;

public DocumentSymbolData(@NotNull DocumentSymbol documentSymbol,
Expand All @@ -54,7 +54,6 @@ public DocumentSymbolData(@NotNull DocumentSymbol documentSymbol,
this.psiFile = psiFile;
this.languageServer = languageServer;
this.parent = parent;
this.textRange = LSPIJUtils.toTextRange(documentSymbol.getRange(), LSPIJUtils.getDocument(psiFile.getVirtualFile()));
}

public @NotNull DocumentSymbol getDocumentSymbol() {
Expand Down Expand Up @@ -83,6 +82,9 @@ public int getTextOffset() {

@Override
public TextRange getTextRange() {
if (textRange == null) {
this.textRange = LSPIJUtils.toTextRange(documentSymbol.getRange(), LSPIJUtils.getDocument(psiFile.getVirtualFile()))
}
return textRange;
}

Expand Down

0 comments on commit 507ef5c

Please sign in to comment.