本文整理汇总了Java中com.intellij.lang.javascript.psi.JSReferenceExpression类的典型用法代码示例。如果您正苦于以下问题:Java JSReferenceExpression类的具体用法?Java JSReferenceExpression怎么用?Java JSReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSReferenceExpression类属于com.intellij.lang.javascript.psi包,在下文中一共展示了JSReferenceExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkPsiElement
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
/**
* @param psiElement checking element
* @return true if this is process.env.*** variable
*/
public static boolean checkPsiElement(@NotNull PsiElement psiElement) {
if(!(psiElement instanceof LeafPsiElement)) {
return false;
}
IElementType elementType = ((LeafPsiElement) psiElement).getElementType();
if(!elementType.toString().equals("JS:IDENTIFIER")) {
return false;
}
PsiElement parent = psiElement.getParent();
if(!(parent instanceof JSReferenceExpression)) {
return false;
}
return ((JSReferenceExpression) parent).getCanonicalText().startsWith("process.env");
}
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:22,代码来源:JsPsiHelper.java
示例2: getElementByReference
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@Nullable
@Override
public PsiElement getElementByReference(@NotNull PsiReference ref, int flags) {
if (ref instanceof JSTextReference) {
final PsiElement element = ref.getElement();
final JSCallExpression call = PsiTreeUtil.getParentOfType(element, JSCallExpression.class);
final JSExpression expression = call != null ? call.getMethodExpression() : null;
if (expression instanceof JSReferenceExpression) {
JSReferenceExpression callee = (JSReferenceExpression)expression;
JSExpression qualifier = callee.getQualifier();
if (qualifier != null && "component".equals(callee.getReferencedName()) &&
EmberIndexUtil.hasEmberJS(element.getProject())) {
return element;
}
}
}
return null;
}
开发者ID:kristianmandrup,项目名称:emberjs-plugin,代码行数:20,代码来源:EmberJSTargetElementEvaluator.java
示例3: elementIsAttachPoint
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
public static boolean elementIsAttachPoint(PsiElement element)
{
/*
It's hard to detect when an element is an attach point, because of the use of this inside other functions
this.attachpoint
that.attachpoint
ideally we would parse the template file in the beginning and cache all of the attach points,
maybe that's a todo item...
*/
if(element == null || element.getParent() == null || !(element.getParent() instanceof JSReferenceExpression))
{
return false;
}
// we can exclude JSCallExpressions at least because you will never reference an attach point like
// this.attachpoint(...)
if(element.getParent().getParent() instanceof JSCallExpression)
{
return false;
}
return true;
}
开发者ID:cefolger,项目名称:needsmoredojo,代码行数:26,代码来源:AMDValidator.java
示例4: isDefineFirstCollection
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
public boolean isDefineFirstCollection(PsiElement element) {
PsiElement jsArrayLiteral = element.getParent();
if (null != jsArrayLiteral && jsArrayLiteral instanceof JSArrayLiteralExpression) {
PsiElement jsArgumentList = jsArrayLiteral.getParent();
if (null != jsArgumentList && jsArgumentList instanceof JSArgumentList) {
PsiElement jsReferenceExpression = jsArgumentList.getPrevSibling();
if (null != jsReferenceExpression && jsReferenceExpression instanceof JSReferenceExpression) {
if (jsReferenceExpression.getText().equals(Settings.REQUIREJS_DEFINE_FUNCTION_NAME)) {
return true;
}
}
}
}
return false;
}
开发者ID:Fedott,项目名称:WebStormRequireJsPlugin,代码行数:17,代码来源:RequirejsPsiReferenceProvider.java
示例5: getName
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@Override
public String getName()
{
final T stub = getStub();
if(stub != null)
{
return stub.getName();
}
final PsiElement name = getNameIdentifier();
if(name != null)
{
if(name instanceof JSReferenceExpression)
{
return ((JSReferenceExpression) name).getReferencedName();
}
}
return name != null ? name.getText() : "";
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:20,代码来源:JSVariableBaseImpl.java
示例6: getReferenceTexts
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@NotNull
@Override
@RequiredReadAction
public String[] getReferenceTexts()
{
final JSReferenceListStub stub = getStub();
if(stub != null)
{
return stub.getReferenceTexts();
}
final JSReferenceExpression[] referenceExpressions = getExpressions();
if(referenceExpressions.length == 0)
{
return ArrayUtil.EMPTY_STRING_ARRAY;
}
int count = referenceExpressions.length;
final String[] result = ArrayUtil.newStringArray(count);
for(int i = 0; i < count; ++i)
{
result[i] = referenceExpressions[i].getText();
}
return result;
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:26,代码来源:JSReferenceListImpl.java
示例7: getName
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@Override
@RequiredReadAction
public String getName()
{
final JSClassStub classStub = getStub();
if(classStub != null)
{
return classStub.getName();
}
PsiElement nameIdentifier = getNameIdentifier();
if(nameIdentifier instanceof JSReferenceExpression)
{
return ((JSReferenceExpression) nameIdentifier).getReferencedName();
}
else if(nameIdentifier != null)
{
return nameIdentifier.getText();
}
return null;
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:22,代码来源:JSClassImpl.java
示例8: getType
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@RequiredReadAction
@NotNull
@Override
public JavaScriptType getType()
{
JSExpression methodExpression = getMethodExpression();
if(methodExpression instanceof JSReferenceExpression)
{
PsiElement resolvedElement = ((JSReferenceExpression) methodExpression).resolve();
if(resolvedElement instanceof JSClass)
{
return new JavaScriptClassType((JSClass) resolvedElement);
}
}
return super.getType();
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:18,代码来源:JSNewExpressionImpl.java
示例9: isReferenceTo
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@Override
@RequiredReadAction
public boolean isReferenceTo(PsiElement element)
{
final PsiElement element2 = resolve();
boolean proxyExpanded = false;
if(element instanceof JSDefinitionExpression)
{
final JSExpression expression = ((JSDefinitionExpression) element).getExpression();
if(expression instanceof JSReferenceExpression)
{
return ((JSReferenceExpression) expression).isReferenceTo(element2);
}
}
if(element != element2 && element instanceof JSProperty && element2 instanceof JSProperty)
{
return ((JSProperty) element).getName().equals(((JSProperty) element2).getName());
}
return proxyExpanded && element == element2;
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:23,代码来源:JSPropertyNameReference.java
示例10: getName
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@Override
@RequiredReadAction
public String getName()
{
final JSFunctionStub stub = getStub();
if(stub != null)
{
return stub.getName();
}
final PsiElement name = getNameIdentifier();
if(name != null)
{
if(name instanceof JSReferenceExpression)
{
return ((JSReferenceExpression) name).getReferencedName();
}
else
{
return name.getText();
}
}
return null;
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:25,代码来源:JSFunctionBaseImpl.java
示例11: findExpressionInRange
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
private static JSExpression findExpressionInRange(PsiFile file, int startOffset, int endOffset)
{
PsiElement element1 = file.findElementAt(startOffset);
PsiElement element2 = file.findElementAt(endOffset - 1);
if(element1 instanceof PsiWhiteSpace)
{
startOffset = element1.getTextRange().getEndOffset();
}
if(element2 instanceof PsiWhiteSpace)
{
endOffset = element2.getTextRange().getStartOffset();
}
JSExpression expression = PsiTreeUtil.findElementOfClassAtRange(file, startOffset, endOffset, JSExpression.class);
if(expression == null || expression.getTextRange().getEndOffset() != endOffset)
{
return null;
}
if(expression instanceof JSReferenceExpression && expression.getParent() instanceof JSCallExpression)
{
return null;
}
return expression;
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:24,代码来源:JSExpressionSurroundDescriptor.java
示例12: createVisitor
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@Override
protected JSElementVisitor createVisitor(final ProblemsHolder holder)
{
return new JSElementVisitor()
{
@Override
public void visitJSReferenceExpression(final JSReferenceExpression node)
{
for(ResolveResult r : node.multiResolve(false))
{
final PsiElement element = r.getElement();
if((element instanceof JSDefinitionExpression && element.getParent() instanceof JSAssignmentExpression) || element == node.getParent())
{
continue;
}
if(JSDocumentationUtils.isDeprecated(element))
{
holder.registerProblem(node.getReferenceNameElement(), JavaScriptBundle.message("javascript.deprecated.symbol.used.name.message"),
ProblemHighlightType.LIKE_DEPRECATED);
break;
}
}
}
};
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:26,代码来源:JSDeprecatedSymbolsInspection.java
示例13: visitJSCallExpression
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@Override public void visitJSCallExpression(JSCallExpression jsCallExpression) {
super.visitJSCallExpression(jsCallExpression);
final JSExpression methodExpression;
try {
methodExpression = jsCallExpression.getMethodExpression();
} catch (Exception e) {
return; //catching an intelliJ CCE
}
if (!(methodExpression instanceof JSReferenceExpression)) {
return;
}
final JSReferenceExpression referenceExpression = (JSReferenceExpression) methodExpression;
final JSExpression qualifier = referenceExpression.getQualifier();
@NonNls final String methodName = referenceExpression.getReferencedName();
if (!"eval".equals(methodName) && !"setTimeout".equals(methodName) && !"setInterval".equals(methodName)) {
return;
}
registerError(methodExpression);
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:21,代码来源:DynamicallyGeneratedCodeJSInspection.java
示例14: visitJSNewExpression
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@Override public void visitJSNewExpression(JSNewExpression jsNewExpression) {
super.visitJSNewExpression(
jsNewExpression);
final JSExpression methodExpression;
try {
methodExpression = jsNewExpression.getMethodExpression();
} catch (Exception e) {
return; //catching an intelliJ CCE
}
if (!(methodExpression instanceof JSReferenceExpression)) {
return;
}
final JSReferenceExpression referenceExpression = (JSReferenceExpression) methodExpression;
final JSExpression qualifier = referenceExpression.getQualifier();
if (qualifier != null) {
return;
}
@NonNls final String methodName = referenceExpression.getReferencedName();
if (!"Function".equals(methodName)) {
return;
}
registerError(methodExpression);
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:25,代码来源:DynamicallyGeneratedCodeJSInspection.java
示例15: visitJSCallExpression
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@Override public void visitJSCallExpression(
@NotNull JSCallExpression expression) {
super.visitJSCallExpression(expression);
final JSExpression reference =
expression.getMethodExpression();
if(!(reference instanceof JSReferenceExpression))
{
return;
}
final JSExpression qualifier = ((JSReferenceExpression)reference).getQualifier();
if (qualifier == null) {
return;
}
if (!isCallExpression(qualifier)) {
return;
}
registerFunctionCallError(expression);
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:19,代码来源:ChainedFunctionCallJSInspection.java
示例16: visitJSReferenceExpression
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
@Override public void visitJSReferenceExpression(JSReferenceExpression referenceExpression) {
super.visitJSReferenceExpression(referenceExpression);
final JSExpression qualifier = referenceExpression.getQualifier();
if (qualifier == null) {
return;
}
final String qualifierText = qualifier.getText();
if (!"document".equalsIgnoreCase(qualifierText)) {
return;
}
final String methodName = referenceExpression.getReferencedName();
if (!"images".equalsIgnoreCase(methodName) &&
!"body".equalsIgnoreCase(methodName) &&
!"applets".equalsIgnoreCase(methodName) &&
!"links".equalsIgnoreCase(methodName) &&
!"forms".equalsIgnoreCase(methodName) &&
!"anchors".equalsIgnoreCase(methodName)
) {
return;
}
registerError(referenceExpression);
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:25,代码来源:XHTMLIncompatabilitiesJSInspection.java
示例17: visitJSReferenceExpression
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@Override public void visitJSReferenceExpression(
@NotNull JSReferenceExpression reference)
{
if(usedInInnerFunction)
{
return;
}
super.visitJSReferenceExpression(reference);
if(inInnerFunction)
{
final PsiElement element = reference.resolve();
if(variable.equals(element))
{
usedInInnerFunction = true;
}
}
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:18,代码来源:VariableUsedInInnerFunctionVisitor.java
示例18: visitElement
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@Override
public void visitElement(PsiElement element) {
if(element instanceof JSReferenceExpression) {
String possibleKey = JsPsiHelper.checkReferenceExpression((JSReferenceExpression) element);
if(possibleKey != null) {
collectedItems.add(new KeyUsagePsiElement(possibleKey, element));
}
}
super.visitElement(element);
}
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:14,代码来源:JsEnvironmentCallsVisitor.java
示例19: checkReferenceExpression
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
/**
* Checks whole process.env.SOME_KEY reference element
* @param referenceExpression checking expression
* @return null or Environment key
*/
@Nullable
public static String checkReferenceExpression(@NotNull JSReferenceExpression referenceExpression) {
String text = referenceExpression.getCanonicalText();
if(!text.startsWith("process.env.") || text.length() < 13) {
return null;
}
return text.substring(12);
}
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:16,代码来源:JsPsiHelper.java
示例20: getLineMarkerInfo
import com.intellij.lang.javascript.psi.JSReferenceExpression; //导入依赖的package包/类
@RequiredReadAction
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element)
{
if(element.getNode().getElementType() == JSTokenTypes.IDENTIFIER && element.getParent() instanceof JSReferenceExpression && element.getParent().getParent() instanceof JSFunction)
{
UnityFunctionManager functionManager = UnityFunctionManager.getInstance();
Map<String, UnityFunctionManager.FunctionInfo> map = functionManager.getFunctionsByType().get(Unity3dTypes.UnityEngine.MonoBehaviour);
if(map == null)
{
return null;
}
UnityFunctionManager.FunctionInfo functionInfo = map.get(element.getText());
if(functionInfo == null)
{
return null;
}
Unity3dModuleExtension extension = ModuleUtilCore.getExtension(element, Unity3dModuleExtension.class);
if(extension == null)
{
return null;
}
JSFunction jsFunction = (JSFunction) element.getParent().getParent();
if(jsFunction.getParent() instanceof JSFile)
{
if(!isEqualParameters(functionInfo.getParameters(), jsFunction))
{
return null;
}
return new LineMarkerInfo<>(element, element.getTextRange(), Unity3dIcons.EventMethod, Pass.LINE_MARKERS, new ConstantFunction<>(functionInfo.getDescription()), null,
GutterIconRenderer.Alignment.LEFT);
}
}
return null;
}
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:38,代码来源:UnityScriptEventFunctionLineMarkerProvider.java
注:本文中的com.intellij.lang.javascript.psi.JSReferenceExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论