static void addCreateParameterProposal( Collection<ICompletionProposal> proposals, String def, String desc, Image image, Declaration dec, PhasedUnit unit, Tree.Declaration decNode, Tree.ParameterList paramList, ProducedType t) { IFile file = CeylonBuilder.getFile(unit); TextFileChange change = new TextFileChange("Add Parameter", file); change.setEdit(new MultiTextEdit()); int offset = paramList.getStopIndex(); int il = importType(change, t, unit.getCompilationUnit()); change.addEdit(new InsertEdit(offset, def)); proposals.add( new CreateProposal( def, "Add " + desc + " to '" + dec.getName() + "'", image, 0, offset + il, file, change)); }
static void addCreateParameterAndAttributeProposal( Collection<ICompletionProposal> proposals, String pdef, String adef, String desc, Image image, Declaration dec, PhasedUnit unit, Tree.Declaration decNode, Tree.ParameterList paramList, Tree.Body body, ProducedType t) { IFile file = CeylonBuilder.getFile(unit); TextFileChange change = new TextFileChange("Add Attribute", file); change.setEdit(new MultiTextEdit()); int offset = paramList.getStopIndex(); IDocument doc = CreateProposal.getDocument(change); String indent; String indentAfter; int offset2; List<Tree.Statement> statements = body.getStatements(); if (statements.isEmpty()) { indentAfter = "\n" + CeylonQuickFixAssistant.getIndent(decNode, doc); indent = indentAfter + getDefaultIndent(); offset2 = body.getStartIndex() + 1; } else { Tree.Statement statement = statements.get(statements.size() - 1); indent = "\n" + CeylonQuickFixAssistant.getIndent(statement, doc); offset2 = statement.getStopIndex() + 1; indentAfter = ""; } int il = importType(change, t, unit.getCompilationUnit()); change.addEdit(new InsertEdit(offset, pdef)); change.addEdit(new InsertEdit(offset2, indent + adef + indentAfter)); proposals.add( new CreateProposal( pdef, "Add " + desc + " to '" + dec.getName() + "'", image, 0, offset + il, file, change)); }