mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extend ShSupport with variable references
fixed #1149 GitOrigin-RevId: 26788bc196b4f1192210dbb4a3f4e73abff81485
This commit is contained in:
committed by
intellij-monorepo-bot
parent
21abe24df3
commit
869ffd1460
@@ -4,10 +4,14 @@ package com.intellij.sh.psi;
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
|
||||
public interface ShVariable extends ShLiteral {
|
||||
|
||||
@NotNull
|
||||
PsiElement getVar();
|
||||
|
||||
@NotNull
|
||||
PsiReference[] getReferences();
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import static com.intellij.sh.ShTypes.*;
|
||||
import com.intellij.sh.psi.*;
|
||||
import com.intellij.psi.PsiReference;
|
||||
|
||||
public class ShVariableImpl extends ShLiteralImpl implements ShVariable {
|
||||
|
||||
@@ -31,4 +32,10 @@ public class ShVariableImpl extends ShLiteralImpl implements ShVariable {
|
||||
return findNotNullChildByType(VAR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiReference[] getReferences() {
|
||||
return ShPsiImplUtil.getReferences(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -298,7 +298,10 @@ literal ::= word | string | number | variable {
|
||||
}
|
||||
private not_lvalue ::= '!' | vars | '$' | brace_expansion | 'file descriptor'
|
||||
brace_expansion ::= '{' (word | brace_expansion)* '}'
|
||||
variable ::= var {extends=literal}
|
||||
variable ::= var {
|
||||
methods=[getReferences]
|
||||
extends=literal
|
||||
}
|
||||
|
||||
number ::= int | hex | octal {extends=literal}
|
||||
string ::= (OPEN_QUOTE (STRING_CONTENT | vars | <<notQuote>>)* CLOSE_QUOTE) | RAW_STRING {
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.sh.psi.ShVariable;
|
||||
import com.intellij.sh.run.ShRunConfiguration;
|
||||
import com.intellij.sh.run.ShRunConfigurationProfileState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -21,6 +23,10 @@ public interface ShSupport {
|
||||
@NotNull ExecutionEnvironment environment,
|
||||
@NotNull ShRunConfiguration configuration);
|
||||
|
||||
@NotNull
|
||||
PsiReference[] getVariableReferences(@NotNull ShVariable v);
|
||||
|
||||
|
||||
class Impl implements ShSupport {
|
||||
@Override
|
||||
public boolean isExternalFormatterEnabled() { return true; }
|
||||
@@ -35,5 +41,11 @@ public interface ShSupport {
|
||||
@NotNull ShRunConfiguration configuration) {
|
||||
return new ShRunConfigurationProfileState(environment.getProject(), configuration);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiReference[] getVariableReferences(@NotNull ShVariable v) {
|
||||
return PsiReference.EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,10 @@ package com.intellij.sh.psi.impl;
|
||||
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
|
||||
import com.intellij.sh.ShSupport;
|
||||
import com.intellij.sh.psi.ShLiteral;
|
||||
import com.intellij.sh.psi.ShString;
|
||||
import com.intellij.sh.psi.ShVariable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ShPsiImplUtil {
|
||||
@@ -14,4 +16,9 @@ public class ShPsiImplUtil {
|
||||
? ReferenceProvidersRegistry.getReferencesFromProviders(o)
|
||||
: PsiReference.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static PsiReference[] getReferences(@NotNull ShVariable o) {
|
||||
return ShSupport.getInstance().getVariableReferences(o);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user