use of com.intellij.lang.javascript.psi.ecmal4.JSAttributeList in project intellij-plugins by JetBrains.
the class FlexImplicitUsageProvider method isImplicitUsage.
@Override
public boolean isImplicitUsage(PsiElement element) {
if (element instanceof XmlAttribute && ((XmlAttribute) element).isNamespaceDeclaration() && JavaScriptSupportLoader.isLanguageNamespace(((XmlAttribute) element).getValue())) {
return true;
}
if (element instanceof JSClass) {
JSClass clazz = (JSClass) element;
final Module module = ModuleUtilCore.findModuleForPsiElement(clazz);
if (module == null || ModuleType.get(module) != FlexModuleType.getInstance())
return false;
if (FlashRunConfigurationProducer.isAcceptedMainClass(clazz, module))
return true;
if (ActionScriptClassResolver.isParentClass(clazz, FlashRunConfigurationForm.MODULE_BASE_CLASS_NAME))
return true;
FlexUnitSupport flexUnitSupport = FlexUnitSupport.getSupport(module);
if (flexUnitSupport != null && flexUnitSupport.isTestClass(clazz, true))
return true;
} else if (element instanceof JSFunction) {
if (isTestMethod((JSFunction) element))
return true;
if (isAnnotatedByUnknownAttribute((JSAttributeListOwner) element))
return true;
} else if (element instanceof JSVariable) {
if (isAnnotatedByUnknownAttribute((JSAttributeListOwner) element))
return true;
if (JSResolveUtil.findParent(element) instanceof JSClass) {
final JSAttributeList varAttrList = ((JSVariable) element).getAttributeList();
if (varAttrList != null && varAttrList.findAttributeByName(FlexAnnotationNames.EMBED) != null) {
return true;
}
}
}
if (element instanceof JSParameter) {
JSFunction function = PsiTreeUtil.getParentOfType(element, JSFunction.class);
if (function != null) {
final JSParameter[] params = function.getParameterVariables();
if (params.length == 1 && element == params[0]) {
@NonNls String type = ((JSParameter) element).getTypeString();
if (type != null)
type = JSImportHandlingUtil.resolveTypeName(type, element);
if (type != null) {
if (FlexCommonTypeNames.FLASH_EVENT_FQN.equals(type) || FlexCommonTypeNames.STARLING_EVENT_FQN.equals(type)) {
return true;
}
boolean b = JSResolveUtil.processHierarchy(type, element.getContainingFile(), jsClass -> !FlexCommonTypeNames.FLASH_EVENT_FQN.equals(jsClass.getQualifiedName()) && !FlexCommonTypeNames.STARLING_EVENT_FQN.equals(jsClass.getQualifiedName()), false);
if (!b)
return true;
}
}
}
}
return false;
}
use of com.intellij.lang.javascript.psi.ecmal4.JSAttributeList in project intellij-plugins by JetBrains.
the class ActionScriptAccessibilityProcessingHandler method acceptsForMembersVisibility.
@Override
protected boolean acceptsForMembersVisibility(@NotNull JSPsiElementBase element, @NotNull SinkResolveProcessor resolveProcessor) {
if (!(element instanceof JSAttributeListOwner))
return true;
final JSAttributeList attributeList = ((JSAttributeListOwner) element).getAttributeList();
if (JSResolveUtil.getClassOfContext(place) != JSResolveUtil.getClassOfContext(element)) {
if (!acceptPrivateMembers) {
if (attributeList != null && attributeList.getAccessType() == JSAttributeList.AccessType.PRIVATE) {
resolveProcessor.addPossibleCandidateResult(element, JSResolveResult.PRIVATE_MEMBER_IS_NOT_ACCESSIBLE);
return false;
}
}
if (!acceptProtectedMembers) {
if (attributeList != null && attributeList.getAccessType() == JSAttributeList.AccessType.PROTECTED) {
// we are resolving in context of the class or element within context of the class
if ((myClassScopeTypeName != null || isParentClassContext(element))) {
resolveProcessor.addPossibleCandidateResult(element, JSResolveResult.PROTECTED_MEMBER_IS_NOT_ACCESSIBLE);
return false;
}
// if element / context out of class then protected element is ok due to includes
}
}
}
PsiElement elt = JSResolveUtil.findParent(element);
if (processStatics) {
if ((attributeList == null || !attributeList.hasModifier(JSAttributeList.ModifierType.STATIC))) {
if (JSResolveUtil.PROTOTYPE_FIELD_NAME.equals(resolveProcessor.getName()))
return true;
resolveProcessor.addPossibleCandidateResult(element, JSResolveResult.INSTANCE_MEMBER_INACCESSIBLE);
return false;
}
if (myTypeName != null && elt instanceof JSClass && !myTypeName.equals(((JSClass) elt).getQualifiedName())) {
// static members are inherited in TypeScript classes
resolveProcessor.addPossibleCandidateResult(element, JSResolveResult.STATIC_MEMBER_INACCESSIBLE);
return false;
}
} else if (myClassDeclarationStarted && !allowUnqualifiedStaticsFromInstance) {
// ActionScript only?
if (attributeList != null && attributeList.hasModifier(JSAttributeList.ModifierType.STATIC)) {
boolean referencingClass = false;
if (place instanceof JSReferenceExpression) {
JSExpression qualifier = ((JSReferenceExpression) place).getQualifier();
if (qualifier instanceof JSReferenceExpression) {
JSElement expression = JSSymbolUtil.calcRefExprValue((JSReferenceExpression) qualifier);
if (expression instanceof JSReferenceExpression) {
for (ResolveResult r : ((JSReferenceExpression) expression).multiResolve(false)) {
PsiElement rElement = r.getElement();
if (rElement instanceof JSClass) {
referencingClass = true;
break;
}
}
}
}
}
if (!referencingClass) {
resolveProcessor.addPossibleCandidateResult(element, JSResolveResult.STATIC_MEMBER_INACCESSIBLE);
return false;
}
}
}
if (processActionScriptNotAllowedNsAttributes(element, resolveProcessor, attributeList))
return false;
return true;
}
use of com.intellij.lang.javascript.psi.ecmal4.JSAttributeList in project intellij-plugins by JetBrains.
the class ActionScriptRearranger method detectModifiers.
@NotNull
protected Set<ArrangementSettingsToken> detectModifiers(@NotNull final JSAttributeListOwner fieldOrMethod) {
final Set<ArrangementSettingsToken> result = ContainerUtil.newHashSet();
final JSAttributeList attributes = fieldOrMethod.getAttributeList();
if (attributes != null) {
JSAttributeList.AccessType accessType = attributes.getExplicitAccessType();
if (accessType == null) {
final String namespace = attributes.getNamespace();
if (namespace == null) {
accessType = JSAttributeList.AccessType.PACKAGE_LOCAL;
}
}
if (accessType != null) {
switch(accessType) {
case PUBLIC:
result.add(PUBLIC);
break;
case PROTECTED:
result.add(PROTECTED);
break;
case PACKAGE_LOCAL:
result.add(PACKAGE_PRIVATE);
break;
case PRIVATE:
result.add(PRIVATE);
break;
}
}
if (attributes.hasModifier(JSAttributeList.ModifierType.STATIC))
result.add(STATIC);
if (attributes.hasModifier(JSAttributeList.ModifierType.FINAL))
result.add(FINAL);
if (attributes.hasModifier(JSAttributeList.ModifierType.OVERRIDE))
result.add(OVERRIDE);
}
return result;
}
use of com.intellij.lang.javascript.psi.ecmal4.JSAttributeList in project intellij-plugins by JetBrains.
the class CreateFlexSkinIntention method appendSkinStates.
private static void appendSkinStates(final Collection<String> skinStates, final JSClass jsClass, final Set<JSClass> visited) {
visited.add(jsClass);
final JSAttributeList attributeList = jsClass.getAttributeList();
if (attributeList != null) {
final JSAttribute[] attributes = attributeList.getAttributesByName("SkinState");
for (final JSAttribute attribute : attributes) {
final JSAttributeNameValuePair pair = attribute.getValueByName(null);
if (pair != null) {
final String state = pair.getSimpleValue();
if (!skinStates.contains(state)) {
skinStates.add(state);
}
}
}
}
for (final JSClass superClass : jsClass.getSuperClasses()) {
if (!visited.contains(superClass)) {
appendSkinStates(skinStates, superClass, visited);
}
}
}
use of com.intellij.lang.javascript.psi.ecmal4.JSAttributeList 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;
}
Aggregations