[Nice-commit] eclipse/src/nice/eclipse/core/builder NiceBuildNotifier.nice,NONE,1.1 NicePluginCompil
Brought to you by:
bonniot
From: <ag...@us...> - 2003-08-03 17:55:42
|
Update of /cvsroot/nice/eclipse/src/nice/eclipse/core/builder In directory sc8-pr-cvs1:/tmp/cvs-serv21012/src/nice/eclipse/core/builder Modified Files: NiceBuilder.nice Added Files: NiceBuildNotifier.nice NicePluginCompilationListener.nice Log Message: general project-scope warnings are reported in Problems view --- NEW FILE: NiceBuildNotifier.nice --- /**************************************************************************/ /* Nice Eclipse-Plugin */ /* (c) Alex Greif 2003 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package nice.eclipse.core.builder; public class NiceBuildNotifier { ?IProgressMonitor monitor; IProject project; int workDone = 0; int totalWork = 1000000; float proportionComplete = 0f; void begin() { if (monitor == null) return; notNull(monitor).beginTask("", totalWork); //$NON-NLS-1$ } void checkCancel() { if (monitor == null) return; if (notNull(monitor).isCanceled()) throw new OperationCanceledException(); } public void done() { this.updateProgress(1.0f); if (monitor == null) return; notNull(monitor).done(); } public void updateProgress(float newProportionComplete) { if (newProportionComplete > proportionComplete) { proportionComplete = Math.min(newProportionComplete, 1.0f); int work = Math.round(proportionComplete * totalWork); if (work > workDone) { if (monitor == null) return; notNull(monitor).worked(work - workDone); workDone = work; } } } public void updateProgressDelta(float proportionWorked) { this.updateProgress(proportionComplete + proportionWorked); } } --- NEW FILE: NicePluginCompilationListener.nice --- /**************************************************************************/ /* Nice Eclipse-Plugin */ /* (c) Alex Greif 2003 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package nice.eclipse.core.builder; class NicePluginCompilationListener implements CompilationListener { ?IProgressMonitor monitor; NiceBuildNotifier notifier; IProject project; error(location, message) { //println("nicec error: "+message); IResource resource = project; try { IMarker marker = resource.createMarker(NICE_MODEL_PROBLEM_MARKER); marker.setAttribute(IMarker.MESSAGE, message); marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); } catch (Throwable e) { e.printStackTrace(); } } error(loc...@Lo...urce, message) { IResource resource = this.getAffectedResource(location); //println("nicec error in source: "+resource+" line: "+location.getLine()+":"+ // location.getColumn()+"\n"+message); try { IMarker marker = resource.createMarker(NICE_MODEL_PROBLEM_MARKER); marker.setAttribute(IMarker.MESSAGE, message); marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); marker.setAttribute(IMarker.LINE_NUMBER, location.getLine()); marker.setAttribute(IMarker.CHAR_START, location.getColumn()); } catch (Throwable e) { e.printStackTrace(); } } warning(location, message) { //println("nicec warning: "+message); IResource resource = project; try { IMarker marker = resource.createMarker(NICE_MODEL_PROBLEM_MARKER); marker.setAttribute(IMarker.MESSAGE, message); marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING); } catch (CoreException e) { e.printStackTrace(); } } warning(loc...@Lo...urce, message) { IResource resource = this.getAffectedResource(location); //println("nicec warning in source: "+resource+" line: "+location.getLine()+":"+ // location.getColumn()+"\n"+message); try { IMarker marker = resource.createMarker(NICE_MODEL_PROBLEM_MARKER); marker.setAttribute(IMarker.MESSAGE, message); marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING); marker.setAttribute(IMarker.LINE_NUMBER, location.getLine()); marker.setAttribute(IMarker.CHAR_START, location.getColumn()); } catch (CoreException e) { e.printStackTrace(); } } /** A bug occured in the compiler. @param url the adress where a bug report should be submitted. */ bug(stackTrace, url) { System.out.println( "nicec bug stackTrace: " + stackTrace + " url: " + url); } /** Reports the progress of compilation. phase can be: parsing, type-checking, generating code, ... the package can be null if the phase applies to the whole program (testing dispatch, creating the archive, compiling to native code, ...). */ progress(packageName, phase) { let monitor = this.monitor; if (monitor == null) return; monitor.subTask("" + phase + " package: " + packageName); } /** Gives an approximation of how much of the compilation has been completed. */ progress(proportion) { notifier.updateProgress(proportion); } IResource getAffectedResource(Location); getAffectedResource(location) { throw new RuntimeException("getAffectedResource() not implemented"); } getAffectedResource(loc...@Lo...urce) { String projectPath = project.getLocation().toFile().getAbsolutePath(); String resourcePath = location.getFile().getAbsolutePath(); Path path = new Path(resourcePath.substring(projectPath.length())); return project.getFile(path); } } Index: NiceBuilder.nice =================================================================== RCS file: /cvsroot/nice/eclipse/src/nice/eclipse/core/builder/NiceBuilder.nice,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NiceBuilder.nice 1 Aug 2003 20:09:42 -0000 1.1 --- NiceBuilder.nice 3 Aug 2003 17:55:38 -0000 1.2 *************** *** 18,22 **** IProject currentProject = cast(null); ?IProgressMonitor monitor = cast(null); ! BuildNotifier notifier = cast(null); build(kind, argsMap, aMonitor) { --- 18,22 ---- IProject currentProject = cast(null); ?IProgressMonitor monitor = cast(null); ! NiceBuildNotifier notifier = cast(null); build(kind, argsMap, aMonitor) { *************** *** 27,31 **** // return new IProject[0]; ! notifier = new BuildNotifier(monitor: monitor, project: currentProject); notifier.begin(); notifier.checkCancel(); --- 27,31 ---- // return new IProject[0]; ! notifier = new NiceBuildNotifier(monitor: monitor, project: currentProject); notifier.begin(); notifier.checkCancel(); *************** *** 89,176 **** - class NicePluginCompilationListener implements CompilationListener { - ?IProgressMonitor monitor; - BuildNotifier notifier; - IProject project; - - error(location, message) {println("nicec error: "+message);} - error(loc...@Lo...urce, message) { - IResource resource = this.getAffectedResource(location); - //println("nicec error in source: "+resource+" line: "+location.getLine()+":"+ - // location.getColumn()+"\n"+message); - try { - IMarker marker = resource.createMarker(NICE_MODEL_PROBLEM_MARKER); - marker.setAttribute(IMarker.MESSAGE, message); - marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); - marker.setAttribute(IMarker.LINE_NUMBER, location.getLine()); - marker.setAttribute(IMarker.CHAR_START, location.getColumn()); - } catch (Throwable e) { - e.printStackTrace(); - } - } - - warning(location, message) {println("nicec warning: "+message);} - warning(loc...@Lo...urce, message) { - IResource resource = this.getAffectedResource(location); - //println("nicec warning in source: "+resource+" line: "+location.getLine()+":"+ - // location.getColumn()+"\n"+message); - try { - IMarker marker = resource.createMarker(NICE_MODEL_PROBLEM_MARKER); - marker.setAttribute(IMarker.MESSAGE, message); - marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING); - marker.setAttribute(IMarker.LINE_NUMBER, location.getLine()); - marker.setAttribute(IMarker.CHAR_START, location.getColumn()); - } catch (CoreException e) { - e.printStackTrace(); - } - } - - /** A bug occured in the compiler. - @param url the adress where a bug report should be submitted. - */ - bug(stackTrace, url) { - System.out.println( - "nicec bug stackTrace: " + stackTrace + " url: " + url); - } - - /** Reports the progress of compilation. - phase can be: parsing, type-checking, generating code, ... - the package can be null if the phase applies to the whole program - (testing dispatch, creating the archive, compiling to native code, ...). - */ - progress(packageName, phase) { - let monitor = this.monitor; - if (monitor == null) return; - monitor.subTask("" + phase + " package: " + packageName); - } - - /** Gives an approximation of how much of the compilation has been completed. - */ - progress(proportion) { - notifier.updateProgress(proportion); - } - - - IResource getAffectedResource(Location); - - getAffectedResource(location) { - throw new RuntimeException("getAffectedResource() not implemented"); - } - getAffectedResource(loc...@Lo...urce) { - String projectPath = project.getLocation().toFile().getAbsolutePath(); - String resourcePath = location.getFile().getAbsolutePath(); - Path path = new Path(resourcePath.substring(projectPath.length())); - return project.getFile(path); - } - - } - - - - - - - - --- 89,92 ---- *************** *** 182,236 **** - public class BuildNotifier { - ?IProgressMonitor monitor; - IProject project; - - int workDone = 0; - int totalWork = 1000000; - float proportionComplete = 0f; - - - - void begin() { - if (monitor == null) - return; - notNull(monitor).beginTask("", totalWork); //$NON-NLS-1$ - } - - - void checkCancel() { - if (monitor == null) - return; - if (notNull(monitor).isCanceled()) - throw new OperationCanceledException(); - } - - - public void done() { - this.updateProgress(1.0f); - if (monitor == null) - return; - notNull(monitor).done(); - } - - - public void updateProgress(float newProportionComplete) { - if (newProportionComplete > proportionComplete) { - proportionComplete = Math.min(newProportionComplete, 1.0f); - int work = Math.round(proportionComplete * totalWork); - if (work > workDone) { - if (monitor == null) - return; - notNull(monitor).worked(work - workDone); - workDone = work; - } - } - } - - public void updateProgressDelta(float proportionWorked) { - this.updateProgress(proportionComplete + proportionWorked); - } - - } --- 98,101 ---- |