/** * Creates the text change for this proposal. This method is only called once and only when no * text change has been passed in {@link #TUCorrectionProposal(String, ITranslationUnit, * TextChange, int, Image)}. * * @return returns the created text change. * @throws CoreException thrown if the creation of the text change failed. */ protected TextChange createTextChange() throws CoreException { ITranslationUnit tu = getTranslationUnit(); String name = getName(); TextChange change; if (!tu.getResource().exists()) { String source; try { source = tu.getSource(); } catch (CModelException e) { CUIPlugin.log(e); source = ""; // $NON-NLS-1$ } Document document = new Document(source); document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(tu)); change = new DocumentChange(name, document); } else { CTextFileChange tuChange = new CTextFileChange(name, tu); tuChange.setSaveMode(TextFileChange.LEAVE_DIRTY); change = tuChange; } TextEdit rootEdit = new MultiTextEdit(); change.setEdit(rootEdit); // Initialize text change. IDocument document = change.getCurrentDocument(new NullProgressMonitor()); addEdits(document, rootEdit); return change; }
@Override protected String resolve(TemplateContext context) { TranslationUnitContext cContext = (TranslationUnitContext) context; ITranslationUnit tUnit = cContext.getTranslationUnit(); if (tUnit == null) return "XXX"; // $NON-NLS-1$ ICProject cProject = tUnit.getCProject(); String todoTaskTag = StubUtility.getTodoTaskTag(cProject); if (todoTaskTag == null) return "XXX"; // $NON-NLS-1$ return todoTaskTag; }