Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,26 @@
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiInvalidElementAccessException;
import com.intellij.psi.impl.FakePsiElement;
import com.intellij.psi.impl.light.LightElement;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

/**
* Base class for LSP Psi element.
*/
public class LSPPsiElement extends FakePsiElement {
public class LSPPsiElement extends LightElement {

private final @NotNull PsiFile file;

private @NotNull TextRange textRange;
private String name;

public LSPPsiElement(@NotNull PsiFile file,
@NotNull TextRange textRange) {
super(file.getManager(), file.getLanguage());
this.file = file;
setTextRange(textRange);
}
Expand Down Expand Up @@ -72,11 +75,15 @@ public int getTextOffset() {
return textRange.getStartOffset();
}

@Override
public int getTextLength() {
return textRange.getEndOffset() - textRange.getStartOffset();
public @Nullable Icon getIcon(boolean open) {
return null;
}

//@Override
//public int getTextLength() {
// return textRange.getEndOffset() - textRange.getStartOffset();
//}

@Override
public String getName() {
if (name != null) {
Expand All @@ -86,7 +93,7 @@ public String getName() {
return name;
}

@Override
//@Override
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
this.name = name;
return this;
Expand All @@ -102,7 +109,7 @@ public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperatio
return getName();
}

@Override
//@Override
public @NlsSafe @Nullable String getLocationString() {
return file.getName();
}
Expand All @@ -117,4 +124,8 @@ public boolean isValid() {
return true;
}

@Override
public String toString() {
return "";
}
}
Loading