(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 |
--------------------------------------------------------------------------------