use of com.intellij.lang.javascript.psi.resolve.JSOverrideHandler in project intellij-plugins by JetBrains.
the class ActionScriptGenerateToStringHandler method createFix.
protected BaseCreateMethodsFix createFix(final JSClass jsClass) {
return new BaseCreateMethodsFix<JSVariable>(jsClass) {
@Override
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
evalAnchor(editor, file);
final boolean[] needOverride = new boolean[1];
JSInheritanceUtil.processOverrides(jsClass, new JSOverrideHandler() {
public boolean process(@NotNull List<JSPsiElementBase> elements, final PsiElement scope, final String className) {
needOverride[0] = !"Object".equals(className);
return false;
}
}, "toString", null, myJsClass, true);
@NonNls String functionText = "public " + (needOverride[0] ? "override " : "") + "function toString():String {\nreturn " + (needOverride[0] ? "super.toString()" : "\"" + jsClass.getName());
final String semicolon = JSCodeStyleSettings.getSemicolon(file);
boolean first = true;
final Set<JSVariable> jsVariables = getElementsToProcess();
if (!jsVariables.isEmpty()) {
functionText += needOverride[0] ? " + \"{" : "{";
for (JSVariable var : jsVariables) {
if (!first) {
functionText += " + \",";
}
first = false;
functionText += var.getName() + "=\" + String(" + var.getName() + ")";
}
functionText += "+\"}\"";
} else {
if (!needOverride[0])
functionText += "\"";
}
functionText += semicolon + "\n}";
doAddOneMethod(project, functionText, anchor);
}
};
}
Aggregations