private PsiElement moveImportToEnd(JSArrayLiteralExpression imports, JSParameterList parameters, String module, String parameter, PsiElement lastDefine, PsiElement lastParameter) { // TODO move to AMDPsiUtil if we need to reuse this in the future PsiElement lastChild = imports.getChildren()[imports.getChildren().length-1]; if(lastDefine != null) { lastChild = lastDefine; } PsiElement element = imports.addAfter(JSChangeUtil.createExpressionFromText(imports.getProject(), String.format("%s", module)).getPsi(), lastChild); imports.getNode().addLeaf(JSTokenTypes.COMMA, ",", element.getNode()); imports.getNode().addLeaf(JSTokenTypes.WHITE_SPACE, "\n", element.getNode()); PsiElement lastParameterChild = parameters.getChildren()[parameters.getChildren().length-1]; if(lastParameter != null) { lastParameterChild = lastParameter; } PsiElement parameterElement = parameters.addAfter(JSChangeUtil.createExpressionFromText(imports.getProject(), String.format("%s", parameter)).getPsi(), lastParameterChild); parameters.getNode().addLeaf(JSTokenTypes.COMMA, ",", parameterElement.getNode()); return element; }
/** * Given a module that is being imported using absolute or relative path syntax, return the module * import with the other syntax, if possible. * * @param define * @return */ public @Nullable PsiElement getOppositePathSyntaxFromImport(PsiElement define) { if(define == null) { return null; } boolean relative = define.getText().charAt(1) == '.'; char quote = define.getText().charAt(0); String moduleText = define.getText().replaceAll("'", "").replaceAll("\"", ""); String syntax = getPathSyntax(define.getProject(), define.getText(), define.getContainingFile(), !relative); if(syntax.equals(moduleText)) { return null; // no point in replacing with the same thing } return JSChangeUtil.createExpressionFromText(define.getProject(), quote + syntax + quote).getPsi(); }
@Override public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { if(!CodeInsightUtilBase.getInstance().prepareFileForWrite(file)) { return; } final ASTNode fromText = JSChangeUtil.createJSTreeFromText(project, "override class A {}"); final JSAttributeList jsAttributeList = myNode.getAttributeList(); final JSAttributeList createdAttrList = ((JSClass) fromText.getPsi()).getAttributeList(); if(jsAttributeList != null) { jsAttributeList.add(createdAttrList.getFirstChild()); } else { myNode.addBefore(createdAttrList, myNode.getFirstChild()); } }
@Override @Nullable public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, @NotNull PsiElement[] elements) throws IncorrectOperationException { ASTNode node = JSChangeUtil.createStatementFromText(project, getStatementTemplate(project, elements[0])); PsiElement container = elements[0].getParent(); container.getNode().addChild(node, elements[0].getNode()); final ASTNode insertBeforeNode = getInsertBeforeNode(node); for(int i = 0; i < elements.length; i++) { final ASTNode childNode = elements[i].getNode(); final ASTNode childNodeCopy = childNode.copyElement(); container.getNode().removeChild(childNode); insertBeforeNode.getTreeParent().addChild(childNodeCopy, insertBeforeNode); } final CodeStyleManager csManager = CodeStyleManager.getInstance(project); csManager.reformat(node.getPsi()); return getSurroundSelectionRange(node); }
private static void deleteImport(final JSImportStatement anImport) { if(!anImport.isValid()) { return; } PsiElement nextSibling = anImport.getNextSibling(); if(nextSibling instanceof PsiWhiteSpace) { // remove with the following whitespace String whitespace = nextSibling.getText(); if(whitespace.contains("]]>")) { nextSibling.replace(JSChangeUtil.createJSTreeFromText(anImport.getProject(), "]]>").getPsi()); } // don't remove trailing line break if it is an injection suffix else if(nextSibling.getNextSibling() == null || nextSibling.getNextSibling().getNode().getElementType() != JSTokenTypes.RBRACE || !(nextSibling.getParent() instanceof JSBlockStatement) || !ImportUtils.isAnonymousEventHandler((JSBlockStatement) nextSibling.getParent())) { nextSibling.delete(); } } anImport.delete(); }
public static String createImportBlock(Project project, Collection<String> fqns) { List<String> sorted = new ArrayList<String>(fqns); Collections.sort(sorted, new Comparator<String>() { @Override public int compare(final String o1, final String o2) { return compareImports(o1, o2); } }); final String semicolon = JSChangeUtil.getSemicolon(project); StringBuilder s = new StringBuilder(); for(String fqn : sorted) { s.append("import ").append(fqn).append(semicolon); } return s.toString(); }
protected static void replaceExpression(JSExpression expression, String newExpression) throws IncorrectOperationException { final ASTNode fromText = JSChangeUtil.createStatementFromText(expression.getProject(), newExpression + ';'); final PsiElement element = fromText != null ? fromText.getPsi() : null; final JSExpressionStatement expressionStatement = element instanceof JSExpressionStatement ? (JSExpressionStatement) element:null; if (expressionStatement == null) { return; } final JSExpression newExp = expressionStatement.getExpression(); final ASTNode newExpressionNode = newExp.getNode(); final ASTNode expressionNode = expression.getNode(); final PsiElement parent = expression.getParent(); final ASTNode parentNode = parent.getNode(); parentNode.replaceChild(expressionNode, newExpressionNode); // final CodeStyleManager styleManager = manager.getCodeStyleManager(); // styleManager.reformat(newExpressionNode.getPsi()); }
protected static void replaceStatement(JSStatement statement, @NonNls String newStatement) throws IncorrectOperationException { final ASTNode fromText = JSChangeUtil.createStatementFromText(statement.getProject(), newStatement); final PsiElement element = fromText != null ? fromText.getPsi() : null; final JSStatement newStmt = element instanceof JSStatement ? (JSStatement)element:null; if (newStmt == null) { return; } final PsiElement parent = statement.getParent(); final ASTNode parentNode = parent.getNode(); final ASTNode statementNode = statement.getNode(); final ASTNode newStatementNode = newStmt.getNode(); parentNode.replaceChild(statementNode, newStatementNode); // final CodeStyleManager styleManager = manager.getCodeStyleManager(); // styleManager.reformat(newStatementNode.getPsi()); }
public static JSStatement replaceElementWithStatement(@NotNull JSElement element, @NonNls @NotNull String statementText) throws IncorrectOperationException { final ASTNode newStatementNode = JSChangeUtil.createStatementFromText( element.getProject(), statementText); final ASTNode oldStatementParentNode = element.getNode(); final PsiElement parentNode = element.getParent(); final ASTNode newStatementParentNode = parentNode.getNode(); if (newStatementParentNode == null || oldStatementParentNode == null || newStatementNode == null) { return null; } newStatementParentNode.replaceChild(oldStatementParentNode, newStatementNode); reformat(parentNode); return (JSStatement) newStatementNode.getPsi(); }
public static JSStatement replaceStatement(@NotNull JSStatement statement, @NonNls @NotNull String text) throws IncorrectOperationException { final ASTNode newStatementNode = JSChangeUtil.createStatementFromText( statement.getProject(), text); final ASTNode oldStatementParentNode = statement.getNode(); final PsiElement parentNode = statement.getParent(); final ASTNode newStatementParentNode = parentNode.getNode(); if (newStatementParentNode == null || oldStatementParentNode == null || newStatementNode == null) { return null; } newStatementParentNode.replaceChild(oldStatementParentNode, newStatementNode); reformat(parentNode); return (JSStatement) newStatementNode.getPsi(); }
public static JSStatement addStatementBefore(@NotNull JSStatement statement, @NonNls @NotNull String previousStatementText) throws IncorrectOperationException { final ASTNode newStatementNode = JSChangeUtil.createStatementFromText( statement.getProject(), previousStatementText); final ASTNode oldStatementParentNode = statement.getNode(); final PsiElement parentNode = statement.getParent(); final ASTNode newStatementParentNode = parentNode.getNode(); if (newStatementParentNode == null || newStatementNode == null) { return null; } newStatementParentNode.addChild(newStatementNode, oldStatementParentNode); reformat(parentNode); return (JSStatement) newStatementNode.getPsi(); }
public static JSStatement addStatementAfter(@NotNull JSStatement statement, @NonNls @NotNull String nextStatementText) throws IncorrectOperationException { final ASTNode newStatementNode = JSChangeUtil.createStatementFromText( statement.getProject(), nextStatementText); final ASTNode statementNode = statement.getNode(); final ASTNode oldStatementParentNode = ((statementNode == null) ? null : statementNode.getTreeNext()); final PsiElement parentNode = statement.getParent(); final ASTNode newStatementParentNode = parentNode.getNode(); if (newStatementParentNode == null || newStatementNode == null) { return null; } newStatementParentNode.addChild(newStatementNode, oldStatementParentNode); reformat(parentNode); return (JSStatement) newStatementNode.getPsi(); }
public static JSExpression getNegated(JSExpression condition) { if (condition instanceof JSPrefixExpression) { final JSPrefixExpression prefixExp = (JSPrefixExpression) condition; final JSExpression operand = prefixExp.getExpression(); return ParenthesesUtils.stripParentheses(operand); } else if (condition instanceof JSBinaryExpression) { final JSBinaryExpression binaryExpression = (JSBinaryExpression) condition; final IElementType sign = binaryExpression.getOperationSign(); final JSExpression lhs = binaryExpression.getLOperand(); final JSExpression rhs = binaryExpression.getROperand(); final String negatedSign = ComparisonUtils.getNegatedOperatorText(sign); final String negatedText = lhs.getText() + negatedSign + rhs.getText(); return (JSExpression) JSChangeUtil.createExpressionFromText( condition.getProject(), negatedText); } else if (condition instanceof JSParenthesizedExpression) { return getNegated(((JSParenthesizedExpression) condition).getInnerExpression()); } return condition; }
@Override public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @Nullable("is null when called from inspection") Editor editor, @NotNull PsiElement element, @NotNull PsiElement end) throws IncorrectOperationException { JSIndexedPropertyAccessExpression indexed = PsiTreeUtil.getParentOfType(element, JSIndexedPropertyAccessExpression.class); JSReferenceExpression ref = PsiTreeUtil.findChildOfType(indexed, JSReferenceExpression.class); JSLiteralExpression literalExpression = (JSLiteralExpression) indexed.getIndexExpression(); String path = StringUtil.stripQuotesAroundValue(literalExpression.getText()); ASTNode dotExp = JSChangeUtil.createStatementFromText(project, ref.getText() + '.' + path); indexed.replace(dotExp.getPsi()); }
@Override public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @Nullable("is null when called from inspection") Editor editor, @NotNull PsiElement element, @NotNull PsiElement end) throws IncorrectOperationException { // PsiElement element = descriptor.getPsiElement(); JSBinaryExpression binary = PsiTreeUtil.getParentOfType(element, JSBinaryExpression.class); JSBinaryExpression binaryClone = (JSBinaryExpression) binary.copy(); binaryClone.getLOperand().replace(binary.getLOperand().getLastChild()); ASTNode negate = JSChangeUtil.createStatementFromText(project, "!(true)"); JSParenthesizedExpression paren = PsiTreeUtil.getChildOfType(negate.getPsi().getFirstChild(), JSParenthesizedExpression.class); paren.getInnerExpression().replace(binaryClone); binary.replace(negate.getPsi()); }
public static PsiElement addStatementBeforeElement(PsiElement parent, PsiElement element, String statement, String whitespace) { ASTNode node = JSChangeUtil.createStatementFromText(parent.getProject(), statement, JSUtils.getDialect(parent.getContainingFile())); parent.addBefore(node.getPsi(), element); if(!whitespace.equals("")) { parent.addBefore(JSChangeUtil.createJSTreeFromText(parent.getProject(), whitespace).getPsi(), element); } return node.getPsi(); }
public static PsiElement addStatement(PsiElement parent, String statement) { ASTNode node = JSChangeUtil.createStatementFromText(parent.getProject(), statement, JSUtils.getDialect(parent.getContainingFile())); parent.add(node.getPsi()); return node.getPsi(); }
public static PsiElement addExpression(PsiElement parent, String statement) { ASTNode node = JSChangeUtil.createExpressionFromText(parent.getProject(), statement, JSUtils.getDialect(parent.getContainingFile())); parent.add(node.getPsi()); return node.getPsi(); }
protected void addSemicolonSegment(final Template template, final PsiFile file) { final String semicolon = JSChangeUtil.getSemicolon(file.getProject()); if(semicolon.length() > 0) { template.addTextSegment(semicolon); } }
@Override protected JSDocTag createTree(final String newText, final Project project) { @NonNls String ToCreate = "/** " + newText + " */"; final PsiElement element = JSChangeUtil.createJSTreeFromText(project, ToCreate).getPsi(); return ((JSDocComment) element).getTags()[0]; }
@Override protected JSAttributeNameValuePair createTree(final String newText, final Project project) { @NonNls String ToCreate = "[A(" + newText + ")] class C {}"; final PsiElement element = JSChangeUtil.createStatementFromText(project, ToCreate).getPsi(); return ((JSClass) element).getAttributeList().getAttributes()[0].getValues()[0]; }
protected PsiElement doAddOneMethod(final Project project, final String functionText, PsiElement anchor) throws IncorrectOperationException { if(functionText != null && functionText.length() > 0) { PsiElement element = JSChangeUtil.createJSTreeFromText(project, functionText).getPsi(); if(element instanceof PsiWhiteSpace) { element = element.getNextSibling(); } boolean defaultAdd = true; if(anchor != null && anchor.isValid()) { String anchorText; if(!(anchor instanceof PsiWhiteSpace) || ((anchorText = anchor.getText()).indexOf("<![CDATA[") == -1 && anchorText.indexOf("]]>") == -1)) { defaultAdd = false; anchor = anchor.getParent().addAfter(element, anchor); } } if(defaultAdd) { anchor = myJsClass.add(element); } } return anchor; }
@Override protected String buildFunctionBodyText(final String retType, final JSParameterList parameterList, final JSFunction func) { @NonNls String s = "{\n"; if(retType != null && !"void".equals(retType)) { s += "return " + defaultValueOfType(retType) + JSChangeUtil.getSemicolon(func.getProject()) + "\n"; } s += "}"; return s; }
@Override @Nullable public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, @NotNull PsiElement[] elements) throws IncorrectOperationException { JSExpression expr = (JSExpression) elements[0]; ASTNode parenthExprNode = JSChangeUtil.createExpressionFromText(project, "(" + expr.getText() + ")").getNode(); expr.getNode().getTreeParent().replaceChild(expr.getNode(), parenthExprNode); int offset = parenthExprNode.getTextRange().getEndOffset(); return new TextRange(offset, offset); }
protected CreateClassDialog(final Project project, String className, String packageName, boolean isInterface) { super(project, false); setTitle(JavaScriptBundle.message(isInterface ? "create.interface.dialog.title" : "create.class.dialog.title")); setModal(true); myPackageName.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(final DocumentEvent e) { String text = getPackageName(); boolean enabled; if(text.length() == 0) { enabled = true; } else { ASTNode node = JSChangeUtil.createJSTreeFromText(project, text); PsiElement elt; enabled = node != null && (elt = node.getPsi()) instanceof JSExpressionStatement && (elt = ((JSExpressionStatement) elt).getExpression()) instanceof JSReferenceExpression && ((JSReferenceExpression) elt).getReferencedName() != null && elt.textMatches(text); } getOKAction().setEnabled(enabled); } }); myClassName.setText(className); myPackageName.setText(packageName); init(); }
protected JSVarStatement prepareDeclaration(final String varDeclText, BaseIntroduceContext<S> context, final Project project) throws IncorrectOperationException { JSVarStatement declaration = (JSVarStatement) JSChangeUtil.createStatementFromText(project, varDeclText + " = 0" + JSChangeUtil.getSemicolon (project)).getPsi(); declaration.getVariables()[0].getInitializer().replace(context.expression); return declaration; }
public static JSExpression replaceExpression(@NotNull JSExpression expression, @NonNls @NotNull String text) throws IncorrectOperationException { final JSExpression newExpressionNode = JSChangeUtil.createExpressionFromText( expression.getProject(), text); return replaceExpression(expression, newExpressionNode); }
/** * Returns the smallest subexpression (if precendence allows it). For instance: * variable + 2 + 3 normally gets evaluated left to right -> (variable + 2) * + 3 this method returns the right most legal subexpression -> 2 + 3 * @param expression the expression to analyse * @return the found common sub-expression if found, or <tt>null</tt> otherwise. */ @Nullable private static JSBinaryExpression getSubexpression(JSBinaryExpression expression) { final JSExpression rhs = expression.getROperand(); final IElementType sign = expression.getOperationSign(); final int parentPrecendence = ParenthesesUtils.getPrecendence(expression); if (rhs == null) { return null; } final JSExpression lhs = expression.getLOperand(); if (!(lhs instanceof JSBinaryExpression)) { return expression; } final JSBinaryExpression lhsBinaryExpression = (JSBinaryExpression) lhs; final int childPrecendence = ParenthesesUtils.getPrecendence(lhsBinaryExpression); final JSExpression leftSide = lhsBinaryExpression.getROperand(); if (leftSide == null) { return null; } if (parentPrecendence > childPrecendence) { return null; } try { final String subExpressionText = leftSide.getText() + BinaryOperatorUtils.getOperatorText(sign) + rhs.getText(); final JSExpression subExpression = JSChangeUtil.createExpressionFromText(expression.getProject(), subExpressionText); return (JSBinaryExpression) subExpression; } catch (Throwable ignore) { return null; } }
private void addIgnoreStatement() { PsiElement element = JSChangeUtil.createJSTreeFromText(define.getProject(), UnusedImportsRemover.IGNORE_COMMENT).getPsi(); define.getParent().addAfter(element, define); }
public static PsiElement createStatement(PsiElement parent, String statement) { ASTNode node = JSChangeUtil.createStatementFromText(parent.getProject(), statement, JSUtils.getDialect(parent.getContainingFile())); return node.getPsi(); }
public static PsiElement createExpression(PsiElement parent, String statement) { ASTNode node = JSChangeUtil.createExpressionFromText(parent.getProject(), statement, JSUtils.getDialect(parent.getContainingFile())); return node.getPsi(); }
public static JSExpression getRealRefExprQualifierFromResult(final JSReferenceExpression expr, final JSImportedElementResolveResult resolved) { return ((JSReferenceExpression) JSChangeUtil.createExpressionFromText(expr.getProject(), resolved.qualifiedName)).getQualifier(); }
private JSReferenceList createReferenceList(final String s) { final JSClass element = (JSClass) JSChangeUtil.createJSTreeFromText(getProject(), "class C extends " + s + " {}").getPsi(); return element.getExtendsList(); }
@Override public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException { if(element instanceof JSFunction || element instanceof JSVarStatement) { final JSFile jsFile = createOrGetFirstScriptTag(); if(jsFile != null) { final PsiElement child = jsFile.getLastChild(); String text; if(child instanceof PsiWhiteSpace && (text = child.getText()).indexOf("]]>") != -1) { int cdataAt = 0; String marker = "<![CDATA["; if((cdataAt = text.indexOf(marker)) == -1) { element = jsFile.addBefore(element, child); } else { int markerEnd = cdataAt + marker.length(); ASTNode fromText = JSChangeUtil.createJSTreeFromText(getProject(), text.substring(0, markerEnd) + element.getText() + text.substring (markerEnd)); jsFile.getNode().replaceAllChildrenToChildrenOf(fromText.getTreeParent()); element = PsiTreeUtil.getParentOfType(jsFile.findElementAt(markerEnd + 1), element.getClass()); } } else { element = jsFile.add(element); } CodeStyleManager.getInstance(getProject()).reformatNewlyAddedElement(jsFile.getNode(), element.getNode()); return element; } } return super.add(element); }
@Override protected JSIncludeDirectiveImpl createTree(final String newText, final Project project) { return (JSIncludeDirectiveImpl) JSChangeUtil.createStatementFromText(project, newText).getPsi(); }
@Override public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { if(!CodeInsightUtilBase.getInstance().prepareFileForWrite(file)) { return; } Template t = TemplateManager.getInstance(project).createTemplate("", ""); t.setToReformat(true); t.addTextSegment("super("); boolean first = true; for(JSParameter p : superConstructor.getParameterList().getParameters()) { if(p.isRest()) { break; } if(!first) { t.addTextSegment(", "); } first = false; MacroCallNode node = new MacroCallNode(new CompleteMacro()); t.addVariable(p.getName(), node, node, true); } t.addTextSegment(")"); String s = JSChangeUtil.getSemicolon(project); if(s.length() > 0) { t.addTextSegment(s); } JSFunction fun = PsiTreeUtil.getParentOfType(node, JSFunction.class); JSSourceElement[] body = fun != null ? fun.getBody() : JSSourceElement.EMPTY_ARRAY; if(body.length > 0 && body[0] instanceof JSBlockStatement) { PsiElement firstChild = body[0].getFirstChild(); editor.getCaretModel().moveToOffset(firstChild.getTextRange().getEndOffset()); TemplateManager.getInstance(project).startTemplate(editor, t); } }
@Override public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { if(!CodeInsightUtilBase.getInstance().prepareFileForWrite(file)) { return; } final JSClass jsClass = PsiTreeUtil.getParentOfType(node, JSClass.class); if(jsClass == null) { return; } final JSAttributeList attributeList = jsClass.getAttributeList(); String fun = ""; if(attributeList != null && attributeList.getAccessType() == JSAttributeList.AccessType.PUBLIC) { fun += "public "; } fun += "function "; final JSParameterList parameterList = superConstructor.getParameterList(); fun += jsClass.getName() + parameterList.getText() + "{\n"; fun += "super("; int i = 0; for(JSParameter p : parameterList.getParameters()) { if(i != 0) { fun += ","; } ++i; fun += p.getName(); } fun += ")" + JSChangeUtil.getSemicolon(project); fun += "\n}"; jsClass.add(JSChangeUtil.createJSTreeFromText(project, fun).getPsi()); }
@Override protected String getStatementTemplate(final Project project, PsiElement context) { return "aaa = function () { }" + JSChangeUtil.getSemicolon(project); }
@Override protected String buildFunctionBodyText(final String retType, final JSParameterList parameterList, final JSFunction func) { @NonNls String functionText = ""; functionText += "{\n"; if(!"void".equals(retType)) { functionText += " return"; } else { functionText += " "; } functionText += " super." + func.getName(); if(func.isGetProperty()) { } else if(func.isSetProperty()) { functionText += " = " + parameterList.getParameters()[0].getName(); } else { functionText += "("; boolean first = true; for(JSParameter param : parameterList.getParameters()) { if(!first) { functionText += ","; } first = false; functionText += param.getName(); } functionText += ")"; } functionText += JSChangeUtil.getSemicolon(func.getProject()) + "\n}"; return functionText; }
@Override public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException { final JSCodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(project).getCustomSettings(JSCodeStyleSettings.class); evalAnchor(editor, file); @NonNls String functionText = "public function " + jsClass.getName() + "("; @NonNls String initialization = ""; boolean first = true; final String semicolon = JSChangeUtil.getSemicolon(project); Set<JSVariable> toProcess = getElementsToProcess(); Iterator<JSVariable> variableIterator = toProcess.iterator(); boolean hadSuperClassConstructorInitializationBefore = false; while(variableIterator.hasNext()) { JSVariable var = variableIterator.next(); if(!first) { functionText += ", "; } first = false; final String name = var.getName(); String parameterName = transformVarNameToAccessorName(name, codeStyleSettings); final String typeString = var.getTypeString(); functionText += parameterName + (typeString != null ? ":" + typeString : ""); if(JSResolveUtil.findParent(var) == jsClass) { if(hadSuperClassConstructorInitializationBefore) { initialization += ")" + semicolon + "\n"; hadSuperClassConstructorInitializationBefore = false; } initialization += (parameterName.equals(name) ? "this." : "") + name + " = " + parameterName + semicolon + "\n"; } else { if(hadSuperClassConstructorInitializationBefore) { initialization += ", "; } else { initialization += "super("; } initialization += parameterName; hadSuperClassConstructorInitializationBefore = true; } } if(hadSuperClassConstructorInitializationBefore) { initialization += ")" + semicolon + "\n"; } functionText += ") {\n"; functionText += initialization; functionText += "}"; doAddOneMethod(project, functionText, anchor); }