本文整理汇总了Java中com.intellij.lang.javascript.psi.JSReferenceExpression类的典型用法代码示例。如果您正苦于以下问题:Java JSReferenceExpression类的具体用法?Java JSReferenceExpression怎么用?Java JSReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSReferenceExpression类属于com.intellij.lang.javascript.psi包,在下文中一共展示了JSReferenceExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例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;
}
示例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;
}
示例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;
}
示例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() : "";
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
};
}
示例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);
}
示例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);
}
示例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);
}