public void generate() throws IOException { Task<WorkingCopy> task = new Task<WorkingCopy>() { public void run(WorkingCopy workingCopy) throws Exception { workingCopy.toPhase(Phase.RESOLVED); TreeMaker make = workingCopy.getTreeMaker(); GenerationUtils gu = GenerationUtils.newInstance(workingCopy); TypeElement typeElement = SourceUtils.getPublicTopLevelElement(workingCopy); ClassTree oldClassTree = workingCopy.getTrees().getTree(typeElement); ClassTree classTree = addFields(gu, make, typeElement, oldClassTree); if (isBodyTag) { classTree = make.addClassMember(classTree, addBodyEvaluatorCheck(evaluateBody, make)); } classTree = addSetters(gu, make, typeElement, classTree); workingCopy.rewrite(oldClassTree, classTree); } }; ModificationResult result = clazz.runModificationTask(task); result.commit(); }
public void generate(JavaSource clazz) throws IOException { Task<WorkingCopy> task = new Task<WorkingCopy>() { public void run(WorkingCopy workingCopy) throws Exception { workingCopy.toPhase(Phase.RESOLVED); CompilationUnitTree cut = workingCopy.getCompilationUnit(); gu = GenerationUtils.newInstance(workingCopy); for (Tree typeDecl : cut.getTypeDecls()) { if (TreeUtilities.CLASS_TREE_KINDS.contains(typeDecl.getKind())) { Element e = workingCopy.getTrees().getElement(new TreePath(new TreePath(workingCopy.getCompilationUnit()), typeDecl)); if (e != null && e.getKind().isClass()) { TypeElement te = (TypeElement) e; ClassTree ct = (ClassTree) typeDecl; workingCopy.rewrite(ct, generateInterfaces(workingCopy, te, ct, gu)); } } } } }; ModificationResult result = clazz.runModificationTask(task); result.commit(); // if (isContext) addContextListenerMethods(); // if (isContextAttr) addContextAttrListenerMethods(); // if (isSession) addSessionListenerMethods(); // if (isSessionAttr) addSessionAttrListenerMethods(); // if (isRequest) addRequestListenerMethods(); // if (isRequestAttr) addRequestAttrListenerMethods(); }
public static Object execute(Write task, JavaSource js) { WriteTaskWrapper taskWrapper = new WriteTaskWrapper(task); ModificationResult result = null; try { result = js.runModificationTask(taskWrapper); if(result != null) { result.commit(); } } catch (IOException ex) { ex.printStackTrace(); } return taskWrapper.result; }
private void addImports(final StyledDocument styledDocument ) { try { JavaSource.forDocument(styledDocument).runModificationTask(new CancellableTask<WorkingCopy>() { public void cancel() { } public void run(WorkingCopy parameter) throws Exception { parameter.toPhase(JavaSource.Phase.PARSED); for (String fqn : fqns) { SourceUtils.resolveImport(parameter, new TreePath(parameter.getCompilationUnit()), fqn); } } }).commit(); } catch (IOException e) { Exceptions.printStackTrace(e); } } };
private void addImports(final StyledDocument styledDocument) { try { JavaSource.forDocument(styledDocument).runModificationTask(new CancellableTask<WorkingCopy>() { public void cancel() { } public void run(WorkingCopy parameter) throws Exception { parameter.toPhase(JavaSource.Phase.PARSED); String typeFqn = getComponent().getType().getString(); if (!fullyNamesList.contains(typeFqn)) { fullyNamesList.add(typeFqn); } DesignComponent connector = MidpDatabindingSupport.getConnector(getComponent(), bindedProperty); for (String fqn : fullyNamesList) { if (bindedProperty == null) { SourceUtils.resolveImport(parameter, new TreePath(parameter.getCompilationUnit()), fqn); } else if (connector != null) { SourceUtils.resolveImport(parameter, new TreePath(parameter.getCompilationUnit()), fqn); } } } }).commit(); } catch (IOException e) { Exceptions.printStackTrace(e); } } }
ModificationResult result = javaSource.runModificationTask( new CancellableTask<WorkingCopy>() {
controllerJavaSource.runModificationTask(new Task<WorkingCopy>() { public void run(WorkingCopy workingCopy) throws IOException { workingCopy.toPhase(JavaSource.Phase.RESOLVED);
JavaSource source = JavaSource.forFileObject(detailFob); try { source.runModificationTask(new CancellableTask<WorkingCopy>() { JavaSource source = JavaSource.forFileObject(masterFob); try { source.runModificationTask(new CancellableTask<WorkingCopy>() {
try { source.runModificationTask(new CancellableTask<WorkingCopy>() { source.runModificationTask(new CancellableTask<WorkingCopy>() { source.runModificationTask(new CancellableTask<WorkingCopy>() {
protected void performGlobalGeneration (StyledDocument styledDocument) { JavaSource source = JavaSource.forDocument (styledDocument); try { ModificationResult result = source.runModificationTask (new CancellableTask<WorkingCopy>() { public void cancel () {
converterJavaSource.runModificationTask(new Task<WorkingCopy>() { public void run(WorkingCopy workingCopy) throws IOException { workingCopy.toPhase(JavaSource.Phase.RESOLVED);
return; ModificationResult res = javaSource.runModificationTask( new Task<WorkingCopy>() {
targetSource.runModificationTask(modificationTask).commit(); }catch(IOException e){ ErrorManager.getDefault().notify(e);
ModificationResult result = js.runModificationTask(new CancellableTask<WorkingCopy>() { @Override public void cancel() {
ModificationResult modificationResult = javaSource.runModificationTask( new StringLiteralTask(oldValueBindingPrefix, newValueBindingPrefix, StringLiteralTransformer.MatchKind.PREFIX) ); ModificationResult modificationResult = javaSource.runModificationTask( new StringLiteralTask(oldBeanName, newBeanName, StringLiteralTransformer.MatchKind.EXACT) ); ModificationResult modificationResult = javaSource.runModificationTask( new StringLiteralTask(oldValueBindingPrefix, newValueBindingPrefix, StringLiteralTransformer.MatchKind.PREFIX) ); ModificationResult modificationResult = javaSource.runModificationTask( new StringLiteralTask(oldBeanName, newBeanName, StringLiteralTransformer.MatchKind.EXACT) );
ModificationResult result = js.runModificationTask(new CancellableTask<WorkingCopy>() { @Override public void cancel() {
ModificationResult modificationResult = javaSource.runModificationTask( new StringLiteralTask(oldValueBindingPrefix, newValueBindingPrefix, StringLiteralTransformer.MatchKind.PREFIX) ); ModificationResult modificationResult = javaSource.runModificationTask( new StringLiteralTask(oldBeanName, newBeanName, StringLiteralTransformer.MatchKind.EXACT) );