├── LICENSE ├── README.md ├── feature ├── .project ├── build.properties └── feature.xml ├── plugin ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.jdt.core.prefs │ └── org.eclipse.jdt.ui.prefs ├── ChangeLog ├── META-INF │ └── MANIFEST.MF ├── build.properties ├── conf │ ├── buffer.scm │ ├── bundles.scm │ ├── codewalkers.scm │ ├── commands.scm │ ├── constants.scm │ ├── dialogs.scm │ ├── dictionaries.scm │ ├── foreign.scm │ ├── forms.scm │ ├── languages │ │ ├── arc.scm │ │ ├── clojure.scm │ │ ├── kawa.scm │ │ ├── r5rs.scm │ │ ├── r6rs.scm │ │ └── snow.scm │ ├── macros.scm │ ├── markers.scm │ ├── modules.scm │ ├── namespaces.scm │ ├── plugin.scm │ ├── reader.scm │ ├── refactoring.scm │ ├── scratchpad.scm │ ├── stxmatch.scm │ ├── user.scm │ ├── util.scm │ └── widgets.scm ├── examples │ ├── circles.scm │ ├── scm2html.scm │ └── sisc │ │ ├── circles.scm │ │ └── scratchpad.scm ├── html │ ├── images │ │ ├── appearprefs.JPG │ │ ├── commentprefs.JPG │ │ ├── console.JPG │ │ ├── defview.JPG │ │ ├── errorlink.JPG │ │ ├── eval.JPG │ │ ├── fasteval.JPG │ │ ├── findsymbol.JPG │ │ ├── indentprefs.JPG │ │ ├── interpreter.JPG │ │ ├── lexicalprefs.JPG │ │ ├── menu.JPG │ │ ├── nuecho.jpg │ │ ├── perspectivebar.JPG │ │ ├── remoteinterp.JPG │ │ ├── run.JPG │ │ ├── schemeprefs.JPG │ │ ├── scratchpad.JPG │ │ ├── selectperspective.JPG │ │ ├── stacktrace.JPG │ │ ├── start.JPG │ │ ├── syntaxprefs.JPG │ │ └── toolbar.JPG │ └── toc.html ├── icons │ ├── chapter.gif │ ├── definition.gif │ ├── interruptScheme.gif │ ├── remove.gif │ ├── removeAll.gif │ ├── restartScheme.gif │ ├── scheme.gif │ ├── schemeway.gif │ ├── search.gif │ ├── section.gif │ ├── stacktrace │ │ ├── javaStackElement.gif │ │ ├── schemeStackElement.gif │ │ ├── stackElement.gif │ │ └── unknownStackElement.gif │ └── startScheme.gif ├── lib │ ├── kawa.jar │ ├── sisc-heap.jar │ ├── sisc-lib.jar │ ├── sisc-opt.jar │ ├── sisc.jar │ └── sisc.shp ├── plugin.properties ├── plugin.xml ├── schema │ └── interpreters.exsd ├── src │ ├── org │ │ └── schemeway │ │ │ └── plugins │ │ │ └── schemescript │ │ │ ├── SchemeNature.java │ │ │ ├── SchemePerspective.java │ │ │ ├── SchemeScriptImageRegistry.java │ │ │ ├── SchemeScriptPlugin.java │ │ │ ├── SchemeScriptTools.java │ │ │ ├── action │ │ │ ├── BackwardSExpAction.java │ │ │ ├── ChooseInterpreterAction.java │ │ │ ├── CommentAction.java │ │ │ ├── CompressSpacesAction.java │ │ │ ├── DownSExpAction.java │ │ │ ├── EvalExpressionAction.java │ │ │ ├── ExpandSelectionToSexpressions.java │ │ │ ├── FastEvalAction.java │ │ │ ├── FileHeaderCommentAction.java │ │ │ ├── FindSymbolAction.java │ │ │ ├── FormatAction.java │ │ │ ├── ForwardSExpAction.java │ │ │ ├── ISchemeEditorAction.java │ │ │ ├── InterruptEvaluationAction.java │ │ │ ├── JumpToDefinitionAction.java │ │ │ ├── LoadFileAction.java │ │ │ ├── MouseCopyAction.java │ │ │ ├── MoveLeftParenBackwardOneExpression.java │ │ │ ├── MoveRightParenForwardOneExpression.java │ │ │ ├── RestartInterpreterAction.java │ │ │ ├── RestoreSelectionAction.java │ │ │ ├── SchemeAction.java │ │ │ ├── SchemeProcedureAction.java │ │ │ ├── SectioningCommentAction.java │ │ │ ├── SelectionStack.java │ │ │ ├── StartInterpreterAction.java │ │ │ ├── SwapSexpAction.java │ │ │ └── UpSExpAction.java │ │ │ ├── debug │ │ │ └── SchemeToggleBreakpointsTarget.java │ │ │ ├── dialogs │ │ │ └── FindSymbolDialog.java │ │ │ ├── dictionary │ │ │ ├── DictionaryUpdater.java │ │ │ ├── DictionaryUtils.java │ │ │ ├── Reference.java │ │ │ ├── SymbolEntry.java │ │ │ ├── SymbolReferencesManager.java │ │ │ ├── SymbolReferencesTable.java │ │ │ ├── SymbolSearchPage.java │ │ │ ├── SymbolSearchQuery.java │ │ │ ├── SymbolSearchResult.java │ │ │ ├── SymbolSearchResultPage.java │ │ │ └── SymbolTableContentProvider.java │ │ │ ├── editor │ │ │ ├── BrlDocumentSetupParticipant.java │ │ │ ├── BrlPartitionScanner.java │ │ │ ├── ColorManager.java │ │ │ ├── ISchemeColorConstants.java │ │ │ ├── ISchemeOutlinePage.java │ │ │ ├── SchemeActionConstants.java │ │ │ ├── SchemeAnnotationHover.java │ │ │ ├── SchemeColoringScanner.java │ │ │ ├── SchemeConfiguration.java │ │ │ ├── SchemeContentAssistProcessor.java │ │ │ ├── SchemeDefaultScanner.java │ │ │ ├── SchemeDocumentSetupParticipant.java │ │ │ ├── SchemeDoubleClickStrategy.java │ │ │ ├── SchemeEditor.java │ │ │ ├── SchemeEditorActionsFactory.java │ │ │ ├── SchemeParenthesisPainter.java │ │ │ ├── SchemePartitionScanner.java │ │ │ ├── SchemeTextHover.java │ │ │ ├── SchemeTextTools.java │ │ │ ├── SchemeTextUtilities.java │ │ │ ├── SchemeWhitespaceDetector.java │ │ │ ├── SymbolHyperlinkDetector.java │ │ │ ├── autoedits │ │ │ │ ├── CommentDeleter.java │ │ │ │ ├── DoubleQuoteInserter.java │ │ │ │ ├── MatchingDelimitersInserter.java │ │ │ │ ├── SexpDeleter.java │ │ │ │ ├── SexpUtils.java │ │ │ │ └── StringDeleter.java │ │ │ └── outline │ │ │ │ ├── ContentUtilities.java │ │ │ │ ├── DefinitionsContentBuilder.java │ │ │ │ ├── NodeLabelProvider.java │ │ │ │ ├── OutlineContentBuilder.java │ │ │ │ ├── OutlineNode.java │ │ │ │ ├── OutlineNodeContentProvider.java │ │ │ │ ├── OutlineNodePositionComparator.java │ │ │ │ ├── SchemeOutlineImageProvider.java │ │ │ │ ├── SchemeOutlinePage.java │ │ │ │ ├── SectionsAndDefinitionsContentBuilder.java │ │ │ │ └── SectionsContentBuilder.java │ │ │ ├── indentation │ │ │ ├── IndentationRule.java │ │ │ ├── SchemeIndentationContext.java │ │ │ ├── SchemeIndentationManager.java │ │ │ └── SchemeIndentationStrategy.java │ │ │ ├── interpreter │ │ │ ├── AbstractInterpreter.java │ │ │ ├── ExternalInterpreter.java │ │ │ ├── ExternalInterpreterDelegate.java │ │ │ ├── IInterpreterProcess.java │ │ │ ├── Interpreter.java │ │ │ ├── InterpreterSupport.java │ │ │ ├── InterpreterType.java │ │ │ ├── KawaInterpreter.java │ │ │ ├── KawaInterpreterDelegate.java │ │ │ ├── KawaProcess.java │ │ │ ├── KawaProxy.java │ │ │ ├── MonitoredOutputStream.java │ │ │ ├── OutputStreamMonitor.java │ │ │ ├── RemoteInterpreter.java │ │ │ ├── RemoteInterpreterDelegate.java │ │ │ ├── RemoteInterpreterProcess.java │ │ │ ├── SchemeErrorLineTracker.java │ │ │ ├── SiscInterpreter.java │ │ │ ├── SiscInterpreterDelegate.java │ │ │ ├── SiscProcess.java │ │ │ └── SocketExceptionHandler.java │ │ │ ├── parser │ │ │ ├── BackwardTokenIterator.java │ │ │ ├── ForwardTokenIterator.java │ │ │ ├── ISchemeTokenIterator.java │ │ │ ├── KeywordManager.java │ │ │ ├── SchemeReader.java │ │ │ ├── SchemeScanner.java │ │ │ ├── SchemeScannerUtilities.java │ │ │ ├── SchemeToken.java │ │ │ ├── SexpExplorer.java │ │ │ └── SexpNavigator.java │ │ │ ├── preferences │ │ │ ├── ActionPreferences.java │ │ │ ├── ColorPreferences.java │ │ │ ├── CommentPreferences.java │ │ │ ├── ExternalInterpreterPreferences.java │ │ │ ├── FastEvalPreferences.java │ │ │ ├── IIndentationSchemeChangeListener.java │ │ │ ├── IndentationPreferences.java │ │ │ ├── IndentationSchemeCellModifier.java │ │ │ ├── IndentationSchemeContentProvider.java │ │ │ ├── IndentationSchemeLabelProvider.java │ │ │ ├── IndentationSchemeList.java │ │ │ ├── IndentationSchemeListViewer.java │ │ │ ├── IndentationSchemeSorter.java │ │ │ ├── InterpreterPreferences.java │ │ │ ├── PreferenceUtil.java │ │ │ ├── RemoteInterpreterPreferences.java │ │ │ ├── SchemeLexicalExtensionsPreferences.java │ │ │ ├── SchemePreferencePage.java │ │ │ ├── SchemePreferences.java │ │ │ ├── SchemePreferencesInitializer.java │ │ │ └── SyntaxPreferences.java │ │ │ ├── tools │ │ │ └── Comments.java │ │ │ ├── views │ │ │ ├── DefinitionListView.java │ │ │ ├── KawaScratchpadView.java │ │ │ └── KawaStackTraceView.java │ │ │ └── wizards │ │ │ ├── NewSchemeFileWizard.java │ │ │ └── NewSchemeFileWizardPage.java │ └── resources.properties ├── tests │ └── indentation-tests.scm └── toc.xml └── update-site ├── .gitignore ├── .project └── site.xml /README.md: -------------------------------------------------------------------------------- 1 | SchemeScript 2 | ============ 3 | 4 | SchemeScript is a Scheme/Lisp editor plug-in for Eclipse. 5 | 6 | The goal of this plug-in is to provide a robust Scheme/Lisp editor to the professional Scheme/Lisp developers who also happen to use Eclipse for Java programming. Also, the plug-in can be subclassed and extended to provide custom editors for Scheme/Lisp-based languages. 7 | 8 | SchemeScript embeds the Kawa and SISC interpreters, and can be readily used to connect to the SISC REPL of SISCweb-based web applications. 9 | 10 | The latest stable release is 1.3.0.rc1. 11 | 12 | 13 | Installation 14 | ------------ 15 | 16 | To install the plugin: 17 | 18 | * click on `Help > Install New Software...` 19 | * click on `Add...` and enter the plugin update site location: `http://schemeway.github.io/SchemeScript/update-site` 20 | * select the latest SchemeScript feature 21 | * click `Next` and follow the instructions 22 | 23 | Usage 24 | ------------ 25 | 26 | Check our [UserGuide](https://github.com/schemeway/SchemeScript/wiki) in the wiki section of our GitHub repo. 27 | 28 | More usage guidelines to be added, soon. 29 | 30 | Contributing 31 | ------------ 32 | 33 | You can contribute by: 34 | * testing the latest version 35 | * creating bug reports 36 | * forking the repository on github and create pull requests. 37 | 38 | 39 | Bug Reports 40 | ------------ 41 | 42 | Please file any bug reports in the bug tracker at github: 43 | 44 | https://github.com/schemeway/SchemeScript/issues 45 | -------------------------------------------------------------------------------- /feature/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | SchemeScript-Feature 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.FeatureBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.pde.FeatureNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /feature/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = feature.xml 2 | -------------------------------------------------------------------------------- /plugin/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /plugin/.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | -------------------------------------------------------------------------------- /plugin/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | SchemeScript 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.pde.ManifestBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.pde.SchemaBuilder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.pde.PluginNature 26 | org.eclipse.jdt.core.javanature 27 | 28 | 29 | -------------------------------------------------------------------------------- /plugin/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: SchemeScript Plug-in 4 | Bundle-SymbolicName: org.schemeway.plugins.schemescript; singleton:=true 5 | Bundle-Version: 1.3.0.rc1 6 | Bundle-ClassPath: schemescript.jar, 7 | lib/kawa.jar, 8 | lib/sisc.jar, 9 | lib/sisc-heap.jar, 10 | lib/sisc-lib.jar, 11 | lib/sisc-opt.jar 12 | Bundle-Activator: org.schemeway.plugins.schemescript.SchemeScriptPlugin 13 | Bundle-Vendor: The SchemeWay Project 14 | Bundle-Localization: plugin 15 | Export-Package: ., 16 | gnu.brl, 17 | gnu.bytecode, 18 | gnu.commonlisp.lang, 19 | gnu.commonlisp.lisp, 20 | gnu.ecmascript, 21 | gnu.expr, 22 | gnu.kawa.brl, 23 | gnu.kawa.functions, 24 | gnu.kawa.lispexpr, 25 | gnu.kawa.reflect, 26 | gnu.kawa.sax, 27 | gnu.kawa.servlet, 28 | gnu.kawa.slib, 29 | gnu.kawa.util, 30 | gnu.kawa.xml, 31 | gnu.kawa.xslt, 32 | gnu.lists, 33 | gnu.mapping, 34 | gnu.math, 35 | gnu.text, 36 | gnu.xml, 37 | gnu.xquery.lang, 38 | gnu.xquery.util, 39 | kawa, 40 | kawa.lang, 41 | kawa.lib, 42 | kawa.standard, 43 | org.schemeway.plugins.schemescript, 44 | org.schemeway.plugins.schemescript.action, 45 | org.schemeway.plugins.schemescript.debug, 46 | org.schemeway.plugins.schemescript.dialogs, 47 | org.schemeway.plugins.schemescript.dictionary, 48 | org.schemeway.plugins.schemescript.editor, 49 | org.schemeway.plugins.schemescript.editor.autoedits, 50 | org.schemeway.plugins.schemescript.editor.outline, 51 | org.schemeway.plugins.schemescript.indentation, 52 | org.schemeway.plugins.schemescript.interpreter, 53 | org.schemeway.plugins.schemescript.parser, 54 | org.schemeway.plugins.schemescript.preferences, 55 | org.schemeway.plugins.schemescript.tools, 56 | org.schemeway.plugins.schemescript.views, 57 | org.schemeway.plugins.schemescript.wizards, 58 | sisc, 59 | sisc.boot, 60 | sisc.compiler, 61 | sisc.data, 62 | sisc.env, 63 | sisc.exprs, 64 | sisc.exprs.fp, 65 | sisc.interpreter, 66 | sisc.io, 67 | sisc.libs, 68 | sisc.libs.srfi, 69 | sisc.modules, 70 | sisc.modules.hashtable, 71 | sisc.modules.io, 72 | sisc.modules.record, 73 | sisc.modules.s2j, 74 | sisc.nativefun, 75 | sisc.reader, 76 | sisc.ser, 77 | sisc.util 78 | Require-Bundle: org.eclipse.core.runtime, 79 | org.eclipse.ui, 80 | org.eclipse.jface.text, 81 | org.eclipse.ui.editors, 82 | org.eclipse.core.resources, 83 | org.eclipse.ui.ide, 84 | org.eclipse.ui.workbench.texteditor, 85 | org.eclipse.debug.core, 86 | org.eclipse.debug.ui, 87 | org.eclipse.ui.console, 88 | org.eclipse.ui.views, 89 | org.eclipse.help, 90 | org.eclipse.jdt, 91 | org.eclipse.jdt.core, 92 | org.eclipse.jdt.ui, 93 | org.eclipse.jdt.debug, 94 | org.eclipse.jdt.debug.ui, 95 | org.eclipse.ui.forms, 96 | org.eclipse.search, 97 | org.eclipse.core.variables 98 | Eclipse-LazyStart: true 99 | -------------------------------------------------------------------------------- /plugin/build.properties: -------------------------------------------------------------------------------- 1 | bin.includes = plugin.xml,\ 2 | COPYING,\ 3 | license.html,\ 4 | conf/,\ 5 | ChangeLog,\ 6 | KnownBugs,\ 7 | html/,\ 8 | toc.xml,\ 9 | icons/,\ 10 | plugin.properties,\ 11 | examples/,\ 12 | META-INF/,\ 13 | schema/,\ 14 | schemescript.jar,\ 15 | lib/ 16 | src.includes = src/,\ 17 | plugin.xml,\ 18 | license.html,\ 19 | icons/,\ 20 | build.properties,\ 21 | COPYING,\ 22 | .project,\ 23 | .classpath,\ 24 | conf/,\ 25 | ChangeLog,\ 26 | KnownBugs,\ 27 | html/,\ 28 | toc.xml,\ 29 | lib/,\ 30 | plugin.properties,\ 31 | examples/ 32 | jars.compile.order = schemescript.jar 33 | bin.excludes = examples/sisc/circles-sisc.scm,\ 34 | examples/sisc/circles-sisc.old,\ 35 | examples/sisc/scratchpad-sisc.old,\ 36 | examples/sisc/scratchpad-sisc.scm,\ 37 | examples/sisc/sedna.scm 38 | source.schemescript.jar = src/ 39 | output.schemescript.jar = bin/ 40 | -------------------------------------------------------------------------------- /plugin/conf/bundles.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; Bundle-related definitions 3 | ;;; 4 | ;; 5 | ;; @created "Thu Apr 06 13:51:37 EDT 2006" 6 | ;; @author "Dominique Boucher" 7 | ;; @copyright "(c) 2006 Nu Echo Inc. All rights reserved." 8 | ;; 9 | 10 | 11 | (define-namespace Platform "class:org.eclipse.core.runtime.Platform") 12 | (define-namespace Bundle "class:org.osgi.framework.Bundle") 13 | 14 | ;; The platform (win32, linux, etc.) 15 | (define *platform* (Platform:getOS)) 16 | 17 | ;; The architecture 18 | (define *architecture* (Platform:getOSArch)) 19 | 20 | ;; The path separator 21 | (define *path-separator* 22 | (cond ((equal? (Platform:getOS) 'win32) ";") 23 | (else ":"))) 24 | 25 | 26 | ;; Returns the absolute filename of a bundle entry, if it exists 27 | ;; @param bundle-name a symbol 28 | ;; @param entry a string 29 | ;; @returns the filename (a string) or #f 30 | (define (locate-bundle-entry bundle-name entry) 31 | (let* ((bundle (find-bundle bundle-name))) 32 | (and bundle 33 | (let ((entry (Bundle:getEntry bundle entry))) 34 | (and (not (eq? entry #!null)) 35 | (let ((url-string (symbol->string (Platform:asLocalURL entry)))) 36 | (cond ((and (equal? *platform* 'win32) (starts-with "file:/" url-string)) 37 | (substring url-string 6 (string-length url-string))) 38 | ((starts-with "file:" url-string) 39 | (substring url-string 5 (string-length url-string))) 40 | (else 41 | url-string)))))))) 42 | 43 | 44 | ;; Finds the given bundle by name 45 | ;; @param name a symbol 46 | ;; @returns a bundle object (Bundle) or #f 47 | (define (find-bundle name) 48 | (let ((bundle (Platform:getBundle name))) 49 | (and (not (eq? bundle #!null)) bundle))) 50 | 51 | -------------------------------------------------------------------------------- /plugin/conf/codewalkers.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; Code walkers 3 | ;;; 4 | ;; 5 | ;; @created "Wed Jul 12 15:26:16 EDT 2006" 6 | ;; 7 | 8 | 9 | (define current-dictionary-entry (make-parameter #!null)) 10 | 11 | 12 | ;;; 13 | ;;;; Helpers 14 | ;;; 15 | 16 | 17 | (define (new-dictionary-entry resource stx-obj category description #!optional (name #f)) 18 | (let* ((name (or name (stx-object-data stx-obj))) 19 | (entry (SymbolEntry:new name description category resource (stx-object-offset stx-obj) (stx-object-length stx-obj) 0))) 20 | (SymbolEntry:setParent entry (current-dictionary-entry)) 21 | (add-dictionary-entry name entry) 22 | entry)) 23 | 24 | 25 | ;;; 26 | ;;;; Entry point 27 | ;;; 28 | 29 | 30 | (define (walk-definitions resource stx-object) 31 | 32 | (define (recurse obj) 33 | (cond ((stx-object? obj) 34 | (scan-object obj)) 35 | ((and (list? obj) 36 | (every stx-object? obj)) 37 | (scan-objects obj)))) 38 | 39 | (define (scan-objects stx-objs) 40 | (let loop ((stx-objs stx-objs)) 41 | (cond ((pair? stx-objs) 42 | (scan-object (car stx-objs)) 43 | (loop (cdr stx-objs))) 44 | (else 45 | (when (not (null? stx-objs)) 46 | (scan-object stx-objs)))))) 47 | 48 | (define (scan-object stx-obj) 49 | (stx-match stx-obj 50 | ((,rator . ,rands) 51 | (if (stx-symbol? rator) 52 | (let* ((sym (stx-object-data rator)) 53 | (walker (get-code-walker sym))) 54 | (when walker 55 | (walker stx-obj resource recurse))) 56 | (begin 57 | (scan-object rator) 58 | (scan-objects rands)))) 59 | 60 | (_ #t))) 61 | 62 | (scan-object stx-object)) 63 | 64 | 65 | ;;; 66 | ;;;; Code walkers 67 | ;;; 68 | 69 | 70 | (define *code-walkers* (make-hash-table)) 71 | 72 | (define (get-code-walker symbol) 73 | (hash-table-ref/default *code-walkers* symbol #f)) 74 | 75 | 76 | (define (define-code-walker symbol-or-symbols proc) 77 | (let ((symbols (if (list? symbol-or-symbols) symbol-or-symbols (list symbol-or-symbols)))) 78 | (for-each (lambda (symbol) 79 | (hash-table-set! *code-walkers* symbol proc)) 80 | symbols))) 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /plugin/conf/constants.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; Constants 3 | ;;; 4 | ;; 5 | ;; @created "Thu Mar 10 11:27:34 EST 2005" 6 | ;; @author "Dominique Boucher" 7 | ;; @copyright "NuEcho Inc." 8 | ;; 9 | 10 | (define-constant *DIALOG-STYLE* :: (+ (SWT:.DIALOG_TRIM) (SWT:.APPLICATION_MODAL))) 11 | 12 | (define-constant *BUTTON-WIDTH* :: 75) 13 | (define-constant *DIALOG-MARGIN-WIDTH* :: 5) 14 | (define-constant *DIALOG-MARGIN-HEIGHT* :: 5) 15 | (define-constant *BUTTON-SPACING* :: 5) 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /plugin/conf/languages/arc.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; Arc-specific configurations 3 | ;;; 4 | ;; 5 | ;; @created "Tue Feb 05 12:33:50 EST 2008" 6 | ;; 7 | 8 | 9 | (def-indentation-rule 'def 'with 2) 10 | (def-indentation-rule 'defset 'with 2) 11 | (def-indentation-rule 'defmemo 'with 2) 12 | (def-indentation-rule 'mac 'with 2) 13 | (def-indentation-rule 'defop 'with 2) 14 | (def-indentation-rule 'deftem 'with 1) 15 | (for-each (cut def-indentation-rule <> 'with 1) '(w/uniq w/table w/outstring w/stdout w/stdin)) 16 | (for-each (cut def-indentation-rule <> 'with 2) '(w/infile w/outfile w/instring w/appendfile)) 17 | 18 | 19 | 20 | (def-constant 'nil) 21 | (def-define '= 'def 'mac 'defmemo 'set 'defset 'defop 'deftem) 22 | (def-special '++ '-- 'and 'or 'atlet 'after 'in 'rfn 'afn 'fn 'compose 23 | 'complement 'w/uniq 'atomic 'atwith 'atwiths 24 | 'each 'do1 'caselet 'case 25 | 'loop 'on 'or= 'repeat 'push 'pull 'pop 'swap 'rotate 'pushnew 26 | 'zap 'nil! 't! 'if-let 'aif 'awhen 'aand 'accum 'drain 'default 27 | 'w/infile 'w/outfile 'w/instring 'w/outstring 'w/appendfile 28 | 'w/stdout 'w/stdin 'tostring 'fromstring 'rand-choice 29 | 'n-of 'insort 'insortnew 'summing 'obj 'time 'jtime 30 | 'time10 'errsafe 'until 'nor 'conswhen 'prf 31 | 'w/table 'noisy-each 'point 'catch 'w/bars 32 | 'help 'for 'forlen 'when 'when-let 'while 'whiler 'whilet 'with 'withs) 33 | 34 | 35 | (define-code-walker '(module) 36 | (lambda (stx resource recurse) 37 | (stx-match stx 38 | ((_ ,name ,base-language . ,body) 39 | (recurse body))))) 40 | 41 | 42 | ;;; 43 | ;;;; Code walkers 44 | ;;; 45 | 46 | 47 | (define-code-walker '(def defset defmemo) 48 | (lambda (stx resource recurse) 49 | (stx-match stx 50 | ((_ ,name ,args . ,body) 51 | (when (stx-symbol? name) 52 | (let ((proto (cl-prototype (stx-object->datum name) (stx-object->datum args) 'procedure))) 53 | (parameterize ((current-dictionary-entry (new-dictionary-entry resource name 'procedure proto))) 54 | (recurse body)))))))) 55 | 56 | 57 | (define-code-walker '(mac) 58 | (lambda (stx resource recurse) 59 | (stx-match stx 60 | ((_ ,name ,args . ,body) 61 | (when (stx-symbol? name) 62 | (let ((proto (cl-prototype (stx-object->datum name) (stx-object->datum args) 'macro))) 63 | (parameterize ((current-dictionary-entry (new-dictionary-entry resource name 'macro proto))) 64 | (recurse body)))))))) 65 | 66 | 67 | (define-code-walker '(= set) 68 | (lambda (stx resource recurse) 69 | (stx-match stx 70 | ((_ . ,bindings) 71 | (let loop ((bindings bindings)) 72 | (if (and (pair? bindings) 73 | (pair? (cdr bindings))) 74 | (let ((name (car bindings)) 75 | (val (cadr bindings))) 76 | (when (and (stx-symbol? name) (eq? #!null (current-dictionary-entry))) 77 | (parameterize ((current-dictionary-entry (new-dictionary-entry resource name 'variable (symbol-description name)))) 78 | (recurse val))) 79 | (loop (cddr bindings))))))))) 80 | 81 | 82 | -------------------------------------------------------------------------------- /plugin/conf/languages/clojure.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; Clojure-related definitions 3 | ;;; 4 | ;; 5 | ;; @created "Mon Sep 07 21:41:23 EDT 2009" 6 | ;; 7 | 8 | (def-indentation-rule 'def 'definition 0) 9 | (def-indentation-rule 'defn 'definition 0) 10 | 11 | 12 | (def-constant 'nil 'true 'false) 13 | (def-define 'def 'defn) 14 | (def-special 'var 'try 'catch 'throw 'finally 'loop 'recur) 15 | 16 | (define-code-walker '(def) 17 | (lambda (stx resource recurse) 18 | (stx-match stx 19 | ((_ ,var . ,rest) 20 | (when (stx-symbol? var) 21 | (parameterize ((current-dictionary-entry (new-dictionary-entry resource var 'variable (symbol-description var)))) 22 | (recurse rest))))))) 23 | 24 | (define-code-walker '(defn) 25 | (lambda (stx resource recurse) 26 | (stx-match stx 27 | ((_ ,name ,args . ,body) 28 | (when (stx-symbol? name) 29 | (let ((proto (cl-prototype (stx-object->datum name) (stx-object->datum args) 'procedure))) 30 | (parameterize ((current-dictionary-entry (new-dictionary-entry resource name 'procedure proto))) 31 | (recurse body)))))))) 32 | 33 | (define-code-walker '(defmulti) 34 | (lambda (stx resource recurse) 35 | (stx-match stx 36 | ((_ ,name ,dispatch) 37 | (when (stx-symbol? name) 38 | (let ((proto (cl-prototype (stx-object->datum name) "[]" 'multi-method))) 39 | (parameterize ((current-dictionary-entry (new-dictionary-entry resource name 'procedure proto))) 40 | (recurse body)))))))) 41 | -------------------------------------------------------------------------------- /plugin/conf/languages/kawa.scm: -------------------------------------------------------------------------------- 1 | ;; Kawa dictionary for SchemeScript 2 | 3 | (dictionary-entry 'module-name "(module-name symbol)" 'syntax 1) 4 | (dictionary-entry 'module-static "(module-static [boolean|'init-run])" 'syntax) 5 | (dictionary-entry 'module-export "(module-exports symbol ...)" 'syntax) 6 | (dictionary-entry 'module-extends "(module-extends )" 'syntax) 7 | (dictionary-entry 'module-implements "(module-implements ...)" 'syntax) 8 | (dictionary-entry 'module-compile-options "(module-compile-options [key: value] ...)" 'syntax) 9 | (dictionary-entry 'require "(require modulespec)" 'syntax 1) 10 | (dictionary-entry 'define-private "(define-private name [:: ] value)" 'syntax) 11 | (dictionary-entry 'define-constant "(define-constant name [:: ] value)" 'syntax) 12 | (dictionary-entry 'define-namespace "(define-namespace name namespace-uri)" 'syntax 1) 13 | (dictionary-entry 'define-alias "(define-alias name type)" 'syntax 1) 14 | (dictionary-entry 'define-simple-class "(define-simple-class name (type ...) fields/methods ...)" 'syntax 1) 15 | (dictionary-entry 'define-class "(define-class name (type ...) fields/methods ...)" 'syntax) 16 | (dictionary-entry 'object "(object (type ...) fields/methods...)" 'syntax 1) 17 | (dictionary-entry 'make "(make type args ...)" 'function 1) 18 | (dictionary-entry 'instance? "(instance? value type)" 'function) 19 | (dictionary-entry 'invoke "(invoke object name args ...)" 'function 1) 20 | (dictionary-entry 'invoke-static "(invoke-static class name args ...)" 'function 1) 21 | (dictionary-entry 'invoke-special "(invoke-special class receiver name args ...)" 'function 1) 22 | (dictionary-entry 'field "(field object field-name)" 'function 1) 23 | (dictionary-entry 'static-field "(static-field class field-name)" 'function 1) 24 | (dictionary-entry 'slot-ref "(slot-ref object field-name)" 'function 1) 25 | (dictionary-entry 'slot-set! "(slot-set! object field-name value)" 'function 1) 26 | (dictionary-entry 'try-catch "(try-catch body handler ...)" 'syntax 1) 27 | (dictionary-entry 'try-finally "(try-finally body handler)" 'syntax 1) 28 | (dictionary-entry 'primitive-throw "(primitive-throw exception)" 'function) 29 | (dictionary-entry 'catch "(catch key thunk handler)" 'syntax 1) 30 | (dictionary-entry 'throw "(throw key args ...)" 'function 1) 31 | (dictionary-entry 'error "(error message args ...)" 'syntax 1) 32 | (dictionary-entry 'when "(when condition form ...)" 'syntax) 33 | (dictionary-entry 'unless "(unless condition form ...)" 'syntax) 34 | (dictionary-entry 'define-record-type "(define-record-type name cstor pred? fields ...)" 'syntax 1) 35 | (dictionary-entry 'defmacro "(defmacro name body ...)" 'syntax) 36 | (dictionary-entry 'cond-expand "(cond-expand [clause...] [(else command-or-definition...)])" 'syntax) 37 | (dictionary-entry 'gentemp "(gentemp)" 'function) 38 | (dictionary-entry 'values-append "(values-append arg ...)" 'function) 39 | (dictionary-entry 'receive "(receive formals expression body)" 'syntax) 40 | (dictionary-entry 'keyword? "(keyword? expr)" 'function) 41 | (dictionary-entry 'keyword->string "(keyword->string keyword)" 'function) 42 | (dictionary-entry 'string->keyword "(string->keyword string)" 'function) 43 | (dictionary-entry 'cut "(cut slot-or-expr slot-or-expr* [<...>])" 'syntax) 44 | (dictionary-entry 'cute "(cute slot-or-expr slot-or-expr* [<...>])" 'syntax) 45 | -------------------------------------------------------------------------------- /plugin/conf/languages/r6rs.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; R6RS dictionary 3 | ;;; 4 | ;; 5 | ;; @created "Fri Nov 16 15:28:22 EST 2007" 6 | ;; 7 | 8 | 9 | 10 | (dictionary-entry 'library "(library (export ...) (import ...) body ...)" 'syntax 1) 11 | (dictionary-entry 'import "(import ...)" 'syntax 1) 12 | (dictionary-entry 'export "(export ...)" 'syntax 1) -------------------------------------------------------------------------------- /plugin/conf/languages/snow.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; Snow dictionary 3 | ;;; 4 | ;; 5 | ;; @created "Fri Nov 16 15:33:34 EST 2007" 6 | ;; 7 | 8 | (dictionary-entry 'package* "(package* body ...)" 'syntax 0) 9 | (dictionary-entry 'define* "(define name value)" 'syntax 0) 10 | (dictionary-entry 'define-macro* "(define-macro* name body)" 'syntax 0) 11 | (dictionary-entry 'define-syntax* "(define-syntax* name body)" 'syntax 0) 12 | (dictionary-entry 'include* "(include* filename)" 'syntax 0) 13 | 14 | -------------------------------------------------------------------------------- /plugin/conf/macros.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; Macros 3 | ;;; 4 | ;; 5 | ;; @created "Tue Mar 08 09:02:09 EST 2005" 6 | ;; @author "Dominique Boucher" 7 | ;; @copyright "NuEcho Inc." 8 | ;; 9 | 10 | 11 | (define-syntax while 12 | (syntax-rules () 13 | ((while expr body ...) 14 | (let loop () 15 | (when expr 16 | body ... 17 | (loop)))))) 18 | 19 | -------------------------------------------------------------------------------- /plugin/conf/plugin.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; Plugin related functions 3 | ;;; 4 | ;; 5 | ;; @created "Tue Feb 05 15:59:03 EST 2008" 6 | ;; 7 | 8 | (define-namespace SchemeScriptPlugin ) 9 | (define-namespace SchemeTextTools ) 10 | (define-namespace SchemeIndentationManager ) 11 | (define-namespace IndentationRule ) 12 | (define-namespace KeywordManager ) 13 | 14 | 15 | (define (schemescript-plugin) 16 | (SchemeScriptPlugin:getDefault)) 17 | 18 | 19 | (define (schemescript-preference-store) 20 | (SchemeScriptPlugin:getPreferenceStore (schemescript-plugin))) 21 | 22 | 23 | (define (schemescript-indentation-manager) 24 | (SchemeTextTools:getIndentationManager 25 | (SchemeScriptPlugin:getTextTools 26 | (schemescript-plugin)))) 27 | 28 | 29 | (define (reset-indentation-rules) 30 | (SchemeIndentationManager:loadRules schemescript-indentation-manager)) 31 | 32 | 33 | (define (def-indentation-rule sym category hint) 34 | (when (and (symbol? sym) 35 | (memq category '(default definition sequence if with none)) 36 | (integer? 0) 37 | (>= hint 0)) 38 | (let ((new-rule (IndentationRule:new sym category hint))) 39 | (SchemeIndentationManager:addIndentationRule (schemescript-indentation-manager) new-rule)))) 40 | 41 | 42 | (define (schemescript-keyword-manager) 43 | (SchemeTextTools:getKeywordManager 44 | (SchemeScriptPlugin:getTextTools 45 | (schemescript-plugin)))) 46 | 47 | 48 | (define (def-keyword . kwds) 49 | (for-each (cut KeywordManager:addKeyword (schemescript-keyword-manager) <>) kwds)) 50 | 51 | (define (def-special . names) 52 | (for-each (cut KeywordManager:addSpecial (schemescript-keyword-manager) <>) names)) 53 | 54 | (define (def-define . names) 55 | (for-each (cut KeywordManager:addDefine (schemescript-keyword-manager) <>) names)) 56 | 57 | (define (def-constant . objs) 58 | (for-each (cut KeywordManager:addConstant (schemescript-keyword-manager) <>) objs)) 59 | 60 | (define (def-mutator . names) 61 | (for-each (cut KeywordManager:addMutator (schemescript-keyword-manager) <>) names)) 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /plugin/conf/scratchpad.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; Interface to the Kawa Scratchpad View 3 | ;;; 4 | ;; 5 | ;; @created "Tue Mar 15 10:19:54 EST 2005" 6 | ;; @author "Dominique Boucher" 7 | ;; @copyright "NuEcho Inc." 8 | ;; 9 | ;; The Kawa Scratchpad is a view that allows developers to test their SWT/JFace controls 10 | ;; without opening a new top-level shell window. 11 | 12 | 13 | (define-namespace KawaScratchpadView "class:org.schemeway.plugins.schemescript.views.KawaScratchpadView") 14 | (define-namespace Control "class:org.eclipse.swt.widgets.Control") 15 | 16 | 17 | ;;; 18 | ;;;; * Interface to the Kawa scratchpad View 19 | ;;; 20 | 21 | ;; @function (add-scratchpad-view name factory) 22 | ;; This function adds a new page to the Kawa Scratchpad View. 23 | ;; @param name the name of the view (a string or symbol) 24 | ;; @param factory a one argument function that creates the control to be placed 25 | ;; as a new page in the Scratchpad view. The argument to the function is 26 | ;; the parent Composite. The function must return a SWT Control object. 27 | ;; @return the control inserted in the Kawa Scratchpad View. 28 | (define (add-scratchpad-view name factory) 29 | (let* ((parent (KawaScratchpadView:getControl)) 30 | (control (factory parent))) 31 | (KawaScratchpadView:addView name control) 32 | control)) 33 | 34 | 35 | ;; @function (show-scratchpad) 36 | ;; Displays the Kawa Scratchpad View 37 | (define (show-scratchpad) 38 | (let ((control (KawaScratchpadView:getControl))) 39 | (Control:setFocus control))) 40 | 41 | -------------------------------------------------------------------------------- /plugin/conf/stxmatch.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; Pattern-matching on syntax objects 3 | ;;; 4 | ;; 5 | ;; @created "Mon Jun 12 13:49:29 EDT 2006" 6 | ;; @author "Dominique Boucher" 7 | ;; 8 | ;; This is a very simple-minded pattern-matcher for the 9 | ;; Scheme editor syntax objects. 10 | 11 | 12 | (define (unquote-pattern? pattern) 13 | (and (list? pattern) 14 | (= (length pattern) 2) 15 | (symbol? (cadr pattern)) 16 | (eq? 'unquote (car pattern)))) 17 | 18 | 19 | (define (predicate-pattern? pattern) 20 | (and (list? pattern) 21 | (= (length pattern) 2) 22 | (eq? '? (car pattern)) 23 | (symbol? (caddr pattern)))) 24 | 25 | 26 | (define (stx-match-pattern stx-obj pattern proc) 27 | (define variable-values '()) 28 | 29 | (define (add-variable-value val) 30 | (set! variable-values (cons val variable-values))) 31 | 32 | (define (fail) (throw 'no-match)) 33 | 34 | (define (match-pairs stx-objs pattern) 35 | (cond ((unquote-pattern? pattern) 36 | (add-variable-value stx-objs)) 37 | ((and (pair? stx-objs) (pair? pattern)) 38 | (match-pattern (car stx-objs) (car pattern)) 39 | (match-pairs (cdr stx-objs) (cdr pattern))) 40 | ((and (null? stx-objs) (null? pattern)) 41 | #t) 42 | (else 43 | (fail)))) 44 | 45 | 46 | (define (match-pattern stx-obj pattern) 47 | (cond ((unquote-pattern? pattern) 48 | (add-variable-value stx-obj)) 49 | 50 | ((pair? pattern) 51 | (if (stx-list? stx-obj) 52 | (match-pairs (stx-object-data stx-obj) pattern) 53 | (fail))) 54 | 55 | ((eq? '_ pattern) 56 | #t) 57 | 58 | ((and (symbol? pattern) (stx-symbol? stx-obj)) 59 | (or (equal? pattern (stx-object-data stx-obj)) 60 | (fail))) 61 | 62 | (else 63 | (fail) 64 | ;; (error (format #f "invalid pattern: ~S" pattern)) 65 | ))) 66 | 67 | (catch 'no-match 68 | (lambda () 69 | (match-pattern stx-obj pattern) 70 | (apply proc (reverse variable-values))) 71 | (lambda (key . vals) 72 | #f))) 73 | 74 | 75 | (define (extract-pattern-variables pattern) 76 | ;; TODO: process vectors 77 | (define variables '()) 78 | 79 | (define (add-variable v) 80 | (set! variables (cons v variables))) 81 | 82 | (define (process-pairs pattern) 83 | (cond ((unquote-pattern? pattern) 84 | (add-variable (cadr pattern))) 85 | ((pair? pattern) 86 | (process-pattern (car pattern)) 87 | (process-pairs (cdr pattern))))) 88 | 89 | (define (process-pattern pattern) 90 | (cond ((unquote-pattern? pattern) 91 | (add-variable (cadr pattern))) 92 | ((pair? pattern) 93 | (process-pairs pattern)))) 94 | 95 | (process-pattern pattern) 96 | (reverse variables)) 97 | 98 | 99 | (define-macro (stx-match obj . clauses) 100 | (let ((obj-var (gentemp))) 101 | `(let ((,obj-var ,obj)) 102 | (or ,@(map (lambda (clause) 103 | `(stx-match-pattern 104 | ,obj-var 105 | ',(car clause) 106 | (lambda ,(extract-pattern-variables (car clause)) 107 | ,@(cdr clause)))) 108 | clauses))))) 109 | 110 | -------------------------------------------------------------------------------- /plugin/conf/user.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; User initialization file 3 | ;;; 4 | ;; 5 | ;; @created "Tue Mar 15 10:17:44 EST 2005" 6 | ;; @author "Dominique Boucher" 7 | ;; @copyright "NuEcho Inc." 8 | ;; 9 | 10 | 11 | ;;; 12 | ;;;; * System initializations 13 | ;;; 14 | 15 | (require 'srfi-1) 16 | (require 'srfi-69) 17 | 18 | ;; -- DO NOT REMOVE THE FOLLOWING LINES -- 19 | (load-relative "macros.scm") 20 | (load-relative "util.scm") 21 | (load-relative "plugin.scm") 22 | (load-relative "foreign.scm") 23 | (load-relative "bundles.scm") 24 | (load-relative "constants.scm") 25 | (load-relative "buffer.scm") 26 | (load-relative "commands.scm") 27 | (load-relative "widgets.scm") 28 | (load-relative "dialogs.scm") 29 | (load-relative "namespaces.scm") 30 | (load-relative "modules.scm") 31 | (load-relative "markers.scm") 32 | (load-relative "scratchpad.scm") 33 | (load-relative "reader.scm") 34 | (load-relative "stxmatch.scm") 35 | (load-relative "codewalkers.scm") 36 | (load-relative "forms.scm") 37 | (load-relative "refactoring.scm") 38 | (load-relative "dictionaries.scm") 39 | 40 | 41 | 42 | ;; -- ADD YOUR OWN INITIALIZATIONS HERE 43 | ;;; 44 | ;;;; * User initializations 45 | ;;; 46 | 47 | ;; uncomment the next line to enable Arc support 48 | ;(load-relative "languages/arc.scm") 49 | 50 | ;; uncomment the next line to enable Clojure support 51 | ;(load-relative "languages/clojure.scm") -------------------------------------------------------------------------------- /plugin/conf/util.scm: -------------------------------------------------------------------------------- 1 | ;;; 2 | ;;;; Utility functions 3 | ;;; 4 | ;; 5 | ;; @created "Mon Mar 07 09:11:32 EST 2005" 6 | ;; @author "Dominique Boucher" 7 | ;; @copyright "NuEcho Inc." 8 | ;; 9 | 10 | 11 | (define (array->list (array :: )) 12 | (let ((array-get (primitive-array-get ))) 13 | (let loop ((index :: (- ((primitive-array-length ) array) 1)) 14 | (result '())) 15 | (if (>= index 0) 16 | (loop (- index 1) (cons (array-get array index) result)) 17 | result)))) 18 | 19 | 20 | (define (list->array (lst :: ) #!optional (type )) 21 | (let* ((len :: (length lst)) 22 | (array ((primitive-array-new type) len)) 23 | (array-set (primitive-array-set type)) 24 | (index :: 0)) 25 | (for-each (lambda (elt) 26 | (array-set array index elt) 27 | (set! index (+ index 1))) 28 | lst) 29 | array)) 30 | 31 | 32 | (define (classname->pathname classname) 33 | (string-replace classname #\. #\/)) 34 | 35 | 36 | (define (string-replace str (ch-src :: ) (ch-dst :: )) 37 | (symbol->string (java.lang.String:replace (string->symbol str) ch-src ch-dst))) 38 | 39 | 40 | (define (starts-with (s1 :: ) (s2 :: )) :: 41 | (and (string? s1) 42 | (string? s2) 43 | (>= (string-length s2) (string-length s1)) 44 | (let ((n1 :: (string-length s1))) 45 | (string=? s1 (substring s2 0 n1))))) 46 | 47 | -------------------------------------------------------------------------------- /plugin/html/images/appearprefs.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/appearprefs.JPG -------------------------------------------------------------------------------- /plugin/html/images/commentprefs.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/commentprefs.JPG -------------------------------------------------------------------------------- /plugin/html/images/console.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/console.JPG -------------------------------------------------------------------------------- /plugin/html/images/defview.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/defview.JPG -------------------------------------------------------------------------------- /plugin/html/images/errorlink.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/errorlink.JPG -------------------------------------------------------------------------------- /plugin/html/images/eval.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/eval.JPG -------------------------------------------------------------------------------- /plugin/html/images/fasteval.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/fasteval.JPG -------------------------------------------------------------------------------- /plugin/html/images/findsymbol.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/findsymbol.JPG -------------------------------------------------------------------------------- /plugin/html/images/indentprefs.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/indentprefs.JPG -------------------------------------------------------------------------------- /plugin/html/images/interpreter.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/interpreter.JPG -------------------------------------------------------------------------------- /plugin/html/images/lexicalprefs.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/lexicalprefs.JPG -------------------------------------------------------------------------------- /plugin/html/images/menu.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/menu.JPG -------------------------------------------------------------------------------- /plugin/html/images/nuecho.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/nuecho.jpg -------------------------------------------------------------------------------- /plugin/html/images/perspectivebar.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/perspectivebar.JPG -------------------------------------------------------------------------------- /plugin/html/images/remoteinterp.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/remoteinterp.JPG -------------------------------------------------------------------------------- /plugin/html/images/run.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/run.JPG -------------------------------------------------------------------------------- /plugin/html/images/schemeprefs.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/schemeprefs.JPG -------------------------------------------------------------------------------- /plugin/html/images/scratchpad.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/scratchpad.JPG -------------------------------------------------------------------------------- /plugin/html/images/selectperspective.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/selectperspective.JPG -------------------------------------------------------------------------------- /plugin/html/images/stacktrace.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/stacktrace.JPG -------------------------------------------------------------------------------- /plugin/html/images/start.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/start.JPG -------------------------------------------------------------------------------- /plugin/html/images/syntaxprefs.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/syntaxprefs.JPG -------------------------------------------------------------------------------- /plugin/html/images/toolbar.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/html/images/toolbar.JPG -------------------------------------------------------------------------------- /plugin/html/toc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | SchemeScript User Guide 7 | 8 | 9 | 10 | 11 |

SchemeScript User Guide

12 | 13 | SchemeScript is an industrial-strength Scheme editor plug-in for Eclipse.

14 | 15 | The UserGuide has been moved to our github repo's wiki 16 | 17 |
18 |

19 | Copyright (C) Dominique Boucher. 20 |

21 | 22 | 23 | -------------------------------------------------------------------------------- /plugin/icons/chapter.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/chapter.gif -------------------------------------------------------------------------------- /plugin/icons/definition.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/definition.gif -------------------------------------------------------------------------------- /plugin/icons/interruptScheme.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/interruptScheme.gif -------------------------------------------------------------------------------- /plugin/icons/remove.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/remove.gif -------------------------------------------------------------------------------- /plugin/icons/removeAll.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/removeAll.gif -------------------------------------------------------------------------------- /plugin/icons/restartScheme.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/restartScheme.gif -------------------------------------------------------------------------------- /plugin/icons/scheme.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/scheme.gif -------------------------------------------------------------------------------- /plugin/icons/schemeway.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/schemeway.gif -------------------------------------------------------------------------------- /plugin/icons/search.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/search.gif -------------------------------------------------------------------------------- /plugin/icons/section.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/section.gif -------------------------------------------------------------------------------- /plugin/icons/stacktrace/javaStackElement.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/stacktrace/javaStackElement.gif -------------------------------------------------------------------------------- /plugin/icons/stacktrace/schemeStackElement.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/stacktrace/schemeStackElement.gif -------------------------------------------------------------------------------- /plugin/icons/stacktrace/stackElement.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/stacktrace/stackElement.gif -------------------------------------------------------------------------------- /plugin/icons/stacktrace/unknownStackElement.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/stacktrace/unknownStackElement.gif -------------------------------------------------------------------------------- /plugin/icons/startScheme.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/icons/startScheme.gif -------------------------------------------------------------------------------- /plugin/lib/kawa.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/lib/kawa.jar -------------------------------------------------------------------------------- /plugin/lib/sisc-heap.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/lib/sisc-heap.jar -------------------------------------------------------------------------------- /plugin/lib/sisc-lib.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/lib/sisc-lib.jar -------------------------------------------------------------------------------- /plugin/lib/sisc-opt.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/lib/sisc-opt.jar -------------------------------------------------------------------------------- /plugin/lib/sisc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/lib/sisc.jar -------------------------------------------------------------------------------- /plugin/lib/sisc.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schemeway/SchemeScript/HEAD/plugin/lib/sisc.shp -------------------------------------------------------------------------------- /plugin/plugin.properties: -------------------------------------------------------------------------------- 1 | Extensions=sch,scm,ss,ssi,lsp,el,kawa,arc 2 | BrlExtensions=brl,krl -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/SchemeNature.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2003 Nu Echo Inc. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript; 5 | 6 | import org.eclipse.core.resources.*; 7 | import org.eclipse.core.runtime.*; 8 | 9 | /** 10 | * @author Nu Echo Inc. 11 | */ 12 | public class SchemeNature implements IProjectNature 13 | { 14 | private IProject mProject; 15 | 16 | public SchemeNature() 17 | { 18 | System.out.println("test"); 19 | } 20 | 21 | public void configure() throws CoreException 22 | { 23 | System.out.println("Toto"); 24 | } 25 | 26 | public void deconfigure() throws CoreException 27 | { 28 | } 29 | 30 | public IProject getProject() 31 | { 32 | return mProject; 33 | } 34 | 35 | public void setProject(IProject project) 36 | { 37 | mProject = project; 38 | 39 | try 40 | { 41 | IResource[] resources = project.members(); 42 | System.out.println("number of resources = " + resources.length); 43 | } 44 | catch(CoreException exception) 45 | { 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/SchemePerspective.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript; 7 | 8 | import org.eclipse.ui.*; 9 | import org.schemeway.plugins.schemescript.views.*; 10 | 11 | public class SchemePerspective implements IPerspectiveFactory { 12 | 13 | public SchemePerspective() { 14 | super(); 15 | } 16 | 17 | public void createInitialLayout(IPageLayout layout) { 18 | defineActions(layout); 19 | defineLayout(layout); 20 | } 21 | 22 | private void defineLayout(IPageLayout layout) { 23 | String editorArea = layout.getEditorArea(); 24 | 25 | IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, 0.20f, editorArea); 26 | topLeft.addView(IPageLayout.ID_RES_NAV); 27 | 28 | IFolderLayout bottomLeft = layout.createFolder("bottomLeft", IPageLayout.BOTTOM, 0.50f, "topLeft"); 29 | bottomLeft.addView(IPageLayout.ID_OUTLINE); 30 | 31 | layout.addFastView(DefinitionListView.DEFINITION_LIST_ID); 32 | layout.addFastView("org.eclipse.ui.console.ConsoleView"); 33 | } 34 | 35 | private void defineActions(IPageLayout layout) { 36 | // Add "new wizards". 37 | layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$ 38 | layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$ 39 | 40 | // Add "show views". 41 | layout.addShowViewShortcut(IPageLayout.ID_RES_NAV); 42 | layout.addShowViewShortcut(IPageLayout.ID_BOOKMARKS); 43 | layout.addShowViewShortcut(IPageLayout.ID_OUTLINE); 44 | layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET); 45 | layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW); 46 | layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST); 47 | 48 | layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/SchemeScriptImageRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript; 7 | 8 | import org.eclipse.core.runtime.Path; 9 | import org.eclipse.jface.resource.*; 10 | import org.eclipse.swt.graphics.*; 11 | 12 | public final class SchemeScriptImageRegistry { 13 | 14 | private SchemeScriptImageRegistry() { 15 | } 16 | 17 | // finds an image in the Plugin 18 | public static Image getImage(String relativePath) { 19 | 20 | ImageDescriptor descriptor = getImageDescriptor(relativePath); 21 | if (descriptor == null) 22 | return null; 23 | return descriptor.createImage(); 24 | } 25 | 26 | public static ImageDescriptor getImageDescriptor(String relativePath) { 27 | return ImageDescriptor.createFromURL(SchemeScriptPlugin.findFile(new Path(relativePath))); 28 | } 29 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/SchemeScriptTools.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript; 7 | 8 | import java.io.*; 9 | 10 | import org.eclipse.core.resources.*; 11 | import org.eclipse.core.runtime.*; 12 | import org.eclipse.jface.text.*; 13 | import org.eclipse.ui.*; 14 | import org.eclipse.ui.ide.*; 15 | import org.schemeway.plugins.schemescript.editor.*; 16 | 17 | public final class SchemeScriptTools { 18 | 19 | private SchemeScriptTools() { 20 | // prevent instantiation 21 | } 22 | 23 | public static IFile findFile(String filename, String baseDirectory) { 24 | if (filename != null && !filename.equals("")) { 25 | File file = new File(filename); 26 | if (!file.isAbsolute()) { 27 | if (baseDirectory == null) 28 | return null; 29 | File directory = new File(baseDirectory); 30 | try { 31 | filename = (new File(directory, filename).getCanonicalPath()); 32 | } 33 | catch (IOException exception) { 34 | return null; 35 | } 36 | } 37 | IWorkspace ws = ResourcesPlugin.getWorkspace(); 38 | IWorkspaceRoot root = ws.getRoot(); 39 | return root.getFileForLocation(new Path(filename)); 40 | } 41 | return null; 42 | } 43 | 44 | public static void openEditor(IFile file, int linenumber) { 45 | try { 46 | IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); 47 | IEditorPart editor; 48 | editor = IDE.openEditor(page, file, true); 49 | if (editor == null) { 50 | return; 51 | } 52 | 53 | if (editor instanceof SchemeEditor) { 54 | SchemeEditor schemeEditor = (SchemeEditor) editor; 55 | try { 56 | int lineStart = schemeEditor.getDocument().getLineOffset(linenumber); 57 | int lineEnd = lineStart + schemeEditor.getDocument().getLineLength(linenumber); 58 | schemeEditor.setSelection(lineStart, lineEnd); 59 | } 60 | catch (BadLocationException exception) { 61 | } 62 | } 63 | } 64 | catch (PartInitException e) { 65 | SchemeScriptPlugin.logException("Unable to open editor", e); 66 | } 67 | } 68 | 69 | public static void openEditor(IFile file, int offset, int length) { 70 | try { 71 | IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); 72 | IEditorPart editor; 73 | editor = IDE.openEditor(page, file, true); 74 | if (editor == null) { 75 | return; 76 | } 77 | 78 | if (editor instanceof SchemeEditor) { 79 | SchemeEditor schemeEditor = (SchemeEditor) editor; 80 | if (length >= 0) { 81 | schemeEditor.setSelection(offset, offset + length); 82 | } 83 | else { 84 | schemeEditor.setSelection(offset, offset); 85 | } 86 | } 87 | } 88 | catch (PartInitException e) { 89 | SchemeScriptPlugin.logException("Unable to open editor", e); 90 | } 91 | 92 | } 93 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/BackwardSExpAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.core.runtime.Assert; 9 | import org.eclipse.jface.text.*; 10 | import org.schemeway.plugins.schemescript.editor.*; 11 | import org.schemeway.plugins.schemescript.parser.*; 12 | 13 | public class BackwardSExpAction extends SchemeAction implements ISchemeEditorAction { 14 | private boolean mSelectExpression; 15 | 16 | public BackwardSExpAction(SchemeEditor editor, boolean selectExpression) { 17 | super(editor); 18 | Assert.isNotNull(editor); 19 | setText("Select Backward Sexp"); 20 | setToolTipText("Selects the previous S-expression"); 21 | mSelectExpression = selectExpression; 22 | } 23 | 24 | public void run() { 25 | SchemeEditor editor = getSchemeEditor(); 26 | if (editor == null) return; 27 | 28 | Region selection = editor.getSelection(); 29 | int selectionEnd = selection.getOffset() + selection.getLength(); 30 | SexpNavigator explorer = editor.getExplorer(); 31 | if (explorer.backwardSexpression(selection.getOffset())) { 32 | int start = explorer.getSexpStart(); 33 | if (mSelectExpression) { 34 | editor.setSelection(start, selectionEnd); 35 | } 36 | else { 37 | editor.setPoint(start); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/ChooseInterpreterAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.action.*; 9 | import org.eclipse.jface.viewers.*; 10 | import org.eclipse.swt.*; 11 | import org.eclipse.swt.events.*; 12 | import org.eclipse.swt.widgets.*; 13 | import org.eclipse.ui.*; 14 | import org.schemeway.plugins.schemescript.*; 15 | import org.schemeway.plugins.schemescript.interpreter.*; 16 | 17 | public class ChooseInterpreterAction implements IWorkbenchWindowPulldownDelegate2 { 18 | 19 | private Menu mMainMenu = null; 20 | private MenuItem mSelectedItem = null; 21 | 22 | public ChooseInterpreterAction() { 23 | super(); 24 | } 25 | 26 | public void dispose() { 27 | if (mMainMenu != null) 28 | mMainMenu.dispose(); 29 | } 30 | 31 | public void init(IWorkbenchWindow window) { 32 | } 33 | 34 | public Menu getMenu(Control parent) { 35 | return null; 36 | } 37 | public Menu getMenu(Menu parent) { 38 | InterpreterType[] types = InterpreterSupport.getTypes(); 39 | Menu menu = new Menu(parent); 40 | for (int i = 0; i < types.length; i++) { 41 | final InterpreterType type = types[i]; 42 | final MenuItem item = new MenuItem(menu, SWT.CHECK); 43 | item.setText(type.getName()); 44 | if (type == SchemeScriptPlugin.getDefault().getCurrentInterpreterType()) { 45 | mSelectedItem = item; 46 | item.setSelection(true); 47 | } 48 | item.addSelectionListener(new SelectionAdapter() { 49 | public void widgetSelected(SelectionEvent event) { 50 | item.setSelection(true); 51 | if (mSelectedItem != null) 52 | mSelectedItem.setSelection(false); 53 | mSelectedItem = item; 54 | SchemeScriptPlugin.getDefault().setInterpreter(type); 55 | } 56 | }); 57 | } 58 | mMainMenu = menu; 59 | return menu; 60 | } 61 | 62 | public void run(IAction action) { 63 | } 64 | 65 | public void selectionChanged(IAction action, ISelection selection) { 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/CommentAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | import org.schemeway.plugins.schemescript.preferences.*; 11 | 12 | public class CommentAction extends SchemeAction { 13 | 14 | public CommentAction(SchemeEditor editor) { 15 | super(editor); 16 | setText("Toggle comment"); 17 | setToolTipText("Comment/Uncomment the selected lines"); 18 | } 19 | 20 | public void run() { 21 | SchemeEditor editor = getSchemeEditor(); 22 | if (editor == null) 23 | return; 24 | 25 | try { 26 | final IDocument document = editor.getDocument(); 27 | final Region selection = editor.getSelection(); 28 | 29 | final int startLine = document.getLineOfOffset(selection.getOffset()); 30 | final int endLine = document.getLineOfOffset(selection.getOffset() + selection.getLength()); 31 | if (!(SchemeTextUtilities.getPartition(document, selection.getOffset()).getType() == SchemePartitionScanner.SCHEME_COMMENT) 32 | || (selection.getLength() != 0)) { 33 | editor.runCompoundChange(new Runnable() { 34 | public void run() { 35 | processLines(document, startLine, endLine); 36 | } 37 | }); 38 | } 39 | else { 40 | editor.runCompoundChange(new Runnable() { 41 | public void run() { 42 | removeCommentFromPartition(document, selection.getOffset()); 43 | } 44 | }); 45 | } 46 | } 47 | catch (BadLocationException exception) { 48 | } 49 | } 50 | 51 | private void removeCommentFromPartition(IDocument document, int offset) { 52 | try { 53 | ITypedRegion partition = SchemeTextUtilities.getPartition(document, offset); 54 | 55 | if (partition.getType() == SchemePartitionScanner.SCHEME_COMMENT) { 56 | int partitionOffset = partition.getOffset(); 57 | if (document.getChar(partitionOffset) == ';') { 58 | int commentPrefixEnd = partitionOffset; 59 | while (document.getChar(commentPrefixEnd) == ';') 60 | commentPrefixEnd++; 61 | document.replace(partitionOffset, commentPrefixEnd - partitionOffset, ""); 62 | } 63 | else if (document.get(partitionOffset, 2).equals("#|")) { 64 | document.replace(partitionOffset + partition.getLength() - 2, 2, ""); 65 | document.replace(partitionOffset, 2, ""); 66 | } 67 | else if (document.get(partitionOffset, 2).equals("#;")) { 68 | document.replace(partitionOffset, 2, ""); 69 | } 70 | } 71 | } 72 | catch (BadLocationException e) { 73 | } 74 | } 75 | 76 | private static void processLines(IDocument document, int startLine, int endLine) { 77 | String prefix = CommentPreferences.getCommentPrefix(); 78 | int prefixLength = prefix.length(); 79 | 80 | try { 81 | for (int line = startLine; line <= endLine; line++) { 82 | IRegion lineInfo = document.getLineInformation(line); 83 | int lineOffset = lineInfo.getOffset(); 84 | int lineLength = lineInfo.getLength(); 85 | 86 | if (lineLength >= prefixLength && document.get(lineOffset, prefixLength).equals(prefix)) { 87 | document.replace(lineOffset, prefixLength, ""); 88 | } 89 | else { 90 | if (lineLength > 0) { 91 | document.replace(lineOffset, 0, prefix); 92 | } 93 | } 94 | } 95 | } 96 | catch (BadLocationException exception) { 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/CompressSpacesAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | 11 | public class CompressSpacesAction extends SchemeAction { 12 | 13 | public CompressSpacesAction(SchemeEditor editor) { 14 | super(editor); 15 | setText("Compress spaces"); 16 | setToolTipText("Replaces all surrounding whitespaces by a single space"); 17 | } 18 | 19 | public void run() { 20 | SchemeEditor editor = getSchemeEditor(); 21 | if (editor == null) 22 | return; 23 | 24 | IDocument document = editor.getDocument(); 25 | try { 26 | int currentPoint = editor.getPoint(); 27 | int docLength = document.getLength(); 28 | int start = currentPoint; 29 | int end = currentPoint; 30 | while (start > 0 && Character.isWhitespace(document.getChar(start - 1))) 31 | start--; 32 | while (end < docLength && Character.isWhitespace(document.getChar(end))) 33 | end++; 34 | editor.replaceText(start, end - start, " "); 35 | } 36 | catch (BadLocationException exception) 37 | { 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/DownSExpAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | import org.schemeway.plugins.schemescript.parser.*; 11 | 12 | public class DownSExpAction extends SchemeAction { 13 | 14 | public DownSExpAction(SchemeEditor editor) { 15 | super(editor); 16 | setText("Enters the next enclosed S-expression"); 17 | setToolTipText("Enters the next enclosed S-expression"); 18 | } 19 | 20 | public void run() { 21 | SchemeEditor editor = getSchemeEditor(); 22 | if (editor == null) return; 23 | 24 | Region selection = editor.getSelection(); 25 | 26 | SexpNavigator explorer = editor.getExplorer(); 27 | if (explorer.downSexpression(selection.getOffset())) 28 | editor.setPoint(explorer.getSexpStart()); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/EvalExpressionAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.*; 10 | import org.schemeway.plugins.schemescript.editor.*; 11 | import org.schemeway.plugins.schemescript.interpreter.*; 12 | import org.schemeway.plugins.schemescript.parser.*; 13 | import org.schemeway.plugins.schemescript.preferences.*; 14 | 15 | public class EvalExpressionAction extends SchemeAction { 16 | private boolean mMoveToTop; 17 | 18 | public EvalExpressionAction(SchemeEditor editor, boolean topExpression) { 19 | super(editor); 20 | 21 | if (topExpression) 22 | setText("Eval top expression"); 23 | else 24 | setText("Eval previous expression"); 25 | setToolTipText("Send text to interpreter"); 26 | mMoveToTop = topExpression; 27 | } 28 | 29 | public void run() { 30 | SchemeEditor editor = getSchemeEditor(); 31 | if (editor == null) 32 | return; 33 | 34 | String textToEval = null; 35 | SexpNavigator explorer = editor.getExplorer(); 36 | 37 | Region selection = editor.getSelection(); 38 | if (selection.getLength() > 0) { 39 | textToEval = editor.getText(selection.getOffset(), selection.getLength()); 40 | } 41 | else if (mMoveToTop) { 42 | int start = editor.getPoint(); 43 | int end = start; 44 | while (explorer.upSexpression(start)) { 45 | start = explorer.getSexpStart(); 46 | end = explorer.getSexpEnd(); 47 | } 48 | if (start != end && explorer.forwardSexpression(start)) 49 | textToEval = explorer.getText(); 50 | } 51 | else { 52 | int point = editor.getPoint(); 53 | if (explorer.backwardSexpression(point)) { 54 | textToEval = explorer.getText(); 55 | } 56 | } 57 | if (textToEval != null) { 58 | if (InterpreterPreferences.surroundCodeWithBegin()) 59 | textToEval = "(begin " + textToEval + ")"; 60 | evalText(textToEval); 61 | } 62 | } 63 | 64 | private void evalText(String textToEval) { 65 | Interpreter interp = SchemeScriptPlugin.getDefault().getInterpreter(); 66 | interp.eval(textToEval); 67 | } 68 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/ExpandSelectionToSexpressions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 SchemeWay.com 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | import org.schemeway.plugins.schemescript.editor.autoedits.*; 11 | 12 | /** 13 | * @author SchemeWay.com 14 | */ 15 | public class ExpandSelectionToSexpressions extends SchemeAction { 16 | 17 | public ExpandSelectionToSexpressions(SchemeEditor editor) { 18 | super(editor); 19 | } 20 | 21 | public void run() { 22 | SchemeEditor editor = getSchemeEditor(); 23 | if (editor == null) 24 | return; 25 | 26 | IRegion selection = editor.getSelection(); 27 | if (selection.getLength() > 1) { 28 | int start = selection.getOffset(); 29 | int end = start + selection.getLength(); 30 | IRegion expandedSelection = SexpUtils.findEnclosingSexpressions(editor.getDocument(), start, end); 31 | if (expandedSelection != null) { 32 | start = expandedSelection.getOffset(); 33 | end = start + expandedSelection.getLength(); 34 | editor.setSelection(start, end); 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/FastEvalAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.action.*; 9 | import org.eclipse.jface.viewers.*; 10 | import org.eclipse.ui.*; 11 | import org.schemeway.plugins.schemescript.*; 12 | import org.schemeway.plugins.schemescript.interpreter.*; 13 | import org.schemeway.plugins.schemescript.preferences.*; 14 | 15 | public class FastEvalAction extends Action implements IWorkbenchWindowActionDelegate { 16 | private int mIndex; 17 | 18 | public static class FastEvalAction0 extends FastEvalAction { 19 | public FastEvalAction0() { super(0); } 20 | } 21 | public static class FastEvalAction1 extends FastEvalAction { 22 | public FastEvalAction1() { super(1); } 23 | } 24 | public static class FastEvalAction2 extends FastEvalAction { 25 | public FastEvalAction2() { super(2); } 26 | } 27 | public static class FastEvalAction3 extends FastEvalAction { 28 | public FastEvalAction3() { super(3); } 29 | } 30 | public static class FastEvalAction4 extends FastEvalAction { 31 | public FastEvalAction4() { super(4); } 32 | } 33 | public static class FastEvalAction5 extends FastEvalAction { 34 | public FastEvalAction5() { super(5); } 35 | } 36 | public static class FastEvalAction6 extends FastEvalAction { 37 | public FastEvalAction6() { super(6); } 38 | } 39 | public static class FastEvalAction7 extends FastEvalAction { 40 | public FastEvalAction7() { super(7); } 41 | } 42 | public static class FastEvalAction8 extends FastEvalAction { 43 | public FastEvalAction8() { super(8); } 44 | } 45 | public static class FastEvalAction9 extends FastEvalAction { 46 | public FastEvalAction9() { super(9); } 47 | } 48 | 49 | 50 | public FastEvalAction(int index) { 51 | setText("Fast Eval " + index); 52 | setToolTipText("Evaluates a predefined expression"); 53 | mIndex = index; 54 | } 55 | 56 | public void run() { 57 | String expr = FastEvalPreferences.getFastEval(mIndex); 58 | if (expr != null && !expr.equals("")) { 59 | Interpreter interp = SchemeScriptPlugin.getDefault().getInterpreter(); 60 | interp.eval(expr); 61 | } 62 | } 63 | 64 | 65 | public void dispose() { 66 | } 67 | 68 | public void init(IWorkbenchWindow window) { 69 | } 70 | 71 | public void run(IAction action) { 72 | run(); 73 | } 74 | 75 | public void selectionChanged(IAction action, ISelection selection) { 76 | } 77 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/FileHeaderCommentAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | import org.schemeway.plugins.schemescript.tools.*; 11 | 12 | public class FileHeaderCommentAction extends SchemeAction { 13 | 14 | public FileHeaderCommentAction(SchemeEditor editor) { 15 | super(editor); 16 | setText("Insert header comment"); 17 | setToolTipText("Insert a Scheme file header comment"); 18 | } 19 | 20 | public void run() { 21 | SchemeEditor editor = getSchemeEditor(); 22 | if (editor == null) return; 23 | 24 | String newline = TextUtilities.getDefaultLineDelimiter(editor.getDocument()); 25 | 26 | editor.insertText(0, Comments.createHeaderComment(newline)); 27 | editor.setPoint(8 + newline.length()); 28 | } 29 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/FindSymbolAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.action.*; 9 | import org.eclipse.jface.viewers.*; 10 | import org.eclipse.jface.window.*; 11 | import org.eclipse.swt.widgets.*; 12 | import org.eclipse.ui.*; 13 | import org.schemeway.plugins.schemescript.dialogs.*; 14 | import org.schemeway.plugins.schemescript.dictionary.*; 15 | import org.schemeway.plugins.schemescript.views.*; 16 | 17 | public class FindSymbolAction extends Action implements IWorkbenchWindowActionDelegate { 18 | 19 | IWorkbenchWindow mWindow = null; 20 | 21 | public FindSymbolAction() { 22 | setText("Choose symbol"); 23 | setToolTipText("Choose symbol"); 24 | } 25 | 26 | public void run() { 27 | Shell shell = null; 28 | 29 | if (mWindow == null) 30 | shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); 31 | else 32 | shell = mWindow.getShell(); 33 | 34 | FindSymbolDialog dialog = new FindSymbolDialog(shell); 35 | if (dialog.open() == Window.OK) { 36 | SymbolEntry[] entries = dialog.getSelectedEntries(); 37 | if (entries != null) { 38 | if (entries.length == 1) 39 | DefinitionListView.openEditorAtLine(entries[0]); 40 | else 41 | DefinitionListView.showInView(entries); 42 | } 43 | } 44 | } 45 | 46 | 47 | public void dispose() { 48 | } 49 | 50 | public void init(IWorkbenchWindow window) { 51 | mWindow = window; 52 | } 53 | 54 | public void run(IAction action) { 55 | run(); 56 | } 57 | 58 | public void selectionChanged(IAction action, ISelection selection) { 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/ForwardSExpAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | import org.schemeway.plugins.schemescript.parser.*; 11 | 12 | public class ForwardSExpAction extends SchemeAction { 13 | private boolean mSelectExpression; 14 | 15 | public ForwardSExpAction(SchemeEditor editor, boolean selectExpression) { 16 | super(editor); 17 | setText("Select Forward Sexp"); 18 | setToolTipText("Selects the next S-expression"); 19 | mSelectExpression = selectExpression; 20 | } 21 | 22 | public void run() { 23 | final SchemeEditor editor = getSchemeEditor(); 24 | if (editor == null) return; 25 | 26 | Region selection = editor.getSelection(); 27 | 28 | SexpNavigator explorer = editor.getExplorer(); 29 | if (explorer.forwardSexpression(selection.getOffset() + selection.getLength())) { 30 | int start = explorer.getSexpStart(); 31 | int end = explorer.getSexpEnd(); 32 | if (mSelectExpression) { 33 | if (selection.getLength() > 0) { 34 | start = selection.getOffset(); 35 | } 36 | else if (start > selection.getOffset()) { 37 | start = selection.getOffset(); 38 | } 39 | editor.setSelection(start, end); 40 | } 41 | else { 42 | editor.setPoint(end); 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/ISchemeEditorAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.schemeway.plugins.schemescript.editor.*; 9 | 10 | public interface ISchemeEditorAction { 11 | void setSchemeEditor(SchemeEditor editor); 12 | SchemeEditor getSchemeEditor(); 13 | } 14 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/InterruptEvaluationAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.action.*; 9 | import org.eclipse.jface.viewers.*; 10 | import org.eclipse.ui.*; 11 | import org.schemeway.plugins.schemescript.*; 12 | import org.schemeway.plugins.schemescript.interpreter.*; 13 | 14 | public class InterruptEvaluationAction extends Action implements IWorkbenchWindowActionDelegate 15 | { 16 | public InterruptEvaluationAction() 17 | { 18 | setText("Interrupt the Scheme interpreter"); 19 | setToolTipText("Interrupt the interpreter"); 20 | } 21 | 22 | public void run() 23 | { 24 | Interpreter interp = SchemeScriptPlugin.getDefault().getInterpreter(); 25 | if (interp == null) 26 | return; 27 | 28 | interp.interrupt(); 29 | interp.showConsole(); 30 | } 31 | 32 | 33 | public void dispose() { 34 | } 35 | 36 | public void init(IWorkbenchWindow window) { 37 | } 38 | 39 | public void run(IAction action) { 40 | run(); 41 | } 42 | 43 | public void selectionChanged(IAction action, ISelection selection) { 44 | } 45 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/JumpToDefinitionAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.core.resources.*; 9 | import org.eclipse.ui.*; 10 | import org.eclipse.ui.part.*; 11 | import org.schemeway.plugins.schemescript.*; 12 | import org.schemeway.plugins.schemescript.dictionary.*; 13 | import org.schemeway.plugins.schemescript.editor.*; 14 | 15 | public class JumpToDefinitionAction extends SchemeAction { 16 | 17 | public JumpToDefinitionAction(SchemeEditor editor) { 18 | super(editor); 19 | setText("Find definition"); 20 | setToolTipText("Jump to the symbol definition"); 21 | } 22 | 23 | private IResource getResource() { 24 | IEditorInput input = getSchemeEditor().getEditorInput(); 25 | if (input instanceof FileEditorInput) { 26 | return ((FileEditorInput) input).getFile(); 27 | } 28 | return null; 29 | } 30 | 31 | public void run() { 32 | final SchemeEditor editor = getSchemeEditor(); 33 | if (editor == null) return; 34 | 35 | try { 36 | String symbol = SchemeTextUtilities.findSymbolAroundPoint(editor.getDocument(), editor.getPoint()); 37 | if (symbol == null) 38 | return; 39 | 40 | SymbolEntry[] entries = DictionaryUtils.findUserDefinitions(symbol); 41 | if (entries.length > 0) { 42 | SchemeTextUtilities.openOrSelectEntry(entries, getResource()); 43 | } 44 | } 45 | catch (Throwable exception) { 46 | SchemeScriptPlugin.logException("Exception in jump definition", exception); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/LoadFileAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.ui.*; 9 | import org.eclipse.ui.part.*; 10 | import org.schemeway.plugins.schemescript.*; 11 | import org.schemeway.plugins.schemescript.editor.*; 12 | import org.schemeway.plugins.schemescript.interpreter.*; 13 | import org.schemeway.plugins.schemescript.preferences.*; 14 | 15 | public class LoadFileAction extends SchemeAction { 16 | 17 | public LoadFileAction(SchemeEditor editor) { 18 | super(editor); 19 | 20 | setText("Load File in Interpreter"); 21 | setToolTipText("Load file in interpreter"); 22 | } 23 | 24 | public void run() { 25 | SchemeEditor editor = getSchemeEditor(); 26 | if (editor == null) 27 | return; 28 | 29 | if (InterpreterPreferences.isSaveRequiredBeforeLoad()) { 30 | editor.doSave(null); 31 | } 32 | IEditorInput input = editor.getEditorInput(); 33 | if (input instanceof FileEditorInput) { 34 | FileEditorInput fileInput = (FileEditorInput) input; 35 | Interpreter interp = SchemeScriptPlugin.getDefault().getInterpreter(); 36 | interp.load(fileInput.getFile()); 37 | 38 | try { 39 | PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( 40 | "org.eclipse.ui.console.ConsoleView"); 41 | } 42 | catch (PartInitException e) { 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/MoveLeftParenBackwardOneExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | import org.schemeway.plugins.schemescript.parser.*; 11 | 12 | public class MoveLeftParenBackwardOneExpression extends SchemeAction { 13 | 14 | public MoveLeftParenBackwardOneExpression(SchemeEditor editor) { 15 | super(editor); 16 | } 17 | 18 | public void run() { 19 | SchemeEditor editor = getSchemeEditor(); 20 | if (editor == null) return; 21 | 22 | try { 23 | Region selection = editor.getSelection(); 24 | if (selection.getLength() == 0) { 25 | IDocument document = editor.getDocument(); 26 | char currentChar = document.getChar(selection.getOffset()); 27 | if (currentChar == '(') { 28 | SexpNavigator navigator = new SexpNavigator(document); 29 | if (navigator.backwardSexpression(selection.getOffset())) { 30 | try { 31 | editor.startCompoundChange(); 32 | document.replace(selection.getOffset(), 1, ""); 33 | document.replace(navigator.getSexpStart(), 0, "("); 34 | editor.setPoint(navigator.getSexpStart()); 35 | } 36 | finally { 37 | editor.endCompoundChange(); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | catch (BadLocationException e) { 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/MoveRightParenForwardOneExpression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | import org.schemeway.plugins.schemescript.parser.*; 11 | 12 | public class MoveRightParenForwardOneExpression extends SchemeAction { 13 | 14 | public MoveRightParenForwardOneExpression(SchemeEditor editor) { 15 | super(editor); 16 | } 17 | 18 | public void run() { 19 | SchemeEditor editor = getSchemeEditor(); 20 | if (editor == null) return; 21 | 22 | try { 23 | Region selection = editor.getSelection(); 24 | if (selection.getLength() == 0) { 25 | IDocument document = editor.getDocument(); 26 | char currentChar = document.getChar(selection.getOffset()); 27 | if (currentChar == ')') { 28 | SexpNavigator navigator = new SexpNavigator(document); 29 | if (navigator.forwardSexpression(selection.getOffset() + 1)) { 30 | try { 31 | editor.startCompoundChange(); 32 | document.replace(navigator.getSexpEnd(), 0, ")"); 33 | document.replace(selection.getOffset(), 1, ""); 34 | editor.setPoint(navigator.getSexpEnd() - 1); 35 | } 36 | finally { 37 | editor.endCompoundChange(); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | catch (BadLocationException e) { 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/RestartInterpreterAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.action.*; 9 | import org.eclipse.jface.viewers.*; 10 | import org.eclipse.ui.*; 11 | import org.schemeway.plugins.schemescript.*; 12 | import org.schemeway.plugins.schemescript.interpreter.*; 13 | 14 | public class RestartInterpreterAction extends Action implements IWorkbenchWindowActionDelegate 15 | { 16 | public RestartInterpreterAction() 17 | { 18 | setText("Restart the Scheme interpreter"); 19 | setToolTipText("Restart interpreter"); 20 | } 21 | 22 | public void run() 23 | { 24 | Interpreter interp = SchemeScriptPlugin.getDefault().getInterpreter(); 25 | if (interp == null) 26 | return; 27 | 28 | interp.restart(); 29 | interp.showConsole(); 30 | } 31 | 32 | 33 | public void dispose() { 34 | } 35 | 36 | public void init(IWorkbenchWindow window) { 37 | } 38 | 39 | public void run(IAction action) { 40 | run(); 41 | } 42 | 43 | public void selectionChanged(IAction action, ISelection selection) { 44 | } 45 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/RestoreSelectionAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.core.runtime.Assert; 9 | import org.eclipse.jface.action.*; 10 | import org.eclipse.jface.text.*; 11 | import org.schemeway.plugins.schemescript.editor.*; 12 | 13 | public class RestoreSelectionAction extends Action 14 | { 15 | private SchemeEditor mEditor; 16 | private SelectionStack mStack; 17 | 18 | public RestoreSelectionAction(SchemeEditor editor, SelectionStack stack) { 19 | Assert.isNotNull(editor); 20 | setText("Restore the previous selection"); 21 | setToolTipText("Restore the previous selection"); 22 | mEditor = editor; 23 | mStack = stack; 24 | } 25 | 26 | public void run() { 27 | Region selection = mStack.pop(); 28 | if (selection != null) { 29 | mEditor.setSelection(selection.getOffset(), selection.getOffset() + selection.getLength()); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/SchemeAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.action.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | 11 | public class SchemeAction extends Action implements ISchemeEditorAction { 12 | private SchemeEditor mEditor = null; 13 | 14 | public SchemeAction(SchemeEditor editor) { 15 | super(); 16 | setSchemeEditor(editor); 17 | } 18 | 19 | public void setSchemeEditor(SchemeEditor editor) { 20 | mEditor = editor; 21 | } 22 | 23 | public SchemeEditor getSchemeEditor() { 24 | return mEditor; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/SchemeProcedureAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 SchemeWay.com 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import gnu.mapping.*; 9 | 10 | import org.eclipse.core.runtime.*; 11 | import org.eclipse.jface.action.*; 12 | import org.eclipse.jface.viewers.*; 13 | import org.eclipse.swt.widgets.*; 14 | import org.eclipse.ui.*; 15 | import org.schemeway.plugins.schemescript.*; 16 | import org.schemeway.plugins.schemescript.interpreter.*; 17 | 18 | /** 19 | * @author SchemeWay.com 20 | */ 21 | public final class SchemeProcedureAction extends Action implements IWorkbenchWindowActionDelegate, IExecutableExtension { 22 | 23 | private Procedure mCachedProcedure = null; 24 | private String mProcedureName; 25 | 26 | public SchemeProcedureAction() { 27 | } 28 | 29 | public SchemeProcedureAction(String procedureName) { 30 | mProcedureName = procedureName; 31 | } 32 | 33 | public void setInitializationData(IConfigurationElement config, String propertyName, Object data) 34 | throws CoreException { 35 | 36 | if (data instanceof String) { 37 | mProcedureName = (String)data; 38 | mCachedProcedure = getProcedure(mProcedureName); 39 | } 40 | } 41 | 42 | public void dispose() { 43 | } 44 | 45 | public void init(IWorkbenchWindow window) { 46 | } 47 | 48 | public void runWithEvent(Event event) { 49 | super.runWithEvent(event); 50 | run(null); 51 | } 52 | 53 | public void run(IAction action) { 54 | Procedure proc = getProcedure(mProcedureName); 55 | 56 | if (proc != null && proc != mCachedProcedure) 57 | mCachedProcedure = proc; 58 | 59 | if (mCachedProcedure != null) { 60 | try { 61 | mCachedProcedure.apply0(); 62 | } 63 | catch (Throwable e) { 64 | SchemeScriptPlugin.logException("Error while evaluating Scheme action", e); 65 | } 66 | } 67 | } 68 | 69 | public void selectionChanged(IAction action, ISelection selection) { 70 | } 71 | 72 | private Procedure getProcedure(final String name) 73 | { 74 | Object object = KawaProxy.get(name); 75 | if (object == null || !(object instanceof Procedure)) 76 | return null; 77 | else 78 | return (Procedure)object; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/SectioningCommentAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | import org.schemeway.plugins.schemescript.tools.*; 11 | 12 | public class SectioningCommentAction extends SchemeAction { 13 | private boolean mSubsection; 14 | 15 | protected SectioningCommentAction(SchemeEditor editor, boolean subsection) { 16 | super(editor); 17 | mSubsection = subsection; 18 | setText(subsection ? "Insert section comment" : "Insert chapter comment"); 19 | setToolTipText(subsection ? "Insert section comment" : "Insert chapter comment"); 20 | } 21 | 22 | public void run() { 23 | final SchemeEditor editor = getSchemeEditor(); 24 | if (editor == null) return; 25 | 26 | int point = editor.getPoint(); 27 | String newline = TextUtilities.getDefaultLineDelimiter(editor.getDocument()); 28 | 29 | if (mSubsection) { 30 | editor.insertText(point, Comments.createSectionComment(newline)); 31 | editor.setPoint(point + 8 + newline.length()); 32 | } 33 | else { 34 | editor.insertText(point, Comments.createChapterComment(newline)); 35 | editor.setPoint(point + 15 + 2 * newline.length()); 36 | } 37 | } 38 | 39 | public static SectioningCommentAction createChapterCommentAction(SchemeEditor editor) { 40 | return new SectioningCommentAction(editor, false); 41 | } 42 | 43 | public static SectioningCommentAction createSectionCommentAction(SchemeEditor editor) { 44 | return new SectioningCommentAction(editor, true); 45 | } 46 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/SelectionStack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import java.util.*; 9 | 10 | import org.eclipse.core.runtime.Assert; 11 | import org.eclipse.jface.text.*; 12 | 13 | public class SelectionStack { 14 | private List mStack; 15 | 16 | public SelectionStack() { 17 | mStack = new LinkedList(); 18 | } 19 | 20 | public void push(Region selection, Region previousSelection){ 21 | Assert.isNotNull(selection); 22 | if (mStack.size() > 0) { 23 | if (previousSelection == null || !previousSelection.equals(mStack.get(0))) { 24 | mStack.clear(); 25 | } 26 | } 27 | mStack.add(0, selection); 28 | } 29 | 30 | public Region pop() { 31 | if (mStack.size() > 0) { 32 | Region element = (Region)mStack.get(0); 33 | mStack.remove(0); 34 | return element; 35 | } 36 | return null; 37 | } 38 | 39 | public void clear() { 40 | mStack.clear(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/StartInterpreterAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.action.*; 9 | import org.eclipse.jface.viewers.*; 10 | import org.eclipse.ui.*; 11 | import org.schemeway.plugins.schemescript.*; 12 | import org.schemeway.plugins.schemescript.interpreter.*; 13 | 14 | public class StartInterpreterAction extends Action implements IWorkbenchWindowActionDelegate 15 | { 16 | public StartInterpreterAction() 17 | { 18 | setText("Start the Scheme interpreter"); 19 | setToolTipText("Start interpreter"); 20 | } 21 | 22 | public void run() 23 | { 24 | Interpreter interp = SchemeScriptPlugin.getDefault().getInterpreter(); 25 | if (interp == null) 26 | return; 27 | 28 | interp.start(); 29 | } 30 | 31 | 32 | public void dispose() { 33 | } 34 | 35 | public void init(IWorkbenchWindow window) { 36 | } 37 | 38 | public void run(IAction action) { 39 | run(); 40 | } 41 | 42 | public void selectionChanged(IAction action, ISelection selection) { 43 | } 44 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/SwapSexpAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.schemeway.plugins.schemescript.editor.*; 9 | import org.schemeway.plugins.schemescript.parser.*; 10 | 11 | public class SwapSexpAction extends SchemeAction { 12 | 13 | public SwapSexpAction(SchemeEditor editor) { 14 | super(editor); 15 | setText("Swaps S-expressions"); 16 | setToolTipText("Swaps the S-expressions before and after the cursor"); 17 | } 18 | 19 | public void run() { 20 | final SchemeEditor editor = getSchemeEditor(); 21 | if (editor == null) return; 22 | 23 | int point = editor.getPoint(); 24 | SexpNavigator explorer = editor.getExplorer(); 25 | if (explorer.backwardSexpression(point)) { 26 | int previousStart = explorer.getSexpStart(); 27 | int previousEnd = explorer.getSexpEnd(); 28 | if (explorer.forwardSexpression(point)) { 29 | int nextStart = explorer.getSexpStart(); 30 | int nextEnd = explorer.getSexpEnd(); 31 | editor.swapText(previousStart, previousEnd - previousStart, nextStart, nextEnd - nextStart); 32 | } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/action/UpSExpAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.action; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | import org.schemeway.plugins.schemescript.parser.*; 11 | 12 | public class UpSExpAction extends SchemeAction { 13 | private boolean mSelectExpression; 14 | private SelectionStack mStack; 15 | private Region mPreviousSelection; 16 | 17 | public UpSExpAction(SchemeEditor editor, boolean selectExpression, SelectionStack stack) { 18 | super(editor); 19 | setText("Moves to enclosing S-expression"); 20 | setToolTipText("Moves to the enclosing S-expression"); 21 | mSelectExpression = selectExpression; 22 | mStack = stack; 23 | mPreviousSelection = null; 24 | } 25 | 26 | public void run() { 27 | final SchemeEditor editor = getSchemeEditor(); 28 | if (editor == null) return; 29 | 30 | Region selection = editor.getSelection(); 31 | SexpNavigator explorer = editor.getExplorer(); 32 | if (explorer.upSexpression(selection.getOffset())) { 33 | if (mSelectExpression && explorer.forwardSexpression(explorer.getSexpStart())) { 34 | int start = explorer.getSexpStart(); 35 | int end = explorer.getSexpEnd(); 36 | if (mStack != null) { 37 | if (mPreviousSelection != null && !encloses(mPreviousSelection, selection)) 38 | mPreviousSelection = null; 39 | mStack.push(selection, mPreviousSelection); 40 | mPreviousSelection = selection; 41 | } 42 | editor.setSelection(start, end); 43 | } 44 | else { 45 | if (mStack != null) { 46 | mStack.clear(); 47 | } 48 | editor.setPoint(explorer.getSexpStart()); 49 | } 50 | } 51 | } 52 | 53 | private boolean encloses(Region innerRegion, Region outerRegion) { 54 | int innerStart = innerRegion.getOffset(); 55 | int innerEnd = innerRegion.getLength() + innerStart; 56 | int outerStart = outerRegion.getOffset(); 57 | int outerEnd = outerRegion.getLength() + outerStart; 58 | 59 | return (innerStart >= outerStart && innerStart <= outerEnd && innerEnd < outerEnd); 60 | } 61 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/dictionary/DictionaryUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.dictionary; 5 | 6 | import gnu.lists.*; 7 | import gnu.mapping.*; 8 | 9 | import java.util.*; 10 | 11 | import org.eclipse.core.resources.*; 12 | import org.schemeway.plugins.schemescript.*; 13 | import org.schemeway.plugins.schemescript.interpreter.*; 14 | 15 | /** 16 | * @author SchemeWay Project. 17 | * 18 | */ 19 | public final class DictionaryUtils { 20 | 21 | public static SymbolEntry[] findUserDefinitions(String symbol) { 22 | Object object = KawaProxy.get("get-dictionary-entries"); 23 | if (object != null && object instanceof Procedure) { 24 | Procedure getDictionaryEntries = (Procedure) object; 25 | try { 26 | LList entryList = (LList) getDictionaryEntries.apply1(symbol); 27 | List entries = new ArrayList(); 28 | addEntriesToJavaList(entryList, entries); 29 | return (SymbolEntry[]) entries.toArray(new SymbolEntry[entries.size()]); 30 | } 31 | catch (Throwable exception) { 32 | SchemeScriptPlugin.logException("Unable to find definitions for symbol: " + symbol , exception); 33 | } 34 | } 35 | return new SymbolEntry[0]; 36 | } 37 | 38 | public static SymbolEntry[] findDefinitionsForResource(IResource resource) { 39 | 40 | Object object = KawaProxy.get("get-dictionary-entries-for-resource"); 41 | if (object != null && object instanceof Procedure) { 42 | Procedure getDictionaryEntries = (Procedure) object; 43 | try { 44 | LList entryList = (LList) getDictionaryEntries.apply1(resource); 45 | List entries = new ArrayList(); 46 | addEntriesToJavaList(entryList, entries); 47 | return (SymbolEntry[]) entries.toArray(new SymbolEntry[entries.size()]); 48 | } 49 | catch (Throwable exception) { 50 | SchemeScriptPlugin.logException("Unable to find definitions for resource: " + resource.getName(), exception); 51 | } 52 | } 53 | return new SymbolEntry[0]; 54 | 55 | } 56 | 57 | public static SymbolEntry[] findCompletions(String prefix) { 58 | Object object = KawaProxy.get("find-completions"); 59 | if (object != null && object instanceof Procedure) 60 | { 61 | Procedure proc = (Procedure) object; 62 | try { 63 | LList entryList = (LList) proc.apply1(prefix); 64 | LinkedList entries = new LinkedList(); 65 | addEntriesToJavaList(entryList, entries); 66 | return (SymbolEntry[]) entries.toArray(new SymbolEntry[entries.size()]); 67 | } 68 | catch (Throwable exception) { 69 | SchemeScriptPlugin.logException("Unable to call completion procedure", exception); 70 | } 71 | } 72 | return new SymbolEntry[0]; 73 | } 74 | 75 | private static void addEntriesToJavaList(LList entryList, List entries) { 76 | while (entryList instanceof Pair) { 77 | Pair pair = (Pair) entryList; 78 | entries.add(pair.car); 79 | entryList = (LList) pair.cdr; 80 | } 81 | } 82 | 83 | private DictionaryUtils() { 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/dictionary/Reference.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.dictionary; 5 | 6 | import org.eclipse.core.resources.*; 7 | 8 | public class Reference { 9 | public IResource resource; 10 | public int offset; 11 | public int length; 12 | 13 | public Reference(IResource mResource, int mOffset, int mLength) { 14 | length = mLength; 15 | offset = mOffset; 16 | resource = mResource; 17 | } 18 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/dictionary/SymbolEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.dictionary; 7 | 8 | import org.eclipse.core.resources.*; 9 | import org.eclipse.core.runtime.*; 10 | 11 | /** 12 | * An entry in a symbol dictionary. 13 | * 14 | * @see IResource 15 | */ 16 | public class SymbolEntry { 17 | public static final String SYNTAX = "syntax"; 18 | public static final String FUNCTION = "function"; 19 | public static final String VARIABLE = "variable"; 20 | 21 | public static final int 22 | HIGH = 0, 23 | MEDIUM = 1, 24 | LOW = 2; 25 | 26 | private String mName; 27 | private String mDescription; 28 | private String mCategory; 29 | private int mPriority; 30 | private int mOffset; 31 | private int mLength; 32 | private IFile mFile; 33 | private SymbolEntry mParent; 34 | 35 | public SymbolEntry(String name, String description, String category) { 36 | this(name, description, category, null, -1, -1, LOW); 37 | } 38 | 39 | public SymbolEntry(String name, String description, String category, int priority) { 40 | this(name, description, category, null, -1, -1, priority); 41 | } 42 | 43 | public SymbolEntry(String name, String description, String category, IFile source, int position) { 44 | this(name, description, category, source, position, -1, LOW); 45 | } 46 | 47 | public SymbolEntry(String name, String description, String category, IFile source, int offset, int length, int priority) { 48 | Assert.isNotNull(name); 49 | mName = name; 50 | mDescription = description; 51 | mCategory = category; 52 | mPriority = priority; 53 | mFile = source; 54 | mOffset = offset; 55 | mLength = length; 56 | } 57 | 58 | public String getName() { 59 | return mName; 60 | } 61 | 62 | public String getDescription() { 63 | return mDescription; 64 | } 65 | 66 | public String getCategory() { 67 | return mCategory; 68 | } 69 | 70 | public int getPriority() { 71 | return mPriority; 72 | } 73 | 74 | public IFile getFile() { 75 | return mFile; 76 | } 77 | 78 | public int getOffset() { 79 | return mOffset; 80 | } 81 | 82 | public int getLength() { 83 | return mLength; 84 | } 85 | 86 | public String getContext() { 87 | if (mFile != null) { 88 | return mFile.getName() + ", " + formatPath(mFile); 89 | } 90 | else if (mCategory != null) 91 | return mCategory; 92 | else 93 | return ""; 94 | } 95 | 96 | private static String formatPath(IResource resource) { 97 | IPath path = resource.getRawLocation(); 98 | String[] segments = path.segments(); 99 | int len = segments.length; 100 | if (len > 3) { 101 | return ".../" + segments[len - 3] + "/" + segments[len - 2] + "/" + segments[len - 1]; 102 | } 103 | else if (len == 3) 104 | return segments[0] + "/" + segments[1] + "/" + segments[2]; 105 | else if (len == 2) 106 | return segments[0] + "/" + segments[1]; 107 | else 108 | return segments[0]; 109 | } 110 | 111 | public SymbolEntry getParent() { 112 | return mParent; 113 | } 114 | 115 | public void setParent(SymbolEntry parent) { 116 | mParent = parent; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/dictionary/SymbolReferencesManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.dictionary; 5 | 6 | import org.eclipse.core.filebuffers.*; 7 | import org.eclipse.core.resources.*; 8 | import org.eclipse.core.runtime.*; 9 | import org.eclipse.jface.text.*; 10 | import org.schemeway.plugins.schemescript.parser.*; 11 | 12 | /** 13 | * @author SchemeWay Project. 14 | * 15 | */ 16 | public class SymbolReferencesManager implements IResourceChangeListener { 17 | 18 | private SymbolReferencesTable mReferencesTable = new SymbolReferencesTable(); 19 | 20 | public SymbolReferencesManager() { 21 | } 22 | 23 | public void resourceChanged(IResourceChangeEvent event) { 24 | } 25 | 26 | public SymbolReferencesTable getSymbolReferencesTable() { 27 | return mReferencesTable; 28 | } 29 | 30 | public void scanResourceForSymbols(IResource resource) { 31 | if (!(resource instanceof IFile)) { 32 | return; 33 | } 34 | 35 | IFile file = (IFile) resource; 36 | ITextFileBufferManager fileBufferManager = FileBuffers.getTextFileBufferManager(); 37 | 38 | IPath path = file.getFullPath(); 39 | try { 40 | fileBufferManager.connect(path, null); 41 | try { 42 | scanDocumentForSymbols(resource, fileBufferManager.getTextFileBuffer(path).getDocument()); 43 | } finally { 44 | fileBufferManager.disconnect(path, null); 45 | } 46 | } catch (CoreException exception) { 47 | // simply ignore 48 | } 49 | } 50 | 51 | private void scanDocumentForSymbols(IResource resource, IDocument document) { 52 | mReferencesTable.removeReferences(resource); 53 | 54 | SchemeScanner scanner = new SchemeScanner(); 55 | scanner.setRange(document, 0, document.getLength()); 56 | 57 | SchemeToken token = scanner.nextToken(); 58 | while (token != SchemeToken.EOF) { 59 | if (token.getType() == SchemeToken.SYMBOL) { 60 | int offset = scanner.getTokenOffset(); 61 | int length = scanner.getTokenLength(); 62 | String symbol = scanner.getText(offset, length); 63 | if (!".".equals(symbol)) { 64 | mReferencesTable.addEntry(symbol, resource, offset, length); 65 | } 66 | } 67 | token = scanner.nextToken(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/dictionary/SymbolSearchQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.dictionary; 5 | 6 | import org.eclipse.core.runtime.*; 7 | import org.eclipse.search.ui.*; 8 | import org.eclipse.search.ui.text.*; 9 | import org.schemeway.plugins.schemescript.*; 10 | 11 | class SymbolSearchQuery implements ISearchQuery { 12 | private String mSearchSymbol; 13 | private SymbolSearchResult mSearchResult; 14 | 15 | public SymbolSearchQuery(String searchSymbol) { 16 | mSearchSymbol = searchSymbol; 17 | mSearchResult = new SymbolSearchResult(this); 18 | } 19 | 20 | public boolean canRunInBackground() { 21 | return true; 22 | } 23 | 24 | public boolean canRerun() { 25 | return true; 26 | } 27 | 28 | public String getLabel() { 29 | return "Search for " + mSearchSymbol; 30 | } 31 | 32 | public ISearchResult getSearchResult() { 33 | return mSearchResult; 34 | } 35 | 36 | public IStatus run(IProgressMonitor monitor) throws OperationCanceledException { 37 | SymbolReferencesManager referencesManager = SchemeScriptPlugin.getReferencesManager(); 38 | SymbolReferencesTable referencesTable = referencesManager.getSymbolReferencesTable(); 39 | 40 | Reference[] references = referencesTable.getReferences(mSearchSymbol); 41 | Match[] matches = new Match[references.length]; 42 | for (int referenceIndex = 0; referenceIndex < references.length; referenceIndex++) { 43 | Reference reference = references[referenceIndex]; 44 | matches[referenceIndex] = new Match(reference.resource, reference.offset, reference.length); 45 | } 46 | mSearchResult.addMatches(matches); 47 | 48 | return Status.OK_STATUS; 49 | } 50 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/dictionary/SymbolSearchResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.dictionary; 5 | 6 | import org.eclipse.core.resources.*; 7 | import org.eclipse.jface.resource.*; 8 | import org.eclipse.search.ui.*; 9 | import org.eclipse.search.ui.text.*; 10 | import org.eclipse.ui.*; 11 | 12 | class SymbolSearchResult extends AbstractTextSearchResult implements IFileMatchAdapter, 13 | IEditorMatchAdapter { 14 | 15 | private SymbolSearchQuery mQuery; 16 | 17 | public SymbolSearchResult(SymbolSearchQuery query) { 18 | mQuery = query; 19 | } 20 | 21 | public IEditorMatchAdapter getEditorMatchAdapter() { 22 | return this; 23 | } 24 | 25 | public IFileMatchAdapter getFileMatchAdapter() { 26 | return this; 27 | } 28 | 29 | public ImageDescriptor getImageDescriptor() { 30 | return null; 31 | } 32 | 33 | public String getLabel() { 34 | int count = getMatchCount(); 35 | return mQuery.getLabel() + " - " + count + " match" + (count <= 1 ? "" : "es") ; 36 | } 37 | 38 | public ISearchQuery getQuery() { 39 | return mQuery; 40 | } 41 | 42 | public String getTooltip() { 43 | return null; 44 | } 45 | 46 | public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) { 47 | return getMatches(file); 48 | } 49 | 50 | public IFile getFile(Object element) { 51 | if (element instanceof IFile) 52 | return (IFile) element; 53 | return null; 54 | } 55 | 56 | public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) { 57 | IEditorInput ei = editor.getEditorInput(); 58 | if (ei instanceof IFileEditorInput) { 59 | IFileEditorInput fi = (IFileEditorInput) ei; 60 | return getMatches(fi.getFile()); 61 | } 62 | return new Match[0]; 63 | } 64 | 65 | public boolean isShownInEditor(Match match, IEditorPart editor) { 66 | IEditorInput input = editor.getEditorInput(); 67 | if (input instanceof IFileEditorInput) { 68 | IFileEditorInput fileEditorInput = (IFileEditorInput) input; 69 | return match.getElement().equals(fileEditorInput.getFile()); 70 | } 71 | return false; 72 | } 73 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/dictionary/SymbolSearchResultPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.dictionary; 5 | 6 | import org.eclipse.core.resources.*; 7 | import org.eclipse.jface.viewers.*; 8 | import org.eclipse.search.ui.text.*; 9 | import org.eclipse.ui.*; 10 | import org.eclipse.ui.model.*; 11 | import org.schemeway.plugins.schemescript.*; 12 | 13 | /** 14 | * @author SchemeWay Project. 15 | * 16 | */ 17 | public class SymbolSearchResultPage extends AbstractTextSearchViewPage { 18 | 19 | private SymbolTableContentProvider mContentProvider; 20 | 21 | public SymbolSearchResultPage() { 22 | super(AbstractTextSearchViewPage.FLAG_LAYOUT_FLAT); 23 | setElementLimit(new Integer(100)); 24 | } 25 | 26 | protected void clear() { 27 | } 28 | 29 | protected void configureTableViewer(TableViewer viewer) { 30 | mContentProvider = new SymbolTableContentProvider(this); 31 | viewer.setContentProvider(mContentProvider); 32 | viewer.setLabelProvider(new WorkbenchLabelProvider()); 33 | } 34 | 35 | protected void configureTreeViewer(TreeViewer viewer) { 36 | } 37 | 38 | protected void elementsChanged(Object[] objects) { 39 | mContentProvider.elementsChanged(objects); 40 | } 41 | 42 | public StructuredViewer getViewer() { 43 | return super.getViewer(); 44 | } 45 | 46 | protected void showMatch(Match match, int currentOffset, int currentLength) throws PartInitException { 47 | Object element = match.getElement(); 48 | if (element instanceof IFile) { 49 | IFile file = (IFile) element; 50 | SchemeScriptTools.openEditor(file, currentOffset, currentLength); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/dictionary/SymbolTableContentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.dictionary; 5 | 6 | import org.eclipse.jface.viewers.*; 7 | 8 | public class SymbolTableContentProvider implements IStructuredContentProvider { 9 | /** 10 | * 11 | */ 12 | private static final Object[] EMPTY_ARRAY = new Object[0]; 13 | private SymbolSearchResult mSearchResult; 14 | private SymbolSearchResultPage mPage; 15 | 16 | /** 17 | * @param symbolSearchResultPage 18 | */ 19 | public SymbolTableContentProvider(SymbolSearchResultPage symbolSearchResultPage) { 20 | mPage = symbolSearchResultPage; 21 | } 22 | 23 | public void dispose() { 24 | // nothing to do 25 | } 26 | 27 | public Object[] getElements(Object inputElement) { 28 | if (inputElement instanceof SymbolSearchResult) { 29 | int elementLimit = mPage.getElementLimit().intValue(); 30 | Object[] elements = ((SymbolSearchResult) inputElement).getElements(); 31 | if (elementLimit != -1 && elements.length > elementLimit) { 32 | Object[] shownElements = new Object[elementLimit]; 33 | System.arraycopy(elements, 0, shownElements, 0, elementLimit); 34 | return shownElements; 35 | } 36 | return elements; 37 | } 38 | return EMPTY_ARRAY; 39 | } 40 | 41 | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { 42 | if (newInput instanceof SymbolSearchResult) { 43 | mSearchResult = (SymbolSearchResult) newInput; 44 | } 45 | } 46 | 47 | public void elementsChanged(Object[] updatedElements) { 48 | TableViewer viewer = (TableViewer) mPage.getViewer(); 49 | int elementLimit = mPage.getElementLimit().intValue(); 50 | boolean tableLimited = elementLimit != -1; 51 | for (int i = 0; i < updatedElements.length; i++) { 52 | if (mSearchResult.getMatchCount(updatedElements[i]) > 0) { 53 | if (viewer.testFindItem(updatedElements[i]) != null) { 54 | viewer.update(updatedElements[i], null); 55 | } 56 | else { 57 | if (!tableLimited || viewer.getTable().getItemCount() < elementLimit) { 58 | viewer.add(updatedElements[i]); 59 | } 60 | } 61 | } 62 | else { 63 | viewer.remove(updatedElements[i]); 64 | } 65 | } 66 | } 67 | 68 | public void clear() { 69 | mPage.getViewer().refresh(); 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/BrlDocumentSetupParticipant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor; 5 | 6 | import org.eclipse.core.filebuffers.*; 7 | import org.eclipse.jface.text.*; 8 | import org.eclipse.jface.text.rules.*; 9 | 10 | /** 11 | * @author SchemeWay Project. 12 | * 13 | */ 14 | public class BrlDocumentSetupParticipant implements IDocumentSetupParticipant { 15 | 16 | public BrlDocumentSetupParticipant() { 17 | } 18 | 19 | public void setup(IDocument document) { 20 | String[] partitions = new String[] 21 | { 22 | SchemePartitionScanner.SCHEME_STRING, SchemePartitionScanner.SCHEME_COMMENT, SchemePartitionScanner.SCHEME_HERESTRING 23 | }; 24 | 25 | IDocumentPartitioner partitioner = new FastPartitioner(new BrlPartitionScanner(), partitions); 26 | IDocumentExtension3 documentExtension3 = (IDocumentExtension3) document; 27 | documentExtension3.setDocumentPartitioner(SchemeDocumentSetupParticipant.SCHEME_PARTITIONING, partitioner); 28 | partitioner.connect(document); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/BrlPartitionScanner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor; 5 | 6 | import org.eclipse.jface.text.rules.*; 7 | 8 | /** 9 | * @author SchemeWay Project. 10 | * 11 | */ 12 | public class BrlPartitionScanner extends SchemePartitionScanner { 13 | 14 | public BrlPartitionScanner() { 15 | super(); 16 | } 17 | 18 | protected Token scanToken() { 19 | if (getPosition() == 0 || lookahead() == ']') { 20 | if (getPosition() != 0) 21 | consume(); 22 | return scanBrlString(); 23 | } 24 | else 25 | return super.scanToken(); 26 | } 27 | 28 | protected boolean endOfDefaultPartition() { 29 | return isEndPosition(getPosition()) || (lookahead() == ']'); 30 | } 31 | 32 | private Token scanBrlString() { 33 | while (!isEndPosition(getPosition()) && lookahead() != '[') { 34 | consume(); 35 | } 36 | if (lookahead() == '[') { 37 | consume(); 38 | } 39 | return SchemePartitionScanner.TOKEN_STRING; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/ColorManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.editor; 7 | 8 | import java.util.*; 9 | 10 | import org.eclipse.swt.graphics.*; 11 | import org.eclipse.swt.widgets.*; 12 | 13 | public class ColorManager { 14 | 15 | protected Map fColorTable = new HashMap(10); 16 | 17 | public void dispose() { 18 | Iterator e = fColorTable.values().iterator(); 19 | while (e.hasNext()) 20 | ((Color) e.next()).dispose(); 21 | } 22 | 23 | public Color getColor(RGB rgb) { 24 | Color color = (Color) fColorTable.get(rgb); 25 | if (color == null) { 26 | color = new Color(Display.getCurrent(), rgb); 27 | fColorTable.put(rgb, color); 28 | } 29 | return color; 30 | } 31 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/ISchemeColorConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.editor; 7 | 8 | import org.eclipse.swt.graphics.*; 9 | 10 | public interface ISchemeColorConstants { 11 | RGB SCHEME_PAREN = new RGB(0, 0, 0); 12 | RGB SCHEME_COMMENT = new RGB(0, 128, 0); 13 | RGB SCHEME_CONSTANT = new RGB(92, 0, 0); 14 | RGB SCHEME_DEFINE = new RGB(0, 0, 0); 15 | RGB SCHEME_KEYWORD = new RGB(50, 128, 50); 16 | RGB SCHEME_KEY = new RGB(0, 255, 0); 17 | RGB SCHEME_SPECIAL = new RGB(0, 0, 255); 18 | RGB SCHEME_MUTATOR = new RGB(196, 0, 0); 19 | RGB SCHEME_TYPE = new RGB(128, 0, 128); 20 | RGB SCHEME_ERROR = new RGB(255, 0, 0); 21 | RGB SCHEME_PUNCTUATION = new RGB(0, 0, 0); 22 | 23 | RGB SCHEME_STRING = new RGB(96, 96, 96); 24 | RGB SCHEME_DEFAULT = new RGB(0, 0, 0); 25 | 26 | RGB SCHEME_BACKGROUND = new RGB(255, 255, 255); 27 | 28 | RGB MATCHING_PARENS = new RGB(128, 196, 128); 29 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/ISchemeOutlinePage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.editor; 7 | 8 | import org.eclipse.ui.views.contentoutline.*; 9 | 10 | public interface ISchemeOutlinePage extends IContentOutlinePage 11 | { 12 | void update(); 13 | } 14 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/SchemeActionConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2003 Nu Echo Inc. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor; 5 | 6 | import org.schemeway.plugins.schemescript.*; 7 | 8 | /** 9 | * @author Nu Echo Inc. 10 | */ 11 | public final class SchemeActionConstants { 12 | private SchemeActionConstants() { 13 | } 14 | 15 | private final static String SEXP_PREFIX = SchemeScriptPlugin.PLUGIN_NS + ".sexp."; 16 | public final static String SEXP_FORWARD = SEXP_PREFIX + "forward"; 17 | public final static String SEXP_SELECT_FORWARD = SEXP_PREFIX + "select-forward"; 18 | public final static String SEXP_BACKWARD = SEXP_PREFIX + "backward"; 19 | public final static String SEXP_SELECT_BACKWARD = SEXP_PREFIX + "select-backward"; 20 | public final static String SEXP_UP = SEXP_PREFIX + "up"; 21 | public final static String SEXP_SELECT_UP = SEXP_PREFIX + "select-up"; 22 | public final static String SEXP_DOWN = SEXP_PREFIX + "down"; 23 | public final static String SEXP_SWAP = SEXP_PREFIX + "swap"; 24 | public final static String SEXP_FORMAT = SEXP_PREFIX + "format"; 25 | public final static String SEXP_MOUSECOPY = SEXP_PREFIX + "mousecopy"; 26 | public final static String SEXP_EXTENDED_MOUSECOPY = SEXP_PREFIX + "extended-mousecopy"; 27 | public final static String SEXP_RESTORE_SELECTION = SEXP_PREFIX + "restore-selection"; 28 | public final static String SEXP_EXPAND_SELECTION = SEXP_PREFIX + "expand-selection"; 29 | 30 | private final static String COMMENT_PREFIX = SchemeScriptPlugin.PLUGIN_NS + ".comment."; 31 | public final static String COMMENT_CHAPTER = COMMENT_PREFIX + "chapter"; 32 | public final static String COMMENT_SECTION = COMMENT_PREFIX + "section"; 33 | public final static String COMMENT_HEADER = COMMENT_PREFIX + "header"; 34 | public final static String COMMENT_SELECTION = COMMENT_PREFIX + "selection"; 35 | 36 | private final static String EVAL_PREFIX = SchemeScriptPlugin.PLUGIN_NS + ".eval."; 37 | public final static String EVAL_EXPR = EVAL_PREFIX + "expression"; 38 | public final static String EVAL_DEF = EVAL_PREFIX + "definition"; 39 | public final static String EVAL_START = EVAL_PREFIX + "start"; 40 | public final static String EVAL_RESTART = EVAL_PREFIX + "restart"; 41 | public final static String EVAL_FAST = EVAL_PREFIX + "fast"; 42 | public final static String EVAL_LOAD = EVAL_PREFIX + "load"; 43 | 44 | private final static String FORMAT_PREFIX = SchemeScriptPlugin.PLUGIN_NS + ".format."; 45 | public final static String COMPRESS_SPACES = FORMAT_PREFIX + "compress"; 46 | public final static String MOVE_RPAREN_FORWARD = FORMAT_PREFIX + "moveRparen"; 47 | public final static String MOVE_LPAREN_BACKWARD = FORMAT_PREFIX + "moveLparen"; 48 | 49 | public final static String JUMP_DEF = SchemeScriptPlugin.PLUGIN_NS + ".jump.definition"; 50 | public final static String CHOOSE_SYMBOL = SchemeScriptPlugin.PLUGIN_NS + ".dictionary.find"; 51 | public final static String RENAME_SYMBOL = SchemeScriptPlugin.PLUGIN_NS + ".code.renameSymbol"; 52 | public final static String RENAME_LOCAL_SYMBOL = SchemeScriptPlugin.PLUGIN_NS + ".code.renameLocalSymbol"; 53 | } 54 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/SchemeAnnotationHover.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor; 5 | 6 | import java.util.*; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.eclipse.jface.text.source.*; 10 | import org.eclipse.ui.texteditor.*; 11 | 12 | /** 13 | * @author SchemeWay Project. 14 | */ 15 | public class SchemeAnnotationHover implements IAnnotationHover { 16 | 17 | public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) { 18 | String hoverInfo = null; 19 | 20 | IAnnotationModel annotationModel = sourceViewer.getAnnotationModel(); 21 | IDocument document = sourceViewer.getDocument(); 22 | 23 | try { 24 | Iterator annotationIterator = annotationModel.getAnnotationIterator(); 25 | StringBuffer info = new StringBuffer(); 26 | 27 | while (annotationIterator.hasNext()) { 28 | Annotation annotation = (Annotation) annotationIterator.next(); 29 | Position position = annotationModel.getPosition(annotation); 30 | 31 | if (isMarkerAnnotation(annotation) && isPositionSpansLine(lineNumber, document, position)) { 32 | if (info.length() > 0) 33 | info.append('\n'); 34 | info.append(annotation.getText()); 35 | } 36 | } 37 | 38 | hoverInfo = info.toString(); 39 | } 40 | catch (BadLocationException e) { 41 | } 42 | 43 | return hoverInfo; 44 | } 45 | 46 | private boolean isMarkerAnnotation(Annotation annotation) { 47 | return annotation instanceof MarkerAnnotation; 48 | } 49 | 50 | private boolean isPositionSpansLine(int lineNumber, IDocument document, Position position) 51 | throws BadLocationException { 52 | return document.getLineOfOffset(position.offset) <= lineNumber 53 | && lineNumber <= document.getLineOfOffset(position.offset + position.length); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/SchemeConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.editor; 7 | 8 | import org.eclipse.core.runtime.Assert; 9 | import org.eclipse.jface.text.*; 10 | import org.eclipse.jface.text.contentassist.*; 11 | import org.eclipse.jface.text.hyperlink.*; 12 | import org.eclipse.jface.text.presentation.*; 13 | import org.eclipse.jface.text.source.*; 14 | 15 | public class SchemeConfiguration extends SourceViewerConfiguration { 16 | private SchemeTextTools mTextTools; 17 | private IUndoManager mUndoManager; 18 | private SchemeEditor mEditor; 19 | 20 | public SchemeConfiguration(SchemeTextTools textTools, SchemeEditor editor) { 21 | Assert.isNotNull(textTools); 22 | this.mTextTools = textTools; 23 | this.mEditor = editor; 24 | } 25 | 26 | public SchemeEditor getEditor() { 27 | return mEditor; 28 | } 29 | 30 | public SchemeTextTools getTextTools() { 31 | return mTextTools; 32 | } 33 | 34 | public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { 35 | return mTextTools.getContentTypes(); 36 | } 37 | 38 | public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) { 39 | return SchemeDocumentSetupParticipant.SCHEME_PARTITIONING; 40 | } 41 | 42 | public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { 43 | return mTextTools.getDoubleClickStrategy(contentType); 44 | } 45 | 46 | public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) { 47 | return mTextTools.getAutoEditStrategies(contentType); 48 | } 49 | 50 | public IUndoManager getUndoManager(ISourceViewer sourceViewer) { 51 | if (mUndoManager == null) { 52 | mUndoManager = super.getUndoManager(sourceViewer); 53 | } 54 | return mUndoManager; 55 | } 56 | 57 | protected SchemeColoringScanner getSchemeScanner() { 58 | return mTextTools.getSchemeColoringScanner(); 59 | } 60 | 61 | protected SchemeDefaultScanner getSchemeStringScanner() { 62 | return mTextTools.getSchemeStringScanner(); 63 | } 64 | 65 | public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { 66 | return mTextTools.getPresentationReconciler(); 67 | } 68 | 69 | public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { 70 | ContentAssistant assistant= new ContentAssistant(); 71 | assistant.setContentAssistProcessor(new SchemeContentAssistProcessor(getEditor()), IDocument.DEFAULT_CONTENT_TYPE); 72 | assistant.enableAutoActivation(true); 73 | assistant.setAutoActivationDelay(200); 74 | assistant.enableAutoInsert(true); 75 | assistant.enablePrefixCompletion(true); 76 | assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY); 77 | assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_BELOW); 78 | 79 | return assistant; 80 | } 81 | 82 | public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) { 83 | return new SchemeAnnotationHover(); 84 | } 85 | 86 | public ITextHover getTextHover(ISourceViewer viewer, String contentType) { 87 | return new SchemeTextHover(getEditor()); 88 | } 89 | 90 | public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { 91 | return new IHyperlinkDetector[] { 92 | new SymbolHyperlinkDetector(mEditor) 93 | }; 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/SchemeDefaultScanner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.editor; 7 | 8 | import org.eclipse.jface.preference.*; 9 | import org.eclipse.jface.text.*; 10 | import org.eclipse.jface.text.rules.*; 11 | import org.eclipse.swt.*; 12 | import org.eclipse.swt.graphics.*; 13 | import org.schemeway.plugins.schemescript.*; 14 | 15 | public class SchemeDefaultScanner implements ITokenScanner { 16 | private ColorManager mColorManager; 17 | private String mColorName; 18 | private Token mToken = new Token(null); 19 | private int mCurrentOffset; 20 | private int mCurrentLength; 21 | private boolean mEmpty; 22 | 23 | public SchemeDefaultScanner(ColorManager manager, String colorName) { 24 | mColorManager = manager; 25 | mColorName = colorName; 26 | updateColors(); 27 | } 28 | 29 | public void updateColors() { 30 | IPreferenceStore store = SchemeScriptPlugin.getDefault().getPreferenceStore(); 31 | 32 | RGB rgb = PreferenceConverter.getColor(store, mColorName); 33 | boolean bold = store.getBoolean(mColorName + ".bold"); 34 | boolean ital = store.getBoolean(mColorName + ".italic"); 35 | int style = SWT.NONE; 36 | if (bold) style |= SWT.BOLD; 37 | if (ital) style |= SWT.ITALIC; 38 | mToken.setData(new TextAttribute(mColorManager.getColor(rgb), null, style)); 39 | } 40 | 41 | public int getTokenLength() { 42 | return mCurrentLength; 43 | } 44 | 45 | public int getTokenOffset() { 46 | return mCurrentOffset; 47 | } 48 | 49 | public IToken nextToken() { 50 | if (mEmpty) { 51 | return Token.EOF; 52 | } 53 | else { 54 | mEmpty = true; 55 | return mToken; 56 | } 57 | } 58 | 59 | public void setRange(IDocument document, int offset, int length) { 60 | mCurrentOffset = offset; 61 | mCurrentLength = length; 62 | mEmpty = false; 63 | } 64 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/SchemeDocumentSetupParticipant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.editor; 7 | 8 | import org.eclipse.core.filebuffers.*; 9 | import org.eclipse.jface.text.*; 10 | import org.eclipse.jface.text.rules.*; 11 | 12 | public class SchemeDocumentSetupParticipant implements IDocumentSetupParticipant { 13 | 14 | public static final String SCHEME_PARTITIONING = "___scheme_partitioning_"; 15 | 16 | public SchemeDocumentSetupParticipant() { 17 | } 18 | 19 | public void setup(IDocument document) { 20 | String[] partitions = new String[] 21 | { 22 | SchemePartitionScanner.SCHEME_STRING, SchemePartitionScanner.SCHEME_COMMENT, SchemePartitionScanner.SCHEME_HERESTRING 23 | }; 24 | 25 | IDocumentPartitioner partitioner = new FastPartitioner(new SchemePartitionScanner(), partitions); 26 | IDocumentExtension3 documentExtension3 = (IDocumentExtension3) document; 27 | documentExtension3.setDocumentPartitioner(SCHEME_PARTITIONING, partitioner); 28 | partitioner.connect(document); 29 | } 30 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/SchemeWhitespaceDetector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.editor; 7 | 8 | import org.eclipse.jface.text.rules.*; 9 | 10 | public class SchemeWhitespaceDetector implements IWhitespaceDetector { 11 | 12 | public boolean isWhitespace(char c) { 13 | return (c == ' ' || c == '\t' || c == '\n' || c == '\r'); 14 | } 15 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/autoedits/CommentDeleter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005 SchemeWay.com 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.editor.autoedits; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | 11 | /** 12 | * @author SchemeWay.com 13 | */ 14 | public class CommentDeleter implements IAutoEditStrategy { 15 | 16 | public void customizeDocumentCommand(IDocument document, DocumentCommand command) { 17 | if (command.text.length() != 0) 18 | return; 19 | if (command.length != 1) 20 | return; 21 | 22 | try { 23 | ITypedRegion partition = SchemeTextUtilities.getPartition(document, command.offset); 24 | if (partition.getType() == SchemePartitionScanner.SCHEME_COMMENT) { 25 | if (command.offset == partition.getOffset() && document.getChar(command.offset) != ';') { 26 | command.text = ""; 27 | command.offset = partition.getOffset(); 28 | command.length = partition.getLength(); 29 | } 30 | else if (document.getChar(partition.getOffset()) == '#' 31 | && ((command.offset - partition.getOffset()) <= 1 32 | || (partition.getOffset() + partition.getLength() - command.offset) <= 2)) { 33 | command.offset = partition.getOffset(); 34 | command.length = partition.getLength(); 35 | } 36 | } 37 | } 38 | catch (BadLocationException exception) { 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/autoedits/DoubleQuoteInserter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.editor.autoedits; 7 | 8 | import org.eclipse.jface.text.*; 9 | 10 | public class DoubleQuoteInserter implements IAutoEditStrategy { 11 | 12 | public DoubleQuoteInserter() { 13 | } 14 | 15 | public void customizeDocumentCommand(IDocument document, DocumentCommand command) { 16 | try { 17 | if (command.text.equals("\\")) { 18 | if (document.getChar(command.offset) == '"') { 19 | command.text = "\\\\"; 20 | command.doit = true; 21 | command.length = 0; 22 | command.shiftsCaret = true; 23 | command.caretOffset = command.offset; 24 | } 25 | } 26 | else if (command.text.equals("\"")) { 27 | if (document.getChar(command.offset) == '"') { 28 | command.doit = true; 29 | command.text = ""; 30 | command.length = 0; 31 | command.shiftsCaret = true; 32 | command.caretOffset = command.offset + 1; 33 | } 34 | else { 35 | command.text = "\\\""; 36 | command.doit = true; 37 | command.length = 0; 38 | command.shiftsCaret = true; 39 | command.caretOffset = command.offset; 40 | } 41 | } 42 | } catch (BadLocationException exception) { 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/autoedits/SexpDeleter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.editor.autoedits; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | 11 | public class SexpDeleter implements IAutoEditStrategy { 12 | 13 | public SexpDeleter() { 14 | super(); 15 | } 16 | 17 | public void customizeDocumentCommand(IDocument document, DocumentCommand command) { 18 | try { 19 | if (command.text.length() == 0 && command.length == 1) { 20 | char currentChar; 21 | currentChar = document.getChar(command.offset); 22 | if (currentChar == '(' || currentChar == '[' || currentChar == '{') { 23 | SexpUtils.deleteForwardSexp(document, command); 24 | } 25 | else if (currentChar == ')' || currentChar == ']' || currentChar == '}') { 26 | SexpUtils.deleteBackwardSexp(document, command); 27 | } 28 | } 29 | else if (command.text.length() == 0 && command.length > 1) { 30 | ITypedRegion startPartition = SchemeTextUtilities.getPartition(document, command.offset); 31 | // FIXME - This is a hack to prevent already deleted characters from CommentDeleter 32 | // to be reinserted... 33 | if (startPartition.getType() == SchemePartitionScanner.SCHEME_COMMENT) { 34 | if ((command.offset + command.length) <= (startPartition.getOffset() + startPartition.getLength())) 35 | return; 36 | } 37 | if (SexpUtils.whitespacesOnly(document, command.offset, command.length)) 38 | return; 39 | SexpUtils.deleteSelection(document, command); 40 | } 41 | else if (command.text.length() > 1 && command.length == 0) { 42 | SexpUtils.insertText(document, command); 43 | } 44 | } 45 | catch (BadLocationException e) { 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/autoedits/StringDeleter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.editor.autoedits; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | 11 | public class StringDeleter implements IAutoEditStrategy { 12 | 13 | public StringDeleter() { 14 | super(); 15 | } 16 | 17 | public void customizeDocumentCommand(IDocument document, DocumentCommand command) { 18 | try { 19 | if (command.length == 1 && command.text.length() == 0) { 20 | ITypedRegion partition = SchemeTextUtilities.getPartition(document, command.offset); 21 | 22 | if (partition.getType() == SchemePartitionScanner.SCHEME_STRING) { 23 | if (command.offset == partition.getOffset() 24 | || command.offset == (partition.getOffset() + partition.getLength() - 1)) { 25 | command.offset = partition.getOffset(); 26 | command.length = partition.getLength(); 27 | } 28 | else { 29 | char currentChar = document.getChar(command.offset); 30 | if (currentChar == '\\' && command.offset < partition.getOffset() + partition.getLength() - 1) { 31 | // remove '\' and the next character 32 | command.length = 2; 33 | if (document.getChar(command.offset - 1) == '\\') { 34 | command.offset -= 1; 35 | } 36 | } 37 | else if (currentChar == '"') { 38 | command.offset -= 1; 39 | command.length = 2; 40 | } 41 | } 42 | } 43 | } 44 | else if (command.length > 1 && command.text.length() == 0) { 45 | ITypedRegion partition = SchemeTextUtilities.getPartition(document, command.offset); 46 | 47 | if (partition.getType() == SchemePartitionScanner.SCHEME_STRING 48 | && (command.offset + command.length) > (partition.getOffset() + partition.getLength())) 49 | SexpUtils.deleteSelection(document, command); 50 | } 51 | } 52 | catch (BadLocationException exception) { 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/outline/DefinitionsContentBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor.outline; 5 | 6 | import java.util.*; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | 11 | /** 12 | * @author SchemeWay Project. 13 | * 14 | */ 15 | public class DefinitionsContentBuilder implements OutlineContentBuilder { 16 | 17 | public OutlineNode[] buildNodes(SchemeEditor editor) throws BadLocationException, BadPositionCategoryException { 18 | List nodes = new ArrayList(); 19 | 20 | ContentUtilities.addDefinitions(editor, nodes, true); 21 | Collections.sort(nodes, ContentUtilities.NODE_COMPARATOR); 22 | 23 | return (OutlineNode[]) nodes.toArray(new OutlineNode[nodes.size()]); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/outline/NodeLabelProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor.outline; 5 | 6 | import org.eclipse.jface.viewers.*; 7 | import org.eclipse.swt.graphics.*; 8 | 9 | public class NodeLabelProvider extends LabelProvider { 10 | public String getText(Object element) { 11 | return ((OutlineNode)element).name; 12 | } 13 | 14 | public Image getImage(Object element) 15 | { 16 | OutlineNode section = (OutlineNode)element; 17 | if (section.type == OutlineNode.SECTION) { 18 | return SchemeOutlineImageProvider.getSectionImage(); 19 | } 20 | else if (section.type == OutlineNode.CHAPTER ) { 21 | return SchemeOutlineImageProvider.getChapterImage(); 22 | } 23 | 24 | return SchemeOutlineImageProvider.getDefinitionImage(); 25 | } 26 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/outline/OutlineContentBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor.outline; 5 | 6 | import org.eclipse.jface.text.*; 7 | import org.schemeway.plugins.schemescript.editor.*; 8 | 9 | /** 10 | * @author SchemeWay Project. 11 | * 12 | */ 13 | public interface OutlineContentBuilder { 14 | OutlineNode[] buildNodes(SchemeEditor editor) throws BadLocationException, BadPositionCategoryException; 15 | } 16 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/outline/OutlineNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor.outline; 5 | 6 | import java.util.*; 7 | 8 | import org.eclipse.jface.text.*; 9 | 10 | public class OutlineNode { 11 | public static final String CHAPTER = "chapter"; 12 | public static final String SECTION = "section"; 13 | public static final String DEFINITION = "definition"; 14 | 15 | public String name; 16 | public Position position; 17 | public List children; 18 | public OutlineNode parent; 19 | public String type; 20 | public int level; 21 | 22 | public OutlineNode(String theType, String theName, Position thePosition, int theLevel) { 23 | this.type = theType; 24 | this.name = theName; 25 | this.position = thePosition; 26 | this.parent = null; 27 | this.level = theLevel; 28 | this.children = new LinkedList(); 29 | } 30 | 31 | public void addSubsection(OutlineNode section) { 32 | section.parent = this; 33 | for (int i = 0; i < children.size(); i++) { 34 | OutlineNode child = (OutlineNode) children.get(i); 35 | if (child.position.offset > section.position.offset) { 36 | children.add(i, section); 37 | return; 38 | } 39 | } 40 | children.add(section); 41 | } 42 | 43 | public OutlineNode[] getChildren() { 44 | return (OutlineNode[]) children.toArray(new OutlineNode[children.size()]); 45 | } 46 | 47 | public int size() { 48 | return children.size(); 49 | } 50 | 51 | public static OutlineNode createSection(String name, Position position, int level) { 52 | return new OutlineNode(SECTION, name, position, level); 53 | } 54 | 55 | public static OutlineNode createChapter(String name, Position position, int level) { 56 | return new OutlineNode(CHAPTER, name, position, level); 57 | } 58 | 59 | public static OutlineNode createDefinition(String name, Position position, int level) { 60 | return new OutlineNode(DEFINITION, name, position, level); 61 | } 62 | 63 | public Object clone() { 64 | return new OutlineNode(type, name, position, level); 65 | } 66 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/outline/OutlineNodeContentProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor.outline; 5 | 6 | import org.eclipse.jface.viewers.*; 7 | 8 | class OutlineNodeContentProvider implements ITreeContentProvider { 9 | 10 | public Object[] getChildren(Object parentElement) 11 | { 12 | if (parentElement != null) { 13 | return ((OutlineNode)parentElement).getChildren(); 14 | } 15 | return null; 16 | } 17 | public Object getParent(Object element) 18 | { 19 | return ((OutlineNode)element).parent; 20 | } 21 | 22 | public boolean hasChildren(Object element) 23 | { 24 | return ((OutlineNode)element).children.size() > 0; 25 | } 26 | 27 | public Object[] getElements(Object inputElement) 28 | { 29 | return getChildren(inputElement); 30 | } 31 | 32 | public void dispose() 33 | { 34 | } 35 | 36 | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) 37 | { 38 | } 39 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/outline/OutlineNodePositionComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor.outline; 5 | 6 | import java.util.*; 7 | 8 | class OutlineNodePositionComparator implements Comparator { 9 | public int compare(Object o1, Object o2) { 10 | OutlineNode s1 = (OutlineNode)o1; 11 | OutlineNode s2 = (OutlineNode)o2; 12 | 13 | if (s1.position.offset < s2.position.offset) 14 | return -1; 15 | else if (s1.position.offset > s2.position.offset) 16 | return 1; 17 | else 18 | return 0; 19 | } 20 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/outline/SchemeOutlineImageProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor.outline; 5 | 6 | import org.eclipse.core.runtime.Path; 7 | import org.eclipse.swt.graphics.*; 8 | import org.eclipse.swt.widgets.*; 9 | import org.schemeway.plugins.schemescript.*; 10 | 11 | /** 12 | * @author SchemeWay Project. 13 | * 14 | */ 15 | public final class SchemeOutlineImageProvider { 16 | private static Image CHAPTER_IMAGE; 17 | private static Image SECTION_IMAGE; 18 | private static Image DEFINITION_IMAGE; 19 | 20 | static { 21 | try { 22 | CHAPTER_IMAGE = new Image(Display.getDefault(), SchemeScriptPlugin.findFile(new Path("icons/chapter.gif")).openStream()); 23 | SECTION_IMAGE = new Image(Display.getDefault(), SchemeScriptPlugin.findFile(new Path("icons/section.gif")).openStream()); 24 | DEFINITION_IMAGE = new Image(Display.getDefault(), SchemeScriptPlugin.findFile(new Path("icons/definition.gif")).openStream()); 25 | } 26 | catch (Throwable exception) { 27 | CHAPTER_IMAGE = null; 28 | SECTION_IMAGE = null; 29 | DEFINITION_IMAGE = null; 30 | } 31 | } 32 | 33 | public static Image getChapterImage() { 34 | return CHAPTER_IMAGE; 35 | } 36 | 37 | public static Image getSectionImage() { 38 | return SECTION_IMAGE; 39 | } 40 | 41 | public static Image getDefinitionImage() { 42 | return DEFINITION_IMAGE; 43 | } 44 | 45 | private SchemeOutlineImageProvider() { 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/outline/SectionsAndDefinitionsContentBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor.outline; 5 | 6 | import java.util.*; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | 11 | /** 12 | * @author SchemeWay Project. 13 | * 14 | */ 15 | public class SectionsAndDefinitionsContentBuilder implements OutlineContentBuilder { 16 | 17 | public OutlineNode[] buildNodes(SchemeEditor editor) throws BadLocationException, BadPositionCategoryException { 18 | List nodes = new ArrayList(); 19 | 20 | ContentUtilities.addSections(editor.getDocument(), nodes); 21 | ContentUtilities.addDefinitions(editor, nodes, true); 22 | Collections.sort(nodes, ContentUtilities.NODE_COMPARATOR); 23 | 24 | return (OutlineNode[]) nodes.toArray(new OutlineNode[nodes.size()]); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/editor/outline/SectionsContentBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.editor.outline; 5 | 6 | import java.util.*; 7 | 8 | import org.eclipse.jface.text.*; 9 | import org.schemeway.plugins.schemescript.editor.*; 10 | 11 | /** 12 | * @author SchemeWay Project. 13 | * 14 | */ 15 | public class SectionsContentBuilder implements OutlineContentBuilder { 16 | 17 | public OutlineNode[] buildNodes(SchemeEditor editor) throws BadLocationException, BadPositionCategoryException { 18 | List nodes = new ArrayList(); 19 | 20 | ContentUtilities.addSections(editor.getDocument(), nodes); 21 | Collections.sort(nodes, ContentUtilities.NODE_COMPARATOR); 22 | 23 | return (OutlineNode[]) nodes.toArray(new OutlineNode[nodes.size()]); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/indentation/IndentationRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.indentation; 7 | 8 | public final class IndentationRule { 9 | public final static String DEFAULT = "default"; 10 | public final static String DEFINITION = "definition"; 11 | public final static String SEQUENCE = "sequence"; 12 | public final static String WITH = "with"; 13 | public final static String IF = "if"; 14 | public final static String NONE = "none"; 15 | 16 | public final static String[] ALL_SCHEMES = new String[] { 17 | DEFAULT, DEFINITION, SEQUENCE, IF, WITH, NONE 18 | }; 19 | 20 | private String mSymbol; 21 | private String mCategory; 22 | private int mHint; 23 | 24 | public IndentationRule(String symbol, String category, int hint) { 25 | mSymbol = symbol; 26 | setCategory(category); 27 | setHint(hint); 28 | } 29 | 30 | public String getSymbol() { 31 | return mSymbol; 32 | } 33 | 34 | public String getCategory() { 35 | return mCategory; 36 | } 37 | 38 | public int getHint() { 39 | return mHint; 40 | } 41 | 42 | public final void setCategory(String category) { 43 | mCategory = category; 44 | } 45 | 46 | public final void setHint(int hint) { 47 | mHint = hint; 48 | } 49 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/indentation/SchemeIndentationContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.indentation; 7 | 8 | import org.schemeway.plugins.schemescript.parser.*; 9 | 10 | public class SchemeIndentationContext { 11 | private SexpNavigator mExplorer; 12 | private SchemeIndentationManager mManager; 13 | private int mOffset; 14 | 15 | public SchemeIndentationContext(SexpNavigator explorer, SchemeIndentationManager manager, int offset) { 16 | this.mExplorer = explorer; 17 | this.mManager = manager; 18 | this.mOffset = offset; 19 | } 20 | 21 | public SexpNavigator getExplorer() { 22 | return mExplorer; 23 | } 24 | 25 | public SchemeIndentationManager getManager() { 26 | return mManager; 27 | } 28 | 29 | public int getOffset() { 30 | return mOffset; 31 | } 32 | 33 | public void setExplorer(SexpNavigator explorer) { 34 | mExplorer = explorer; 35 | } 36 | 37 | public void setManager(SchemeIndentationManager manager) { 38 | mManager = manager; 39 | } 40 | 41 | public void setOffset(int offset) { 42 | mOffset = offset; 43 | } 44 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/indentation/SchemeIndentationManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.indentation; 7 | 8 | import java.util.*; 9 | 10 | import org.eclipse.core.runtime.*; 11 | import org.eclipse.jface.preference.*; 12 | import org.schemeway.plugins.schemescript.*; 13 | import org.schemeway.plugins.schemescript.preferences.*; 14 | 15 | public class SchemeIndentationManager { 16 | private static IndentationRule DEFAULT_SCHEME; 17 | static { 18 | DEFAULT_SCHEME = new IndentationRule(null, IndentationRule.DEFAULT, 0); 19 | } 20 | 21 | private Map mRulesMap; 22 | 23 | public SchemeIndentationManager() { 24 | mRulesMap = new HashMap(); 25 | } 26 | 27 | public void clear() { 28 | mRulesMap.clear(); 29 | } 30 | 31 | public void setRules(IndentationRule[] rules) { 32 | Assert.isNotNull(rules); 33 | 34 | clear(); 35 | for (int index = 0; index < rules.length; index++) { 36 | IndentationRule scheme = rules[index]; 37 | if (scheme != null) { 38 | addIndentationRule(scheme); 39 | } 40 | } 41 | } 42 | 43 | public IndentationRule[] getRules() { 44 | return (IndentationRule[]) mRulesMap.values().toArray(new IndentationRule[mRulesMap.size()]); 45 | } 46 | 47 | public void addIndentationRule(IndentationRule rule) { 48 | mRulesMap.put(rule.getSymbol(), rule); 49 | } 50 | 51 | public final IndentationRule getFunction(String symbol) { 52 | IndentationRule scheme = (IndentationRule) mRulesMap.get(symbol); 53 | if (scheme == null) 54 | return DEFAULT_SCHEME; 55 | else 56 | return scheme; 57 | } 58 | 59 | public void loadRules() { 60 | IPreferenceStore store = SchemeScriptPlugin.getDefault().getPreferenceStore(); 61 | setRules(PreferenceUtil.getIndentationSchemes(store, IndentationPreferences.INDENT_SCHEMES)); 62 | } 63 | 64 | public void saveRules() { 65 | IPreferenceStore store = SchemeScriptPlugin.getDefault().getPreferenceStore(); 66 | PreferenceUtil.setIndentationSchemes(store, IndentationPreferences.INDENT_SCHEMES, getRules()); 67 | } 68 | 69 | /* -- Factory methods -- */ 70 | 71 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/AbstractInterpreter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.interpreter; 7 | 8 | import org.eclipse.core.resources.*; 9 | import org.eclipse.core.runtime.*; 10 | import org.eclipse.debug.core.*; 11 | import org.eclipse.debug.core.model.*; 12 | import org.eclipse.debug.ui.*; 13 | import org.eclipse.ui.*; 14 | import org.eclipse.ui.console.*; 15 | 16 | public abstract class AbstractInterpreter implements Interpreter 17 | { 18 | 19 | public abstract IInterpreterProcess getProcess(); 20 | 21 | public abstract String getConfigurationType(); 22 | 23 | public boolean isRunning() { 24 | return getProcess().isRunning(); 25 | } 26 | 27 | public void start() { 28 | IInterpreterProcess instance = getProcess(); 29 | if (instance != null && instance.getLaunch() == null) { 30 | try { 31 | ILaunchConfigurationType configType = DebugPlugin.getDefault() 32 | .getLaunchManager() 33 | .getLaunchConfigurationType(getConfigurationType()); 34 | ILaunchConfigurationWorkingCopy copy = configType.newInstance(null, "Scheme"); 35 | copy.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor()); 36 | } 37 | catch (CoreException exception) { 38 | } 39 | } 40 | if (instance != null && instance.getLaunch() != null) 41 | showConsole(); 42 | } 43 | 44 | public void stop() { 45 | IInterpreterProcess process = getProcess(); 46 | if (process.canTerminate()) { 47 | try { 48 | process.terminate(); 49 | } 50 | catch (DebugException e) { 51 | } 52 | } 53 | } 54 | 55 | public void restart() { 56 | if (isRunning()) { 57 | stop(); 58 | } 59 | start(); 60 | } 61 | 62 | public boolean supportInterruption() { 63 | return false; 64 | } 65 | 66 | public void interrupt() { 67 | } 68 | 69 | public void eval(String code) { 70 | if (!isRunning()) 71 | start(); 72 | getProcess().sendToInterpreter(code + "\n"); 73 | } 74 | 75 | public void load(IFile file) { 76 | String filename = file.getRawLocation().toString(); 77 | eval("(load \"" + filename + "\")"); 78 | } 79 | 80 | public void showConsole() { 81 | IProcess process = getProcess(); 82 | if (process == null || process.getLaunch() == null) 83 | return; 84 | 85 | IConsole console = DebugUITools.getConsole(process); 86 | ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console); 87 | IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); 88 | IViewPart view = page.findView("org.eclipse.ui.console.ConsoleView"); 89 | if (view != null) 90 | view.setFocus(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/IInterpreterProcess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.interpreter; 7 | 8 | import org.eclipse.debug.core.model.*; 9 | 10 | public interface IInterpreterProcess extends IProcess 11 | { 12 | boolean isRunning(); 13 | 14 | void sendToInterpreter(String code); 15 | } 16 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/Interpreter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.interpreter; 7 | 8 | import org.eclipse.core.resources.*; 9 | 10 | public interface Interpreter { 11 | boolean isRunning(); 12 | void start(); 13 | void stop(); 14 | void restart(); 15 | 16 | boolean supportInterruption(); 17 | void interrupt(); 18 | void eval(String code); 19 | void load(IFile file); 20 | 21 | void showConsole(); 22 | } 23 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/InterpreterSupport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.interpreter; 7 | 8 | import java.util.*; 9 | 10 | import org.eclipse.core.runtime.*; 11 | import org.schemeway.plugins.schemescript.*; 12 | 13 | public class InterpreterSupport { 14 | 15 | private static final String EXTENSION_POINT_ID = SchemeScriptPlugin.PLUGIN_NS + ".interpreters"; 16 | 17 | private InterpreterSupport() { 18 | // make sure this class is never instantiated 19 | } 20 | 21 | private static InterpreterType[] mCachedTypes = null; 22 | 23 | public static InterpreterType[] getTypes() { 24 | if (mCachedTypes != null) { 25 | return mCachedTypes; 26 | } 27 | 28 | IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID).getExtensions(); 29 | 30 | mCachedTypes = parseTypes(extensions); 31 | return mCachedTypes; 32 | } 33 | 34 | private static InterpreterType[] parseTypes(IExtension[] extensions) { 35 | List types = new ArrayList(20); 36 | 37 | for (int i = 0; i < extensions.length; i++) { 38 | IExtension extension = extensions[i]; 39 | IConfigurationElement[] elements = extension.getConfigurationElements(); 40 | for (int j = 0; j < elements.length; j++) { 41 | IConfigurationElement element = elements[j]; 42 | if (element.getName().equals("interpreter")) { 43 | String name = element.getAttribute("name"); 44 | String id = element.getAttribute("id"); 45 | String cls = element.getAttribute("class"); 46 | InterpreterType type = new InterpreterType(name, id, cls, element); 47 | 48 | types.add(type); 49 | } 50 | } 51 | } 52 | 53 | return (InterpreterType[])types.toArray(new InterpreterType[types.size()]); 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/InterpreterType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.interpreter; 7 | 8 | import org.eclipse.core.runtime.*; 9 | import org.eclipse.jface.dialogs.*; 10 | import org.eclipse.swt.widgets.*; 11 | import org.eclipse.ui.*; 12 | 13 | public class InterpreterType { 14 | 15 | private Interpreter mCachedInterpreter = null; 16 | private String mName; 17 | private String mClass; 18 | private String mId; 19 | private IConfigurationElement mElement; 20 | 21 | public InterpreterType(String name, String id, String clss, IConfigurationElement element) { 22 | super(); 23 | mElement = element; 24 | mName = name; 25 | mId = id; 26 | mClass = clss; 27 | } 28 | 29 | public String getName() { 30 | return mName; 31 | } 32 | 33 | public String getID() { 34 | return mId; 35 | } 36 | 37 | public Interpreter getInterpreter() { 38 | if (mCachedInterpreter != null) 39 | return mCachedInterpreter; 40 | try { 41 | mCachedInterpreter = (Interpreter) mElement.createExecutableExtension("class"); 42 | } 43 | catch(CoreException exception){ 44 | Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); 45 | MessageDialog.openError(shell, "Interpreter Error!", "Unable to instantiate interpreter: " + mClass); 46 | } 47 | return mCachedInterpreter; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/KawaInterpreter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.interpreter; 7 | 8 | import org.schemeway.plugins.schemescript.*; 9 | 10 | public class KawaInterpreter extends AbstractInterpreter { 11 | public static final String CONFIG_TYPE = SchemeScriptPlugin.PLUGIN_NS + ".kawaInterpreter"; 12 | 13 | public KawaInterpreter() { 14 | super(); 15 | } 16 | 17 | public IInterpreterProcess getProcess() { 18 | return KawaProcess.getInstance(); 19 | } 20 | 21 | public String getConfigurationType() { 22 | return CONFIG_TYPE; 23 | } 24 | 25 | public void stop() { 26 | } 27 | 28 | public void restart() { 29 | start(); 30 | } 31 | 32 | public boolean supportInterruption() { 33 | return false; 34 | } 35 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/KawaInterpreterDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.interpreter; 7 | 8 | import org.eclipse.core.runtime.*; 9 | import org.eclipse.debug.core.*; 10 | import org.eclipse.debug.core.model.*; 11 | 12 | public class KawaInterpreterDelegate implements ILaunchConfigurationDelegate 13 | { 14 | public KawaInterpreterDelegate() 15 | { 16 | super(); 17 | } 18 | 19 | public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) 20 | throws CoreException 21 | { 22 | KawaProcess.getInstance().setLaunch(launch); 23 | launch.addProcess(KawaProcess.getInstance()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/KawaProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.interpreter; 7 | 8 | import gnu.lists.*; 9 | import gnu.mapping.*; 10 | import kawa.standard.*; 11 | 12 | import org.eclipse.swt.widgets.*; 13 | import org.schemeway.plugins.schemescript.*; 14 | 15 | /** 16 | * The KawaProxy help ensure that all Scheme evaluations are done in the same 17 | * thread. 18 | * 19 | * TODO - change the implementation to not use the UI thread 20 | * @author schemeway 21 | */ 22 | public final class KawaProxy { 23 | 24 | private KawaProxy() { 25 | // Ensure that the class will not be instantiated 26 | } 27 | 28 | // Loads a file in the Kawa interpreter. 29 | public static void loadFile(final String filename) { 30 | Display.getDefault().syncExec(new Runnable() { 31 | public void run() { 32 | try { 33 | load.load.apply1(filename); 34 | } 35 | catch (Throwable e) { 36 | SchemeScriptPlugin.logException("Unable to load initialization files", e); 37 | } 38 | } 39 | }); 40 | } 41 | 42 | // Dereferences a symbol in the global environment. 43 | public static Object get(final String symbolName) { 44 | final Pair box = new Pair(); 45 | 46 | Display.getDefault().syncExec(new Runnable() { 47 | public void run() { 48 | try { 49 | Object object = Environment.getCurrent().get(symbolName); 50 | box.car = object; 51 | } catch (Throwable e) { 52 | SchemeScriptPlugin.logException("Error while referencing Scheme symbol", e); 53 | box.car = null; 54 | } 55 | } 56 | }); 57 | return box.car; 58 | } 59 | 60 | // Sets a symbol in the global environment 61 | public static void set(final String symbolName, final Object value) 62 | { 63 | runInSchemeThread(new Runnable() { 64 | public void run() { 65 | Environment env = Environment.getCurrent(); 66 | env.define(env.getSymbol(symbolName), null, value); 67 | } 68 | }); 69 | } 70 | 71 | // Runs a runnable in the Scheme thread 72 | public static void runInSchemeThread(Runnable runnable) { 73 | if (runnable == null) 74 | return; 75 | 76 | Display.getDefault().syncExec(runnable); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/MonitoredOutputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.interpreter; 5 | 6 | import java.io.*; 7 | import java.util.*; 8 | 9 | import org.eclipse.debug.core.*; 10 | import org.eclipse.debug.core.model.*; 11 | 12 | class MonitoredOutputStream extends OutputStream implements IStreamMonitor { 13 | 14 | private List mListeners = new LinkedList(); 15 | public static final String PROMPT = "> "; 16 | 17 | public MonitoredOutputStream() { 18 | } 19 | 20 | public void addListener(IStreamListener listener) { 21 | if (!mListeners.contains(listener)) 22 | mListeners.add(listener); 23 | } 24 | 25 | public String getContents() { 26 | return null; 27 | //return (mIsStdout ? MonitoredOutputStream.PROMPT : ""); 28 | } 29 | 30 | public void removeListener(IStreamListener listener) { 31 | mListeners.remove(listener); 32 | } 33 | 34 | // send the string to all listeners. 35 | private void writeString(String text) { 36 | for (Iterator iter = mListeners.iterator(); iter.hasNext();) { 37 | IStreamListener listener = (IStreamListener) iter.next(); 38 | listener.streamAppended(text, this); 39 | } 40 | } 41 | 42 | public void write(byte[] bytes) { 43 | char[] chars = new char[bytes.length]; 44 | for (int i = 0; i < chars.length; i++) { 45 | chars[i] = (char) bytes[i]; 46 | } 47 | writeString(new String(chars)); 48 | } 49 | 50 | public void write(int b) { 51 | if ((char) b == '\r') 52 | return; 53 | char[] chars = 54 | { 55 | (char) b 56 | }; 57 | writeString(new String(chars)); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/RemoteInterpreter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.interpreter; 7 | 8 | import org.schemeway.plugins.schemescript.*; 9 | 10 | public class RemoteInterpreter extends AbstractInterpreter 11 | { 12 | public static final String CONFIG_TYPE = SchemeScriptPlugin.PLUGIN_NS + ".remoteInterpreter"; 13 | 14 | public IInterpreterProcess getProcess() 15 | { 16 | return RemoteInterpreterProcess.getInstance(); 17 | } 18 | 19 | public String getConfigurationType() { 20 | return CONFIG_TYPE; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/RemoteInterpreterDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.interpreter; 7 | 8 | import org.eclipse.core.runtime.*; 9 | import org.eclipse.debug.core.*; 10 | import org.eclipse.debug.core.model.*; 11 | 12 | public class RemoteInterpreterDelegate implements ILaunchConfigurationDelegate 13 | { 14 | public RemoteInterpreterDelegate() 15 | { 16 | super(); 17 | } 18 | 19 | public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) 20 | throws CoreException 21 | { 22 | RemoteInterpreterProcess.getInstance().setLaunch(launch); 23 | launch.addProcess(RemoteInterpreterProcess.getInstance()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/SiscInterpreter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.interpreter; 5 | 6 | import org.schemeway.plugins.schemescript.*; 7 | 8 | /** 9 | * @author SchemeWay Project. 10 | * 11 | */ 12 | public class SiscInterpreter extends AbstractInterpreter { 13 | public static final String CONFIG_TYPE = SchemeScriptPlugin.PLUGIN_NS + ".siscInterpreter"; 14 | 15 | public SiscInterpreter() { 16 | super(); 17 | } 18 | 19 | public IInterpreterProcess getProcess() { 20 | return SiscProcess.getInstance(); 21 | } 22 | 23 | public String getConfigurationType() { 24 | return CONFIG_TYPE; 25 | } 26 | 27 | public void stop() { 28 | } 29 | 30 | public void restart() { 31 | start(); 32 | } 33 | 34 | public boolean supportInterruption() { 35 | return false; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/SiscInterpreterDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.interpreter; 5 | 6 | import org.eclipse.core.runtime.*; 7 | import org.eclipse.debug.core.*; 8 | import org.eclipse.debug.core.model.*; 9 | 10 | /** 11 | * @author SchemeWay Project. 12 | * 13 | */ 14 | public class SiscInterpreterDelegate implements ILaunchConfigurationDelegate { 15 | 16 | public SiscInterpreterDelegate() 17 | { 18 | } 19 | 20 | public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) 21 | throws CoreException 22 | { 23 | SiscProcess.getInstance().setLaunch(launch); 24 | launch.addProcess(SiscProcess.getInstance()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/interpreter/SocketExceptionHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2005 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.interpreter; 7 | 8 | import java.net.*; 9 | 10 | public interface SocketExceptionHandler 11 | { 12 | void exceptionOccurred(SocketException exception); 13 | } 14 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/parser/ISchemeTokenIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.parser; 7 | 8 | public interface ISchemeTokenIterator { 9 | void setPosition(int position); 10 | 11 | SchemeToken nextToken(); 12 | SchemeToken nextToken(boolean ignoreWS); 13 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/parser/SchemeReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004-2006 SchemeWay Project. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.parser; 5 | 6 | import org.eclipse.jface.text.*; 7 | 8 | /** 9 | * @author SchemeWay Project. 10 | * 11 | */ 12 | public class SchemeReader { 13 | private SchemeScanner mScanner; 14 | private int mStart; 15 | private int mEnd; 16 | private SchemeToken mToken; 17 | private IDocument mDocument; 18 | 19 | private void initializeScanner(IDocument document, int start, int end) { 20 | mDocument = document; 21 | mScanner = new SchemeScanner(); 22 | mStart = start; 23 | mEnd = start; 24 | mScanner.setRange(document, start, end - start); 25 | mToken = null; 26 | } 27 | 28 | public Region nextExpression(IDocument document, int start, int end) { 29 | 30 | initializeScanner(document, start, end); 31 | 32 | try { 33 | parseExpression(); 34 | } 35 | catch (ParsingException exception) { 36 | mEnd = exception.getOffset(); 37 | } 38 | 39 | return new Region(mStart, mEnd - mStart); 40 | } 41 | 42 | /** 43 | * 44 | */ 45 | private void parseExpression() throws ParsingException { 46 | boolean done = false; 47 | 48 | while (!done) { 49 | int type = lookahead().getType(); 50 | switch (type) { 51 | case SchemeToken.COMMENT: 52 | case SchemeToken.WSPACE: { 53 | consume(); 54 | break; 55 | } 56 | case SchemeToken.EXPR_COMMENT_PREFIX: { 57 | consume(); 58 | parseExpression(); 59 | break; 60 | } 61 | case SchemeToken.VECTORPREFIX: 62 | case SchemeToken.LPAREN: { 63 | if (type == SchemeToken.VECTORPREFIX) 64 | consume(); 65 | consume(); 66 | parseExpressionList(); 67 | if (!(type == SchemeToken.RPAREN)) { 68 | int offset = lookahead() == SchemeToken.EOF ? mDocument.getLength() : lookahead().getOffset(); 69 | throw new ParsingException("RPAREN expected", offset); 70 | } 71 | consume(); 72 | done = true; 73 | break; 74 | } 75 | case SchemeToken.RPAREN: { 76 | throw new ParsingException("unexpected RPAREN", lookahead().getOffset()); 77 | } 78 | case SchemeToken.EOFTOK: 79 | throw new ParsingException("End of buffer!", mDocument.getLength()); 80 | default: 81 | consume(); 82 | done = true; 83 | } 84 | } 85 | mEnd = mScanner.getTokenOffset(); 86 | } 87 | 88 | private void parseExpressionList() throws ParsingException { 89 | skipWhitespaces(); 90 | while (lookahead() != SchemeToken.EOF && lookahead().getType() != SchemeToken.RPAREN) { 91 | parseExpression(); 92 | skipWhitespaces(); 93 | } 94 | } 95 | 96 | private void skipWhitespaces() { 97 | int type = lookahead().getType(); 98 | while (type == SchemeToken.COMMENT || type == SchemeToken.WSPACE) { 99 | consume(); 100 | type = lookahead().getType(); 101 | } 102 | } 103 | 104 | private SchemeToken lookahead() { 105 | if (mToken == null) { 106 | consume(); 107 | } 108 | return mToken; 109 | } 110 | 111 | private void consume() { 112 | if (mToken != SchemeToken.EOF) 113 | mToken = mScanner.nextToken(); 114 | } 115 | 116 | private class ParsingException extends Exception { 117 | private int mOffset; 118 | 119 | public ParsingException(String message, int offset) { 120 | super(message); 121 | mOffset = offset; 122 | } 123 | 124 | public int getOffset() { 125 | return mOffset; 126 | } 127 | 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/preferences/ActionPreferences.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.preferences; 7 | 8 | import org.eclipse.jface.preference.*; 9 | import org.eclipse.swt.*; 10 | import org.eclipse.swt.layout.*; 11 | import org.eclipse.swt.widgets.*; 12 | import org.schemeway.plugins.schemescript.*; 13 | 14 | public class ActionPreferences extends SchemePreferencePage { 15 | public final static String PREFIX = SchemeScriptPlugin.PLUGIN_NS + ".action."; 16 | public final static String ACTION_PRIVATE_ALIAS = PREFIX + "private-alias"; 17 | 18 | public static void initializeDefaults(IPreferenceStore store) { 19 | store.setDefault(ACTION_PRIVATE_ALIAS, false); 20 | } 21 | 22 | public static boolean usePrivateAlias() { 23 | IPreferenceStore store = SchemeScriptPlugin.getDefault().getPreferenceStore(); 24 | 25 | return store.getBoolean(ActionPreferences.ACTION_PRIVATE_ALIAS); 26 | } 27 | 28 | private Button mPrivateAlias; 29 | 30 | @Override 31 | protected Control createContents(Composite parent) { 32 | Composite composite = new Composite(parent, SWT.NONE); 33 | composite.setLayout(new GridLayout(1, false)); 34 | 35 | createCommandsSection(composite); 36 | 37 | initializeValues(); 38 | return composite; 39 | } 40 | 41 | private void createCommandsSection(Composite parent) { 42 | Group group = new Group(parent, SWT.NONE); 43 | group.setText("Commands"); 44 | group.setLayout(new GridLayout(1, false)); 45 | group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); 46 | 47 | mPrivateAlias = new Button(group, SWT.CHECK); 48 | mPrivateAlias.setText("Add define-alias command inserts define-private-alias"); 49 | } 50 | 51 | @Override 52 | protected IPreferenceStore doGetPreferenceStore() { 53 | return SchemeScriptPlugin.getDefault().getPreferenceStore(); 54 | } 55 | 56 | @Override 57 | protected void doPerformDefaults() { 58 | IPreferenceStore store = getPreferenceStore(); 59 | 60 | mPrivateAlias.setSelection(store.getDefaultBoolean(ACTION_PRIVATE_ALIAS)); 61 | } 62 | 63 | @Override 64 | protected void initializeValues() { 65 | IPreferenceStore store = getPreferenceStore(); 66 | 67 | mPrivateAlias.setSelection(store.getBoolean(ACTION_PRIVATE_ALIAS)); 68 | } 69 | 70 | @Override 71 | protected void storeValues() { 72 | IPreferenceStore store = getPreferenceStore(); 73 | 74 | store.setValue(ACTION_PRIVATE_ALIAS, mPrivateAlias.getSelection()); 75 | } 76 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/preferences/CommentPreferences.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.preferences; 7 | 8 | import org.eclipse.jface.preference.*; 9 | import org.eclipse.ui.*; 10 | import org.schemeway.plugins.schemescript.*; 11 | 12 | public class CommentPreferences extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { 13 | public final static String PREFIX = SchemeScriptPlugin.PLUGIN_NS + ".comment."; 14 | public final static String COMMENT_PREFIX = PREFIX + "prefix"; 15 | public final static String COMMENT_AUTHOR = PREFIX + "author"; 16 | public final static String COMMENT_COPYRIGHT = PREFIX + "copyright"; 17 | public final static String COMMENT_CONTINUE = PREFIX + "continue"; 18 | public final static String COMMENT_EMACS_BEHAVIOR = PREFIX + "emacs-behavior"; 19 | 20 | public CommentPreferences() { 21 | super("Scheme comment-related preferences", GRID); 22 | } 23 | 24 | public void init(IWorkbench workbench) { 25 | } 26 | 27 | protected IPreferenceStore doGetPreferenceStore() { 28 | return SchemeScriptPlugin.getDefault().getPreferenceStore(); 29 | } 30 | 31 | protected void initializeDefaultPreferences(IPreferenceStore store) { 32 | initializeDefaults(store); 33 | } 34 | 35 | public static void initializeDefaults(IPreferenceStore store) { 36 | store.setDefault(COMMENT_PREFIX, ";;"); 37 | store.setDefault(COMMENT_AUTHOR, ""); 38 | store.setDefault(COMMENT_COPYRIGHT, ""); 39 | store.setDefault(COMMENT_CONTINUE, true); 40 | store.setDefault(COMMENT_EMACS_BEHAVIOR, true); 41 | } 42 | 43 | /* 44 | * (non-Javadoc) 45 | * 46 | * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() 47 | */ 48 | protected void createFieldEditors() { 49 | initializeDefaultPreferences(getPreferenceStore()); 50 | addField(new StringFieldEditor(COMMENT_PREFIX, "Prefix for comments:", getFieldEditorParent())); 51 | addField(new StringFieldEditor(COMMENT_AUTHOR, "Author field content:", getFieldEditorParent())); 52 | addField(new StringFieldEditor(COMMENT_COPYRIGHT, "Copyright field content:", getFieldEditorParent())); 53 | addField(new BooleanFieldEditor(COMMENT_CONTINUE, 54 | "Automatically continue comment from previous line", 55 | getFieldEditorParent())); 56 | addField(new BooleanFieldEditor(COMMENT_EMACS_BEHAVIOR, 57 | "Emacs behavior for formatting lines starting with ;", 58 | getFieldEditorParent())); 59 | } 60 | 61 | public static String getCommentPrefix() { 62 | IPreferenceStore store = SchemeScriptPlugin.getDefault().getPreferenceStore(); 63 | String prefix = store.getString(CommentPreferences.COMMENT_PREFIX); 64 | if (prefix == null || prefix.equals("")) { 65 | return ";"; 66 | } 67 | else { 68 | return prefix; 69 | } 70 | } 71 | 72 | public static boolean isUsingEmacsBehavior() { 73 | IPreferenceStore store = SchemeScriptPlugin.getDefault().getPreferenceStore(); 74 | return store.getBoolean(CommentPreferences.COMMENT_EMACS_BEHAVIOR); 75 | } 76 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/preferences/FastEvalPreferences.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.preferences; 7 | 8 | import org.eclipse.jface.preference.*; 9 | import org.eclipse.ui.*; 10 | import org.schemeway.plugins.schemescript.*; 11 | 12 | public class FastEvalPreferences extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { 13 | public final static String PREFIX = SchemeScriptPlugin.PLUGIN_NS + ".interpreter."; 14 | public final static String FASTEVAL_0 = PREFIX + "0"; 15 | public final static String FASTEVAL_1 = PREFIX + "1"; 16 | public final static String FASTEVAL_2 = PREFIX + "2"; 17 | public final static String FASTEVAL_3 = PREFIX + "3"; 18 | public final static String FASTEVAL_4 = PREFIX + "4"; 19 | public final static String FASTEVAL_5 = PREFIX + "5"; 20 | public final static String FASTEVAL_6 = PREFIX + "6"; 21 | public final static String FASTEVAL_7 = PREFIX + "7"; 22 | public final static String FASTEVAL_8 = PREFIX + "8"; 23 | public final static String FASTEVAL_9 = PREFIX + "9"; 24 | 25 | public FastEvalPreferences() { 26 | super("Fast Keys", GRID); 27 | } 28 | 29 | public void init(IWorkbench workbench) { 30 | } 31 | 32 | protected IPreferenceStore doGetPreferenceStore() { 33 | return SchemeScriptPlugin.getDefault().getPreferenceStore(); 34 | } 35 | 36 | protected void initializeDefaultPreferences(IPreferenceStore store) { 37 | initializeDefaults(store); 38 | } 39 | 40 | public static void initializeDefaults(IPreferenceStore store) { 41 | for (int i=0; i<10; i++) { 42 | store.setDefault(PREFIX + i, ""); 43 | } 44 | } 45 | 46 | /* 47 | * (non-Javadoc) 48 | * 49 | * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() 50 | */ 51 | protected void createFieldEditors() { 52 | initializeDefaultPreferences(getPreferenceStore()); 53 | for (int i=0; i<10; i++) { 54 | addField(new StringFieldEditor(PREFIX + i, "Fast Eval Key " + i + ":", getFieldEditorParent())); 55 | } 56 | } 57 | 58 | 59 | public static String getFastEval(int index) { 60 | IPreferenceStore store = SchemeScriptPlugin.getDefault().getPreferenceStore(); 61 | if (0 <= index && index <= 9) { 62 | return store.getString(PREFIX + index); 63 | } 64 | return ""; 65 | } 66 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/preferences/IIndentationSchemeChangeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.preferences; 7 | 8 | import org.schemeway.plugins.schemescript.indentation.*; 9 | 10 | public interface IIndentationSchemeChangeListener { 11 | void schemeAdded(IndentationRule scheme); 12 | 13 | void schemeRemoved(IndentationRule scheme); 14 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/preferences/IndentationSchemeCellModifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.preferences; 7 | 8 | import org.eclipse.core.runtime.*; 9 | import org.eclipse.jface.viewers.*; 10 | import org.eclipse.swt.widgets.*; 11 | import org.schemeway.plugins.schemescript.indentation.*; 12 | 13 | public class IndentationSchemeCellModifier implements ICellModifier 14 | { 15 | private TableViewer mViewer; 16 | 17 | public IndentationSchemeCellModifier(TableViewer viewer) 18 | { 19 | Assert.isNotNull(viewer); 20 | mViewer = viewer; 21 | } 22 | 23 | public boolean canModify(Object element, String property) 24 | { 25 | return (property.equals(IndentationPreferences.ROW_SCHEME) 26 | || (property.equals(IndentationPreferences.ROW_HINT) 27 | && ((IndentationRule)element).getCategory() == IndentationRule.WITH)); 28 | } 29 | 30 | public Object getValue(Object element, String property) 31 | { 32 | IndentationRule scheme = (IndentationRule) element; 33 | if (property.equals(IndentationPreferences.ROW_SYMBOL)) 34 | return scheme.getSymbol(); 35 | else if (property.equals(IndentationPreferences.ROW_SCHEME)) 36 | return getIndexOfScheme(scheme.getCategory()); 37 | else 38 | return Integer.toString(scheme.getHint()); 39 | } 40 | 41 | private Integer getIndexOfScheme(String scheme) 42 | { 43 | String[] schemes = IndentationRule.ALL_SCHEMES; 44 | for (int i=0; i 0) { 38 | buffer.append(";; @author \"").append(author).append("\"").append(lineDelimiter); 39 | } 40 | if (copyright != null && copyright.length() > 0) { 41 | buffer.append(";; @copyright \"").append(copyright).append("\"").append(lineDelimiter); 42 | } 43 | buffer.append(";;").append(lineDelimiter).append(lineDelimiter); 44 | 45 | return buffer.toString(); 46 | } 47 | 48 | public static String createSectionComment(String lineDelimiter) { 49 | return createSectionComment(lineDelimiter, ""); 50 | } 51 | 52 | public static String createSectionComment(String lineDelimiter, String header) { 53 | StringBuffer buffer = new StringBuffer(); 54 | buffer.append(";;;") 55 | .append(lineDelimiter) 56 | .append(";;;; ") 57 | .append(header) 58 | .append(lineDelimiter) 59 | .append(";;;") 60 | .append(lineDelimiter) 61 | .append(lineDelimiter); 62 | 63 | return buffer.toString(); 64 | } 65 | 66 | public static String createChapterComment(String lineDelimiter) { 67 | return createChapterComment(lineDelimiter, ""); 68 | } 69 | 70 | public static String createChapterComment(String lineDelimiter, String header) { 71 | StringBuffer buffer = new StringBuffer(); 72 | buffer.append(";;;") 73 | .append(lineDelimiter) 74 | .append(";;;; --") 75 | .append(lineDelimiter) 76 | .append(";;;; ") 77 | .append(header) 78 | .append(lineDelimiter) 79 | .append(";;;") 80 | .append(lineDelimiter) 81 | .append(lineDelimiter); 82 | 83 | return buffer.toString(); 84 | } 85 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/views/KawaScratchpadView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004 Nu Echo Inc. 3 | * 4 | * This is free software. For terms and warranty disclaimer, see ./COPYING 5 | */ 6 | package org.schemeway.plugins.schemescript.views; 7 | 8 | import org.eclipse.jface.action.*; 9 | import org.eclipse.jface.resource.*; 10 | import org.eclipse.swt.*; 11 | import org.eclipse.swt.custom.*; 12 | import org.eclipse.swt.widgets.*; 13 | import org.eclipse.ui.*; 14 | import org.eclipse.ui.part.*; 15 | import org.schemeway.plugins.schemescript.*; 16 | 17 | public class KawaScratchpadView extends ViewPart { 18 | private static final String VIEW_ID = SchemeScriptPlugin.PLUGIN_NS + ".kawa.scratchpadView"; 19 | private CTabFolder mFolder; 20 | 21 | private static ImageDescriptor mRemoveImageDescriptor = SchemeScriptImageRegistry 22 | .getImageDescriptor("icons/remove.gif"); 23 | private static ImageDescriptor mRemoveAllImageDescriptor = SchemeScriptImageRegistry 24 | .getImageDescriptor("icons/removeAll.gif"); 25 | 26 | private class RemoveAllAction extends Action { 27 | public RemoveAllAction() { 28 | super(null, IAction.AS_PUSH_BUTTON); 29 | setToolTipText("Remove all"); 30 | setImageDescriptor(mRemoveAllImageDescriptor); 31 | } 32 | 33 | public void run() { 34 | CTabItem[] items = mFolder.getItems(); 35 | for (int index = 0; index < items.length; index++) { 36 | items[index].dispose(); 37 | } 38 | } 39 | } 40 | 41 | private class RemoveAction extends Action { 42 | public RemoveAction() { 43 | super(null, IAction.AS_PUSH_BUTTON); 44 | setToolTipText("Remove"); 45 | setImageDescriptor(mRemoveImageDescriptor); 46 | } 47 | 48 | public void run() { 49 | int index = mFolder.getSelectionIndex(); 50 | if (index >= 0) { 51 | CTabItem item = mFolder.getItem(index); 52 | item.dispose(); 53 | } 54 | } 55 | } 56 | 57 | public KawaScratchpadView() { 58 | super(); 59 | } 60 | 61 | public void createPartControl(Composite parent) { 62 | mFolder = new CTabFolder(parent, SWT.BOTTOM); 63 | 64 | IToolBarManager manager = this.getViewSite().getActionBars().getToolBarManager(); 65 | manager.add(new RemoveAction()); 66 | manager.add(new RemoveAllAction()); 67 | } 68 | 69 | public void setFocus() { 70 | mFolder.setFocus(); 71 | } 72 | 73 | private void addNewView(String name, Control control) { 74 | CTabItem item = new CTabItem(mFolder, SWT.BORDER); 75 | item.setControl(control); 76 | item.setText(name); 77 | } 78 | 79 | public static Composite getControl() { 80 | try { 81 | KawaScratchpadView view = (KawaScratchpadView) (PlatformUI.getWorkbench() 82 | .getActiveWorkbenchWindow().getActivePage().showView(VIEW_ID)); 83 | return view.mFolder; 84 | } 85 | catch (PartInitException e) { 86 | } 87 | return null; 88 | } 89 | 90 | public static void addView(String name, Control control) { 91 | try { 92 | KawaScratchpadView view = (KawaScratchpadView) (PlatformUI.getWorkbench() 93 | .getActiveWorkbenchWindow().getActivePage().showView(VIEW_ID)); 94 | view.addNewView(name, control); 95 | } 96 | catch (PartInitException e) { 97 | SchemeScriptPlugin.logException("Unable to add control", e); 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/wizards/NewSchemeFileWizard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2003 Nu Echo Inc. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.wizards; 5 | 6 | import org.eclipse.core.resources.*; 7 | import org.eclipse.core.runtime.*; 8 | import org.eclipse.jface.viewers.*; 9 | import org.eclipse.jface.wizard.*; 10 | import org.eclipse.ui.*; 11 | import org.eclipse.ui.part.*; 12 | import org.schemeway.plugins.schemescript.*; 13 | 14 | /** 15 | * @author Nu Echo Inc. 16 | */ 17 | public class NewSchemeFileWizard extends Wizard implements INewWizard 18 | { 19 | IWorkbench mWorkbench; 20 | IStructuredSelection mSelection; 21 | NewSchemeFileWizardPage mMainPage; 22 | 23 | public void init(IWorkbench workbench, IStructuredSelection selection) 24 | { 25 | this.mWorkbench = workbench; 26 | this.mSelection = selection; 27 | setWindowTitle("Scheme File"); 28 | } 29 | 30 | public void addPages() 31 | { 32 | mMainPage = new NewSchemeFileWizardPage("Kawa Scheme File", mSelection); 33 | addPage(mMainPage); 34 | } 35 | 36 | // public boolean canFinish() 37 | // { 38 | // return super.canFinish() && mSelection.size() == 1 && ((mSelection.getFirstElement() instanceof IFolder) 39 | // || (mSelection.getFirstElement() instanceof IProject)); 40 | // } 41 | 42 | public boolean performFinish() 43 | { 44 | try 45 | { 46 | String filename = mMainPage.getFileName(); 47 | if (!filename.endsWith(".scm")) 48 | { 49 | mMainPage.setFileName(filename + ".scm"); 50 | } 51 | IFile file = mMainPage.createNewFile(); 52 | FileEditorInput input = new FileEditorInput(file); 53 | mWorkbench.getActiveWorkbenchWindow().getActivePage().openEditor(input, SchemeScriptPlugin.PLUGIN_NS + ".editor.SchemeEditor"); 54 | } 55 | catch(CoreException exception) 56 | { 57 | } 58 | return true; 59 | } 60 | 61 | // public IFile getFile(String name) throws CoreException 62 | // { 63 | // Object selectedItem = mSelection.getFirstElement(); 64 | // if (selectedItem instanceof IProject) 65 | // return ((IProject)selectedItem).getFile(name); 66 | // else 67 | // return ((IFolder) selectedItem).getFile(name); 68 | // } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /plugin/src/org/schemeway/plugins/schemescript/wizards/NewSchemeFileWizardPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002-2003 Nu Echo Inc. All rights reserved. 3 | */ 4 | package org.schemeway.plugins.schemescript.wizards; 5 | 6 | import java.io.*; 7 | 8 | import org.eclipse.jface.viewers.*; 9 | import org.eclipse.swt.*; 10 | import org.eclipse.swt.layout.*; 11 | import org.eclipse.swt.widgets.*; 12 | import org.eclipse.ui.dialogs.*; 13 | import org.schemeway.plugins.schemescript.tools.*; 14 | 15 | /** 16 | * @author Nu Echo Inc. 17 | */ 18 | public class NewSchemeFileWizardPage extends WizardNewFileCreationPage 19 | { 20 | Text mModuleName; 21 | Text mDescription; 22 | 23 | public NewSchemeFileWizardPage(String title, IStructuredSelection selection) 24 | { 25 | super(title, selection); 26 | setDescription("Create a new Kawa Scheme file"); 27 | setTitle("Create Kawa Scheme File"); 28 | } 29 | 30 | public void createControl(Composite parent) 31 | { 32 | super.createControl(parent); 33 | Composite composite = (Composite) getControl(); 34 | 35 | Group group = new Group(composite, SWT.NONE); 36 | group.setText("File information"); 37 | GridLayout layout = new GridLayout(); 38 | layout.numColumns = 2; 39 | GridData data = new GridData(GridData.FILL_BOTH); 40 | group.setLayout(layout); 41 | group.setLayoutData(data); 42 | 43 | Label label = new Label(group, SWT.NONE); 44 | label.setText("Module Description: "); 45 | label.setEnabled(true); 46 | 47 | mDescription = new Text(group, SWT.SINGLE | SWT.BORDER); 48 | mDescription.setText(""); 49 | mDescription.setEnabled(true); 50 | 51 | data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); 52 | mDescription.setLayoutData(data); 53 | 54 | label = new Label(group, SWT.NONE); 55 | label.setText("Module fully-qualified name: "); 56 | label.setEnabled(true); 57 | 58 | mModuleName = new Text(group, SWT.SINGLE | SWT.BORDER); 59 | mModuleName.setText(""); 60 | mModuleName.setEnabled(true); 61 | 62 | data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); 63 | mModuleName.setLayoutData(data); 64 | 65 | setControl(composite); 66 | } 67 | 68 | public InputStream getInitialContents() 69 | { 70 | StringBuffer buffer = new StringBuffer(); 71 | buffer.append(Comments.createHeaderComment("\n", mDescription.getText())); 72 | buffer.append(Comments.createSectionComment("\n", "Module declaration")); 73 | buffer.append("(module-name <").append(mModuleName.getText()).append(">)\n\n\n"); 74 | buffer.append(Comments.createChapterComment("\n", "Public interface")); 75 | buffer.append(Comments.createChapterComment("\n", "Private interface")); 76 | return new ByteArrayInputStream(buffer.toString().getBytes()); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /plugin/src/resources.properties: -------------------------------------------------------------------------------- 1 | ## Resources 2 | ContentAssistProposal.label=Complete symbol 3 | ContentAssistTip.label=Describe symbol 4 | -------------------------------------------------------------------------------- /plugin/tests/indentation-tests.scm: -------------------------------------------------------------------------------- 1 | (define x 2 | ;; 3 | `(foo (foo x) 4 | print 5 | ,x 6 | ,x)) 7 | 8 | ;; 9 | ;; asdfasdf 10 | 11 | 12 | (define (foo x . args) ; asdfasdf 13 | ;; sadfa 14 | 'machin) 15 | 16 | 17 | (foo a 18 | b 19 | c) 20 | 21 | (a b 22 | c 23 | d) 24 | 25 | 26 | `(a b c d e 27 | f g h i j) 28 | 29 | 30 | ("abc" "def" 31 | "ghi" "jkl" 32 | "mno" "pqr" "stu" 33 | "vw") 34 | 35 | ((foo) 36 | x y 37 | z) 38 | 39 | 40 | `(,@(a) 41 | ,@(a)) 42 | 43 | (begin 44 | code code ; comment 45 | ; comment 46 | code) 47 | 48 | (define print display) 49 | 50 | (not-a-procedure ; a 51 | ; b = right 52 | (print a1 53 | ; c = wrong 54 | a2 ; d 55 | ; e 56 | ) 57 | (print 58 | a1 59 | ; f = wrong 60 | ; g = wrong 61 | ) 62 | '(not-a-procedure abc 63 | ; h = wrong 64 | def ; i = right 65 | ; j = right 66 | ) 67 | ) 68 | 69 | -------------------------------------------------------------------------------- /plugin/toc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /update-site/.gitignore: -------------------------------------------------------------------------------- 1 | *.jar 2 | artifacts.xml 3 | content.xml 4 | -------------------------------------------------------------------------------- /update-site/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | SchemeScript-Update-Site 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.pde.UpdateSiteBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.pde.UpdateSiteNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /update-site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | --------------------------------------------------------------------------------