use of com.intellij.lang.javascript.psi.JSExpressionStatement 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.JSExpressionStatement in project intellij-plugins by JetBrains.
the class CreateEventHandlerIntention method isAvailable.
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
// keep consistency with JavaScriptGenerateEventHandler.GenerateEventHandlerFix.beforeInvoke()
final XmlAttribute xmlAttribute = ActionScriptGenerateEventHandler.getXmlAttribute(file, editor);
final String eventType = xmlAttribute == null ? null : ActionScriptGenerateEventHandler.getEventType(xmlAttribute);
if (eventType != null) {
return true;
}
final JSCallExpression callExpression = ActionScriptGenerateEventHandler.getEventListenerCallExpression(file, editor);
if (callExpression != null) {
return true;
}
final Trinity<JSExpressionStatement, String, String> eventConstantInfo = ActionScriptGenerateEventHandler.getEventConstantInfo(file, editor);
if (eventConstantInfo != null) {
return true;
}
return false;
}
use of com.intellij.lang.javascript.psi.JSExpressionStatement in project intellij-plugins by JetBrains.
the class AngularMessageFormatCompletion method messageFormatCompletion.
static boolean messageFormatCompletion(CompletionParameters parameters, CompletionResultSet result) {
final PsiElement originalPosition = parameters.getOriginalPosition();
if (originalPosition == null)
return false;
final PsiElement parent = originalPosition.getParent();
if (parent instanceof JSReferenceExpression && parent.getParent() instanceof JSCommaExpression) {
final PsiElement[] children = parent.getParent().getChildren();
if (children.length >= 2 && children[1] == parent) {
messageFormatExtensions(result);
return true;
}
}
if (parent instanceof AngularJSMessageFormatExpression) {
final AngularJSMessageFormatExpression amfe = (AngularJSMessageFormatExpression) parent;
if (originalPosition == amfe.getExtensionTypeElement()) {
messageFormatExtensions(result);
return true;
}
if (originalPosition.getNode().getElementType() == AngularJSElementTypes.MESSAGE_FORMAT_SELECTION_KEYWORD) {
messageFormatSelectionKeywords(((AngularJSMessageFormatExpression) parent).getExtensionType(), result);
return true;
}
if (originalPosition.getNode().getElementType() == JSTokenTypes.WHITE_SPACE) {
if (originalPosition.getNextSibling() != null && originalPosition.getNextSibling().getNode().getElementType() == AngularJSElementTypes.MESSAGE_FORMAT_SELECTION_KEYWORD || originalPosition.getPrevSibling() != null && originalPosition.getPrevSibling().getNode().getElementType() == JSTokenTypes.RBRACE) {
messageFormatSelectionKeywords(((AngularJSMessageFormatExpression) parent).getExtensionType(), result);
return true;
}
}
}
final PsiElement sibling = originalPosition.getPrevSibling();
if (sibling instanceof AngularJSMessageFormatExpression) {
messageFormatSelectionKeywords(((AngularJSMessageFormatExpression) sibling).getExtensionType(), result);
} else if (sibling instanceof JSExpressionStatement && sibling.getFirstChild() instanceof AngularJSMessageFormatExpression) {
messageFormatSelectionKeywords(((AngularJSMessageFormatExpression) sibling.getFirstChild()).getExtensionType(), result);
}
return false;
}
use of com.intellij.lang.javascript.psi.JSExpressionStatement in project oxy-template-support-plugin by mutant-industries.
the class JsMacroNameDataIndexer method map.
@Override
@NotNull
public Map<String, JsMacroNameIndexedElement> map(@NotNull final FileContent inputData) {
PsiFile jsFile = inputData.getPsiFile().getViewProvider().getPsi(OxyTemplateInnerJs.INSTANCE);
Map<String, JsMacroNameIndexedElement> result = new HashMap<>();
for (PsiElement psiElement : jsFile.getChildren()) {
if (psiElement instanceof JSExpressionStatement && (psiElement = PsiTreeUtil.getChildOfAnyType(psiElement, JSAssignmentExpression.class)) != null && psiElement.getFirstChild() instanceof JSDefinitionExpression) {
String rootNamespace = psiElement.getFirstChild().getText().replace(MACRO_REGISTRY_NAMESPACE + ".", "");
boolean firstIteration = true;
for (JSReferenceExpression ref : PsiTreeUtil.findChildrenOfType(psiElement.getFirstChild(), JSReferenceExpression.class)) {
String namespace = ref.getText().replace(MACRO_REGISTRY_NAMESPACE + ".", "");
if (!namespace.equals(DEFAULT_NAMESPACE) && !namespace.equals(MACRO_REGISTRY_NAMESPACE)) {
result.put(ref.getText().replace(MACRO_REGISTRY_NAMESPACE + ".", ""), new JsMacroNameIndexedElement(firstIteration && psiElement.getLastChild() instanceof JSFunctionExpression, ref.getTextOffset() + ref.getTextLength() - 1));
}
firstIteration = false;
}
if (psiElement.getLastChild() instanceof JSObjectLiteralExpression) {
processObjectLiteralExpression((JSObjectLiteralExpression) psiElement.getLastChild(), rootNamespace, result);
}
}
}
return result;
}
Aggregations