use of com.intellij.lang.javascript.psi.ecmal4.JSAttributeList in project intellij-plugins by JetBrains.
the class FlashUmlEdgeCreationPolicy method acceptSource.
public boolean acceptSource(@NotNull final DiagramNode<Object> source) {
if (!(source.getIdentifyingElement() instanceof JSClass))
return false;
final JSClass clazz = (JSClass) source.getIdentifyingElement();
JSAttributeList attributeList = clazz.getAttributeList();
if (attributeList != null && attributeList.hasModifier(JSAttributeList.ModifierType.FINAL))
return false;
if (JSProjectUtil.isInLibrary(clazz))
return false;
return true;
}
use of com.intellij.lang.javascript.psi.ecmal4.JSAttributeList in project intellij-plugins by JetBrains.
the class FlashUmlVisibilityManager method getVisibilityLevel.
public VisibilityLevel getVisibilityLevel(Object element) {
if (element instanceof JSAttributeListOwner) {
JSAttributeList attributeList = ((JSAttributeListOwner) element).getAttributeList();
JSAttributeList.AccessType accessType = attributeList != null ? attributeList.getAccessType() : JSUtils.getImplicitAccessType((PsiElement) element);
return predefinedLevels.get(ArrayUtil.indexOf(JSVisibilityUtil.ACCESS_TYPES, accessType));
}
return null;
}
use of com.intellij.lang.javascript.psi.ecmal4.JSAttributeList in project intellij-plugins by JetBrains.
the class CreateJSSubclassIntention method isAvailable.
public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) {
final PsiFile psiFile = element.getContainingFile();
if (!(psiFile instanceof JSFile) || InjectedLanguageManager.getInstance(project).getInjectionHost(psiFile) != null || !psiFile.getLanguage().isKindOf(JavaScriptSupportLoader.ECMA_SCRIPT_L4)) {
return false;
}
final JSClass jsClass = PsiTreeUtil.getParentOfType(element, JSClass.class);
if (jsClass == null || !(jsClass.getParent() instanceof JSPackageStatement)) {
return false;
}
if (!jsClass.isInterface()) {
final JSAttributeList attributeList = jsClass.getAttributeList();
if (attributeList != null && attributeList.hasModifier(JSAttributeList.ModifierType.FINAL)) {
return false;
}
}
final TextRange declarationRange = getClassDeclarationTextRange(jsClass);
final int offset = editor.getCaretModel().getOffset();
if (offset < declarationRange.getStartOffset() || offset > declarationRange.getEndOffset()) {
// not the same as TextRange.contains()
return false;
}
setText(getTitle(jsClass));
return true;
}
use of com.intellij.lang.javascript.psi.ecmal4.JSAttributeList in project intellij-plugins by JetBrains.
the class CreateJSSubclassIntention method getClassDeclarationTextRange.
public static TextRange getClassDeclarationTextRange(final JSClass jsClass) {
int start = jsClass.getTextRange().getStartOffset();
final JSAttributeList attributeList = jsClass.getAttributeList();
if (attributeList != null) {
final PsiElement accessTypeElement = attributeList.findAccessTypeElement();
if (accessTypeElement != null) {
start = accessTypeElement.getTextRange().getStartOffset();
} else {
final ASTNode node = jsClass.getNode();
final ASTNode classKeyWordNode = node == null ? null : node.findChildByType(JSTokenTypes.CLASS_KEYWORD);
if (classKeyWordNode != null) {
start = classKeyWordNode.getTextRange().getStartOffset();
}
}
}
int end = start;
JSReferenceList jsReferenceList = jsClass.getImplementsList();
if (jsReferenceList == null) {
jsReferenceList = jsClass.getExtendsList();
}
if (jsReferenceList != null) {
end = jsReferenceList.getTextRange().getEndOffset();
} else {
final PsiElement nameIdentifier = jsClass.getNameIdentifier();
if (nameIdentifier != null) {
end = nameIdentifier.getTextRange().getEndOffset();
}
}
return new TextRange(start, end);
}
use of com.intellij.lang.javascript.psi.ecmal4.JSAttributeList in project intellij-plugins by JetBrains.
the class FlexMxmlNSDescriptor method isLegalRootElementDescriptor.
private static boolean isLegalRootElementDescriptor(@NotNull final XmlElementDescriptor _descriptor) {
if (_descriptor instanceof ClassBackedElementDescriptor) {
final ClassBackedElementDescriptor descriptor = (ClassBackedElementDescriptor) _descriptor;
final PsiElement element = descriptor.getDeclaration();
if (element instanceof JSClass) {
final JSAttributeList attributeList = ((JSClass) element).getAttributeList();
if (attributeList != null && attributeList.hasModifier(JSAttributeList.ModifierType.FINAL)) {
return false;
}
}
if (JavaScriptSupportLoader.isLanguageNamespace(descriptor.context.namespace)) {
final String tagName = _descriptor.getName();
return !descriptor.isPredefined() && !ArrayUtil.contains(tagName, ILLEGAL_LANGUAGE_ROOT_TAGS);
}
}
return true;
}
Aggregations