use of com.intellij.lang.javascript.psi.ecmal4.JSReferenceList in project intellij-plugins by JetBrains.
the class FlexXmlBackedClassesIndex method getIndexer.
@Override
@NotNull
public DataIndexer<String, Void, FileContent> getIndexer() {
return new DataIndexer<String, Void, FileContent>() {
@Override
@NotNull
public Map<String, Void> map(@NotNull FileContent inputData) {
final XmlFile file = (XmlFile) inputData.getPsiFile();
final Map<String, Void> result = new HashMap<>();
for (JSClass clazz : XmlBackedJSClassImpl.getClasses(file)) {
JSReferenceList supers = getSupers(clazz);
if (supers != null) {
final JSExpression[] expressions = supers.getExpressions();
for (JSExpression expr : expressions) {
String s = expr instanceof JSReferenceExpression ? ((JSReferenceExpression) expr).getReferenceName() : null;
if (s != null)
result.put(s, null);
}
}
}
return result;
}
};
}
use of com.intellij.lang.javascript.psi.ecmal4.JSReferenceList in project intellij-plugins by JetBrains.
the class FlashUmlDataModel method removeEdge.
@Override
public void removeEdge(DiagramEdge<Object> edge) {
final Object source = edge.getSource().getIdentifyingElement();
final Object target = edge.getTarget().getIdentifyingElement();
final DiagramRelationshipInfo relationship = edge.getRelationship();
if (!(source instanceof JSClass) || !(target instanceof JSClass) || relationship == DiagramRelationshipInfo.NO_RELATIONSHIP) {
return;
}
final JSClass fromClass = (JSClass) source;
final JSClass toClass = (JSClass) target;
if (JSProjectUtil.isInLibrary(fromClass)) {
return;
}
if (fromClass instanceof XmlBackedJSClassImpl && !toClass.isInterface()) {
Messages.showErrorDialog(fromClass.getProject(), FlexBundle.message("base.component.needed.message"), FlexBundle.message("remove.edge.title"));
return;
}
if (Messages.showYesNoDialog(fromClass.getProject(), FlexBundle.message("remove.inheritance.link.prompt", fromClass.getQualifiedName(), toClass.getQualifiedName()), FlexBundle.message("remove.edge.title"), Messages.getQuestionIcon()) != Messages.YES) {
return;
}
final Runnable runnable = () -> {
JSReferenceList refList = !fromClass.isInterface() && toClass.isInterface() ? fromClass.getImplementsList() : fromClass.getExtendsList();
List<FormatFixer> formatters = new ArrayList<>();
JSRefactoringUtil.removeFromReferenceList(refList, toClass, formatters);
if (!(fromClass instanceof XmlBackedJSClassImpl) && needsImport(fromClass, toClass)) {
formatters.addAll(ECMAScriptImportOptimizer.executeNoFormat(fromClass.getContainingFile()));
}
FormatFixer.fixAll(formatters);
};
DiagramAction.performCommand(getBuilder(), runnable, FlexBundle.message("remove.relationship.command.name"), null, fromClass.getContainingFile());
}
use of com.intellij.lang.javascript.psi.ecmal4.JSReferenceList 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);
}
Aggregations