use of com.intellij.lang.javascript.psi.JSReferenceExpression in project intellij-plugins by JetBrains.
the class ActionScriptCompletionKeywordsContributor method process.
@Override
public boolean process(KeywordCompletionConsumer consumer, PsiElement context) {
if (JSCompletionContributor.getInstance().isDoingSmartCodeCompleteAction())
return false;
final PsiElement parent = context.getParent();
final PsiElement grandParent = parent != null ? parent.getParent() : null;
final PsiElement grandGrandParent = grandParent != null ? grandParent.getParent() : null;
if (parent instanceof JSReferenceExpression && ((JSReferenceExpression) parent).getQualifier() == null && (JSResolveUtil.isExprInTypeContext((JSReferenceExpression) parent) || grandParent instanceof JSExpressionStatement && (JSResolveUtil.isPlaceWhereNsCanBe(grandParent) || grandGrandParent instanceof JSFile && grandGrandParent.getContext() == null) || grandParent instanceof JSAttributeList || parent instanceof JSAttributeNameValuePair)) {
if (!(grandParent instanceof JSImportStatement) && (grandParent instanceof JSAttributeList || JSResolveUtil.isPlaceWhereNsCanBe(grandParent) || grandGrandParent instanceof JSFile) && (!(grandParent instanceof JSFunction) || ((JSFunction) grandParent).getReturnTypeElement() != parent)) {
consumer.consume(JSLookupPriority.SMART_KEYWORDS_PRIORITY, true, accessModifiers);
consumer.consume(JSLookupPriority.SMART_KEYWORDS_PRIORITY, true, "class", "function", "interface", "namespace", "package", "extends", "implements", "import", "override", "static", "dynamic", "var", "const", "use", "final");
}
return false;
}
if (JSResolveUtil.isInPlaceWhereTypeCanBeDuringCompletion(parent) && JSResolveUtil.isPlaceWhereNsCanBe(grandParent)) {
consumer.consume(JSLookupPriority.KEYWORDS_PRIORITY, false, JSKeywordsCompletionProvider.TYPE_LITERAL_VALUES);
consumer.consume(JSLookupPriority.KEYWORDS_PRIORITY, false, "function");
consumer.consume(JSLookupPriority.KEYWORDS_PRIORITY, true, accessModifiers);
consumer.consume(JSLookupPriority.KEYWORDS_PRIORITY, true, "extends", "implements", "include", "import", "static", "override", "namespace", "class", "interface", "var", "use");
return false;
}
return true;
}
use of com.intellij.lang.javascript.psi.JSReferenceExpression in project intellij-plugins by JetBrains.
the class CreateJSEventMethod method addParameters.
@Override
protected void addParameters(Template template, JSReferenceExpression refExpr, PsiFile file) {
Expression expression = new MyExpression("event");
template.addVariable("$event$", expression, expression, true);
template.addTextSegment(":");
String text = myEventTypeGenerator.compute();
text = ImportUtils.importAndShortenReference(text, refExpr, true, true).first;
template.addTextSegment(text);
}
use of com.intellij.lang.javascript.psi.JSReferenceExpression in project intellij-plugins by JetBrains.
the class ActionScriptResolveTest method testResolveInClassDynamic.
public void testResolveInClassDynamic() throws Exception {
String fileText = "public class T {\n" + " public function m() : String {\n" + " return \"m\";\n" + " }\n" + "\n" + " public function test() : String {\n" + " function foo():String {\n" + " return this.<ref>m();\n" + " }\n" + " return foo();\n" + " }\n" + "}\n" + "function m() {}";
JSReferenceExpression ref = (JSReferenceExpression) configureByFileText(fileText, "sample.js2");
ResolveResult[] results = ref.multiResolve(false);
assertEquals(2, results.length);
}
use of com.intellij.lang.javascript.psi.JSReferenceExpression in project intellij-plugins by JetBrains.
the class ActionScriptResolveTest method testResolveVectorMember.
public void testResolveVectorMember() throws Exception {
String fileText = "package {\n" + "public class Vector$object {\n" + " function reverse():Vector$object {}\n" + "}\n" + "}\n" + "var x:Vector.<int>\n" + "x.rev<ref>erse()";
JSReferenceExpression ref = (JSReferenceExpression) configureByFileText(fileText, "sample.as");
final PsiElement resolved = ref.resolve();
assertNotNull(resolved);
}
use of com.intellij.lang.javascript.psi.JSReferenceExpression in project intellij-plugins by JetBrains.
the class ActionScriptResolveTest method testObjectProperties.
public void testObjectProperties() throws Exception {
String fileText = "package {\n" + "public class Foo {\n" + " function bar() {" + " var x:Object = {};\n" + " x.toStri<ref>ng();\n" + " }\n" + "}\n" + "}";
JSReferenceExpression ref = (JSReferenceExpression) configureByFileText(fileText, "sample.as");
final PsiElement resolved = ref.resolve();
assertNotNull(resolved);
}
Aggregations