--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>CobolEditor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: CobolEd Plug-in
+Bundle-SymbolicName: CobolEd; singleton:=true
+Bundle-Version: 0.0.1
+Bundle-Activator: coboled.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text,
+ org.eclipse.ui.editors
+Eclipse-LazyStart: true
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension point="org.eclipse.ui.editors">
+ <editor
+ name="Cobolエディター"
+ extensions="cob,pco"
+ icon="icons/sample.gif"
+ contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
+ class="coboled.editors.CobolEditor"
+ id="coboled.editors.CobolEditor">
+ </editor>
+ </extension>
+
+ <extension point="org.eclipse.ui.commands">
+ <category
+ name="CobolEditor"
+ id="coboled.editors.category">
+ </category>
+ <command
+ name="Cobolアウトライン"
+ categoryId="coboled.editors.category"
+ id="coboled.editors.command">
+ </command>
+ </extension>
+
+ <extension point="org.eclipse.ui.bindings">
+ <key sequence="M1+O"
+ contextId="coboled.editors.cobolEditorScope"
+ commandId="coboled.editors.command"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+ </key>
+ </extension>
+
+ <extension point="org.eclipse.ui.contexts">
+ <context
+ name="CobolEditor"
+ parentId="org.eclipse.ui.textEditorScope"
+ description="Cobol editor scope"
+ id="coboled.editors.cobolEditorScope">
+ </context>
+ </extension>
+
+ <extension point="org.eclipse.ui.handlers">
+ <handler
+ commandId="coboled.editors.command"
+ class="coboled.editors.command.QuickOutLineHandler">
+ </handler>
+ </extension>
+
+</plugin>
--- /dev/null
+package coboled;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "CobolEd";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
--- /dev/null
+package coboled.editors;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+
+public class CobolConfiguration extends SourceViewerConfiguration {
+ private XMLDoubleClickStrategy doubleClickStrategy;
+ private CobolScanner scanner;
+ private ColorManager colorManager;
+
+ public CobolConfiguration(ColorManager colorManager) {
+ this.colorManager = colorManager;
+ }
+
+ public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+ return new String[] {
+ IDocument.DEFAULT_CONTENT_TYPE,
+ CobolPartitionScanner.COBOL_COMMENT};
+ }
+
+ public ITextDoubleClickStrategy getDoubleClickStrategy(
+ ISourceViewer sourceViewer,
+ String contentType) {
+ if (doubleClickStrategy == null)
+ doubleClickStrategy = new XMLDoubleClickStrategy();
+ return doubleClickStrategy;
+ }
+
+ protected CobolScanner getCobolScanner() {
+ if (scanner == null) {
+ scanner = new CobolScanner(colorManager);
+ scanner.setDefaultReturnToken(
+ new Token(
+ new TextAttribute(
+ colorManager.getColor(ICobolColorConstants.DEFAULT))));
+ }
+ return scanner;
+ }
+
+ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
+ PresentationReconciler reconciler = new PresentationReconciler();
+
+ DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getCobolScanner());
+ reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+ NonRuleBasedDamagerRepairer ndr =
+ new NonRuleBasedDamagerRepairer(
+ new TextAttribute(
+ colorManager.getColor(ICobolColorConstants.COMMENT)));
+ reconciler.setDamager(ndr, CobolPartitionScanner.COBOL_COMMENT);
+ reconciler.setRepairer(ndr, CobolPartitionScanner.COBOL_COMMENT);
+
+ return reconciler;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package coboled.editors;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.ui.editors.text.FileDocumentProvider;
+
+public class CobolDocumentProvider extends FileDocumentProvider {
+
+ protected IDocument createDocument(Object element) throws CoreException {
+ IDocument document = super.createDocument(element);
+ if (document != null) {
+ IDocumentPartitioner partitioner =
+ new FastPartitioner(
+ new CobolPartitionScanner(),
+ new String[] {
+ CobolPartitionScanner.COBOL_COMMENT });
+ partitioner.connect(document);
+ document.setDocumentPartitioner(partitioner);
+ }
+ return document;
+ }
+}
\ No newline at end of file
--- /dev/null
+package coboled.editors;
+
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
+
+public class CobolEditor extends TextEditor {
+
+ private ColorManager colorManager;
+
+ public CobolEditor() {
+ super();
+ colorManager = new ColorManager();
+ setSourceViewerConfiguration(new CobolConfiguration(colorManager));
+ setDocumentProvider(new CobolDocumentProvider());
+ }
+ public void dispose() {
+ colorManager.dispose();
+ super.dispose();
+ }
+
+ @Override
+ protected SourceViewerDecorationSupport getSourceViewerDecorationSupport(
+ ISourceViewer viewer) {
+ if (fSourceViewerDecorationSupport == null) {
+ fSourceViewerDecorationSupport =
+ new CobolViewerDecorationSupport(viewer, getOverviewRuler(),
+ getAnnotationAccess(), getSharedColors());
+ configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport);
+ }
+ return fSourceViewerDecorationSupport;
+ }
+
+ @Override
+ protected void initializeKeyBindingScopes() {
+ super.initializeKeyBindingScopes();
+ setKeyBindingScopes(new String[]{"coboled.editors.cobolEditorScope"});
+ }
+}
--- /dev/null
+package coboled.editors;
+
+import org.eclipse.jface.text.rules.*;
+
+public class CobolPartitionScanner extends RuleBasedPartitionScanner {
+ public final static String COBOL_COMMENT = "__cobol_comment";
+ public final static String XML_TAG = "__xml_tag";
+
+ private static final int MARK_AREA = 6;
+
+ public CobolPartitionScanner() {
+
+ IToken cobolComment = new Token(COBOL_COMMENT);
+
+ IPredicateRule[] rules = new IPredicateRule[3];
+
+ SingleLineRule asterisk = new EndOfLineRule("*", cobolComment);
+ asterisk.setColumnConstraint(MARK_AREA);
+ rules[0] = asterisk;
+
+ SingleLineRule slash = new EndOfLineRule("/", cobolComment);
+ slash.setColumnConstraint(MARK_AREA);
+ rules[1] = slash;
+
+ SingleLineRule debug = new EndOfLineRule("D", cobolComment);
+ debug.setColumnConstraint(MARK_AREA);
+ rules[2] = debug;
+
+ setPredicateRules(rules);
+ }
+}
--- /dev/null
+package coboled.editors;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.SingleLineRule;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WhitespaceRule;
+import org.eclipse.jface.text.rules.WordRule;
+import org.eclipse.swt.SWT;
+
+public class CobolScanner extends RuleBasedScanner {
+
+ public CobolScanner(ColorManager manager) {
+ List<IRule> rules = new ArrayList<IRule>();
+ addQuotesRule(rules, manager);
+ addWordRule(rules, manager);
+ addWhitespaceRule(rules, manager);
+ setRules(rules.toArray(new IRule[rules.size()]));
+ }
+
+ private void addQuotesRule(List<IRule> rules, ColorManager manager) {
+ IToken string =
+ new Token(
+ new TextAttribute(manager.getColor(ICobolColorConstants.STRING)));
+ // Add rule for double quotes
+ rules.add(new SingleLineRule("\"", "\"", string, '\\'));
+ // Add a rule for single quotes
+ rules.add(new SingleLineRule("'", "'", string, '\\'));
+ }
+
+ private void addWordRule(List<IRule> rules, ColorManager manager) {
+ IToken keyword =
+ new Token(
+ new TextAttribute(manager.getColor(ICobolColorConstants.KEYWORD), null, SWT.BOLD));
+ IToken other =
+ new Token(
+ new TextAttribute(manager.getColor(ICobolColorConstants.DEFAULT)));
+
+ WordRule wordRule = new WordRule(new CobolWordDetector(), other, false);
+ for(int i = 0; i < ICobolKeyWordConstants.KEYWORDS.length; i++) {
+ wordRule.addWord(ICobolKeyWordConstants.KEYWORDS[i], keyword);
+ }
+ rules.add(wordRule);
+ }
+
+ private void addWhitespaceRule(List<IRule> rules, ColorManager manager) {
+ rules.add(new WhitespaceRule(new CobolWhitespaceDetector()));
+ }
+}
--- /dev/null
+package coboled.editors;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.ITextViewerExtension2;
+import org.eclipse.jface.text.MarginPainter;
+import org.eclipse.jface.text.source.IAnnotationAccess;
+import org.eclipse.jface.text.source.IOverviewRuler;
+import org.eclipse.jface.text.source.ISharedTextColors;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
+
+public class CobolViewerDecorationSupport extends SourceViewerDecorationSupport {
+
+ private ISourceViewer sourceViewer = null;
+
+ private ISharedTextColors fSharedTextColors = null;
+
+ private List<MarginPainter> fMarginPainters = new ArrayList<MarginPainter>();
+
+ private List<Integer> rulerColumns = Arrays.asList(6, 7, 12, 72, 80);
+
+ public CobolViewerDecorationSupport(ISourceViewer sourceViewer,
+ IOverviewRuler overviewRuler, IAnnotationAccess annotationAccess,
+ ISharedTextColors sharedTextColors) {
+ super(sourceViewer, overviewRuler, annotationAccess, sharedTextColors);
+ this.sourceViewer = sourceViewer;
+ this.fSharedTextColors = sharedTextColors;
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ fSharedTextColors = null;
+ clearMargins();
+ }
+
+ @Override
+ public void install(IPreferenceStore store) {
+ super.install(store);
+ showMargins();
+ }
+
+ private void showMargins() {
+ if (fMarginPainters != null && fMarginPainters.size() != 0) {
+ return;
+ }
+ if (sourceViewer instanceof ITextViewerExtension2) {
+ Iterator<Integer> iter = rulerColumns.iterator();
+ while (iter.hasNext()) {
+ MarginPainter marginPainter = new MarginPainter(sourceViewer);
+ marginPainter = new MarginPainter(sourceViewer);
+ marginPainter.setMarginRulerColor(fSharedTextColors.getColor(ICobolColorConstants.MARGIN));
+ marginPainter.setMarginRulerColumn(iter.next());
+ ITextViewerExtension2 extension= (ITextViewerExtension2) sourceViewer;
+ extension.addPainter(marginPainter);
+ fMarginPainters.add(marginPainter);
+ }
+ }
+ }
+
+ private void clearMargins() {
+ if (fMarginPainters != null && fMarginPainters.size() != 0) {
+ fMarginPainters.clear();
+ fMarginPainters = new ArrayList<MarginPainter>();
+ }
+ }
+}
--- /dev/null
+package coboled.editors;
+
+import org.eclipse.jface.text.rules.IWhitespaceDetector;
+
+public class CobolWhitespaceDetector implements IWhitespaceDetector {
+
+ public boolean isWhitespace(char c) {
+ return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
+ }
+}
--- /dev/null
+package coboled.editors;
+
+import org.eclipse.jface.text.rules.IWordDetector;
+
+public class CobolWordDetector implements IWordDetector {
+
+ public boolean isWordPart(char c) {
+ return Character.isJavaIdentifierPart(c);
+ }
+
+ public boolean isWordStart(char c) {
+ return Character.isJavaIdentifierStart(c);
+ }
+
+}
--- /dev/null
+package coboled.editors;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+public class ColorManager {
+
+ protected Map<RGB,Color> fColorTable = new HashMap<RGB,Color>(10);
+
+ public void dispose() {
+ Iterator<Color> e = fColorTable.values().iterator();
+ while (e.hasNext())
+ (e.next()).dispose();
+ }
+ public Color getColor(RGB rgb) {
+ Color color = fColorTable.get(rgb);
+ if (color == null) {
+ color = new Color(Display.getCurrent(), rgb);
+ fColorTable.put(rgb, color);
+ }
+ return color;
+ }
+}
--- /dev/null
+package coboled.editors;
+
+import org.eclipse.swt.graphics.RGB;
+
+public interface ICobolColorConstants {
+ RGB COMMENT = new RGB(63, 127, 95);
+ RGB KEYWORD = new RGB(127, 0, 85);
+ RGB STRING = new RGB(42, 0, 255);
+ RGB DEFAULT = new RGB(0, 0, 0);
+ RGB MARGIN = new RGB(176, 180, 185);
+}
--- /dev/null
+package coboled.editors;
+
+public interface ICobolKeyWordConstants {
+
+ public static final String[] KEYWORDS = {
+ // A
+ "ABSENT ",
+ "ABSTRACT",
+ "ACCEPT",
+ "ACCESS",
+ "ACQUIRE",
+ "ACTIVE-CLASS",
+ "ACTUAL",
+ "ADD",
+ "ADDRESS",
+ "ADVANCING",
+ "AFP-5A",
+ "AFTER",
+ "ALIGNED",
+ "ALL",
+ "ALLOCATE",
+ "ALLOW",
+ "ALPHABET",
+ "ALPHABETIC",
+ "ALPHABETIC-LOWER",
+ "ALPHABETIC-UPPER",
+ "ALPHANUMERIC",
+ "ALPHANUMERIC-EDITED",
+ "ALSO",
+ "ALTER",
+ "ALTERNATE",
+ "AND",
+ "ANY",
+ "APPLY",
+ "ARE",
+ "AREA",
+ "AREAS",
+ "AS",
+ "ASCENDING",
+ "ASSIGN",
+ "AT",
+ "AUTHOR",
+ "AUTO-HYPHEN-SKIP",
+ "AUTO-SKIP",
+ "AUTOMATIC",
+
+ // B
+ "B-AND",
+ "B-EXOR",
+ "B-LEFT",
+ "B-NOT",
+ "B-OR",
+ "B-RIGHT",
+ "B-XOR",
+ "BACKWARD",
+ "BASED",
+ "BASIS",
+ "BEEP",
+ "BEFORE",
+ "BEGINNING",
+ "BINARY",
+ "BINARY-CHAR",
+ "BINARY-DOUBLE",
+ "BINARY-LONG",
+ "BINARY-SHORT",
+ "BIT",
+ "BLANK",
+ "BLOCK",
+ "BOOLEAN",
+ "BOTTOM",
+ "BROWSING",
+ "BY",
+
+ // C
+ "C01",
+ "C02",
+ "C03",
+ "C04",
+ "C05",
+ "C06",
+ "C07",
+ "C08",
+ "C09",
+ "C10",
+ "C11",
+ "C12",
+ "CALL",
+ "CALLED",
+ "CANCEL",
+ "CBL",
+ "CBL-CTR",
+ "CD",
+ "CF",
+ "CH",
+ "CHAIN",
+ "CHAINING",
+ "CHANGED",
+ "CHARACTER",
+ "CHARACTERS",
+ "CHECKING",
+ "CLASS",
+ "CLASS-CONTROL",
+ "CLASS-ID",
+ "CLASS-OBJECT",
+ "CLOCK-UNITS",
+ "CLOSE",
+ "COBOL",
+ "CODE",
+ "CODE-SET",
+ "COERCION",
+ "COL",
+ "COLLATING",
+ "COLS",
+ "COLUMN",
+ "COLUMNS",
+ "COM-REG",
+ "COMMA",
+ "COMMIT",
+ "COMMITMENT",
+ "COMMON",
+ "COMMUNICATION74",
+ "COMP",
+ "COMP-0",
+ "COMP-1",
+ "COMP-2",
+ "COMP-3",
+ "COMP-4",
+ "COMP-5",
+ "COMP-6",
+ "COMP-X",
+ "COMPUTATIONAL",
+ "COMPUTATIONAL-0",
+ "COMPUTATIONAL-1",
+ "COMPUTATIONAL-2",
+ "COMPUTATIONAL-3",
+ "COMPUTATIONAL-4",
+ "COMPUTATIONAL-5",
+ "COMPUTATIONAL-6",
+ "COMPUTATIONAL-X",
+ "COMPUTE",
+ "CONFIGURATION",
+ "CONSOLE",
+ "CONSTANT",
+ "CONTAINS",
+ "CONTENT",
+ "CONTINUE",
+ "CONTROL",
+ "CONTROL-AREA",
+ "CONTROLS",
+ "CONVERT",
+ "CONVERTING",
+ "COPY",
+ "CORE-INDEX",
+ "CORR",
+ "CORRESPONDING74",
+ "COUNT",
+ "CREATING",
+ "CRT",
+ "CRT-UNDER",
+ "CSP",
+ "CURRENCY",
+ "CURRENT-DATE",
+ "CURSOR",
+ "CYL-INDEX",
+ "CYL-OVERFLOW",
+
+ // D
+ "DATA",
+ "DATABASE-KEY",
+ "DATABASE-KEY-LONG",
+ "DATE",
+ "DATE-COMPILED",
+ "DATE-WRITTEN",
+ "DAY",
+ "DAY-OF-WEEK",
+ "DBCS",
+ "DE",
+ "DEBUG",
+ "DEBUG-CONTENTS74",
+ "DEBUG-ITEM",
+ "DEBUG-LINE",
+ "DEBUG-NAME",
+ "DEBUG-SUB-1",
+ "DEBUG-SUB-2",
+ "DEBUG-SUB-3",
+ "DEBUGGING",
+ "DECIMAL-POINT",
+ "DECLARATIVES",
+ "DEFAULT",
+ "DEFINITION",
+ "DELETE",
+ "DELIMITED",
+ "DELIMITER",
+ "DEPENDING",
+ "DESCENDING",
+ "DESTINATION",
+ "DETAIL",
+ "DISABLE",
+ "DISC",
+ "DISK",
+ "DISP",
+ "DISPLAY",
+ "DISPLAY-1",
+ "DISPLAY-ST",
+ "DIVIDE",
+ "DIVISION",
+ "DOWN",
+ "DROP",
+ "DUPLICATES",
+ "DYNAMIC",
+
+ // E
+ "EBCDIC",
+ "ECHO",
+ "EGCS",
+ "EGI",
+ "EJECT",
+ "ELSE",
+ "EMI",
+ "EMPTY-CHECK",
+ "ENABLE",
+ "END",
+ "END-ACCEPT",
+ "END-ADD",
+ "END-CALL",
+ "END-CHAIN",
+ "END-COMPUTE",
+ "END-DELETE",
+ "END-DISPLAY",
+ "END-DIVIDE",
+ "END-EVALUATE",
+ "END-IF",
+ "END-INVOKE",
+ "END-MULTIPLY",
+ "END-OF-PAGE",
+ "END-PERFORM",
+ "END-READ",
+ "END-RECEIVE",
+ "END-RETURN",
+ "END-REWRITE",
+ "END-SEARCH",
+ "END-START",
+ "END-STRING",
+ "END-SUBTRACT",
+ "END-UNSTRING",
+ "END-WAIT",
+ "END-WRITE",
+ "ENDING",
+ "ENTER",
+ "ENTRY",
+ "ENVIRONMENT",
+ "EOP",
+ "EQUAL",
+ "EQUALS",
+ "ERROR",
+ "ESCAPE",
+ "ESI",
+ "EVALUATE",
+ "EVENT-POINTER",
+ "EVERY",
+ "EXAMINE",
+ "EXCEEDS",
+ "EXCEPTION",
+ "EXCEPTION-OBJECT",
+ "EXCESS-3",
+ "EXCLUSIVE",
+ "EXEC",
+ "EXECUTE",
+ "EXHIBIT",
+ "EXIT",
+ "EXTEND",
+ "EXTENDED",
+ "EXTENDED-SEARCH",
+ "EXTERNAL",
+ "EXTERNALLY-DESCRIBED-KEY",
+
+ // F
+ "FACTORY",
+ "FALSE",
+ "FD",
+ "FH--FCD",
+ "FH--KEYDEF",
+ "FILE",
+ "FILE-CONTROL",
+ "FILE-ID",
+ "FILE-LIMIT",
+ "FILE-LIMITS",
+ "FILLER",
+ "FINAL",
+ "FIRST",
+ "FIXED",
+ "FLOAT-",
+ "EXTENDED",
+ "FLOAT-LONG",
+ "FLOAT-SHORT",
+ "FOOTING",
+ "FOR",
+ "FORMAT",
+ "FREE",
+ "FROM",
+ "FUNCTION",
+ "FUNCTION-ID",
+
+ // G
+ "GENERATE",
+ "GIVING",
+ "GLOBAL",
+ "GO",
+ "GOBACK",
+ "GREATER",
+ "GRID",
+ "GROUP",
+
+ // H
+ "HEADING",
+ "HIGH-VALUE",
+ "HIGH-VALUES",
+
+ // I
+ "I-O",
+ "I-O-CONTROL",
+ "ID",
+ "IDENTIFICATION",
+ "IDENTIFIED",
+ "IF",
+ "IGNORE",
+ "IN",
+ "INDEX",
+ "INDEXED",
+ "INDIC",
+ "INDICATE",
+ "INDICATOR",
+ "INDICATORS",
+ "INHERITING",
+ "INHERITS",
+ "INITIAL",
+ "INITIALIZE",
+ "INITIATE",
+ "INPUT",
+ "INPUT-OUTPUT",
+ "INSERT",
+ "INSPECT",
+ "INSTALLATION",
+ "INSTANCE",
+ "INTERFACE",
+ "INTERFACE-ID",
+ "INTO",
+ "INVALID",
+ "INVOKE",
+ "INVOKED",
+ "IS",
+
+ // J
+ "JAPANESE",
+ "JUST",
+ "JUSTIFIED",
+
+ // K
+ "KANJI",
+ "KEPT",
+ "KEY",
+ "KEY-YY",
+ "KEYBOARD",
+
+ // L
+ "LABEL",
+ "LAST",
+ "LEADING",
+ "LEAVE",
+ "LEFT",
+ "LEFT-JUSTIFY",
+ "LEFTLINE",
+ "LENGTH",
+ "LENGTH-CHECK",
+ "LESS",
+ "LIMIT",
+ "LIMITS",
+ "LIN",
+ "LINAGE",
+ "LINAGE-COUNTER",
+ "LINE",
+ "LINE-COUNTER",
+ "LINES",
+ "LINKAGE",
+ "LOCAL-STORAGE",
+ "LOCALE",
+ "LOCK",
+ "LOCKING",
+ "LOW-VALUE",
+ "LOW-VALUES",
+ "LOWER",
+
+ // M
+ "MASTER-INDEX",
+ "MEMORY",
+ "MERGE",
+ "MESSAGE",
+ "METACLASS",
+ "METHOD",
+ "METHOD-ID",
+ "MODE",
+ "MODIFIED",
+ "MODULES",
+ "MONITOR-POINTER",
+ "MORE-LABELS",
+ "MOVE",
+ "MULTIPLE",
+ "MULTIPLY",
+ "MUTEX-POINTER",
+
+ // N
+ "NAME",
+ "NAMED",
+ "NATIONAL",
+ "NATIONAL-EDITED",
+ "NATIVE",
+ "NCHAR",
+ "NEGATIVE",
+ "NESTED",
+ "NEXT",
+ "NO",
+ "NO-ECHO",
+ "NOMINAL",
+ "NOT",
+ "NOTE",
+ "NSTD-REELS",
+ "NULL",
+ "NULLS",
+ "NUMBER",
+ "NUMBERS",
+ "NUMERIC",
+ "NUMERIC-EDITED",
+
+ // O
+ "O-FILL",
+ "OBJECT",
+ "OBJECT-COMPUTER",
+ "OBJECT-ID",
+ "OBJECT-STORAGE",
+ "OCCURS",
+ "OF",
+ "OFF",
+ "OMITTED",
+ "ON",
+ "OOSTACKPTR",
+ "OPEN",
+ "OPTIONAL",
+ "OPTIONS",
+ "OR",
+ "ORDER",
+ "ORGANIZATION",
+ "OTHER",
+ "OTHERWISE",
+ "OUTPUT",
+ "OVERFLOW",
+ "OVERLINE",
+ "OVERRIDE",
+
+ // P
+ "PACKED-DECIMAL",
+ "PADDING",
+ "PAGE",
+ "PAGE-COUNTER",
+ "PARSE",
+ "PASSWORD",
+ "PERFORM",
+ "PF",
+ "PH",
+ "PIC",
+ "PICTURE",
+ "PLUS",
+ "POINTER",
+ "POS",
+ "POSITION",
+ "POSITIONING",
+ "POSITIVE",
+ "PRESENT",
+ "PRINT",
+ "PRINT-SWITCH",
+ "PRINTER",
+ "PRINTER-1",
+ "PRINTING",
+ "PRIOR",
+ "PRIVATE",
+ "PROCEDURE",
+ "PROCEDURE-POINTER",
+ "PROCEDURES",
+ "PROCEED",
+ "PROCESS",
+ "PROCESSING",
+ "PROGRAM",
+ "PROGRAM-ID",
+ "PROGRAM-POINTER",
+ "PROMPT",
+ "PROPERTY",
+ "PROTECTED",
+ "PROTOTYPE",
+ "PUBLIC",
+ "PURGE",
+
+ // Q
+ "QUEUE",
+ "QUOTE",
+ "QUOTES",
+
+ // R
+ "RAISE",
+ "RAISING",
+ "RANDOM",
+ "RANGE",
+ "RD",
+ "READ",
+ "READING",
+ "READY",
+ "RECEIVE",
+ "RECORD",
+ "RECORD-OVERFLOW",
+ "RECORDING",
+ "RECORDS",
+ "RECURSIVE",
+ "REDEFINES",
+ "REDEFINITION",
+ "REEL",
+ "REFERENCE",
+ "REFERENCES",
+ "RELATIVE",
+ "RELEASE",
+ "RELOAD",
+ "REMAINDER",
+ "REMARKS",
+ "REMOVAL",
+ "RENAMES",
+ "REORG-CRITERIA",
+ "REPEATED",
+ "REPLACE",
+ "REPLACING",
+ "REPORT",
+ "REPORTING",
+ "REPORTS",
+ "REPOSITORY",
+ "REREAD",
+ "RERUN",
+ "RESERVE",
+ "RESET",
+ "RESTRICTED",
+ "RESUME",
+ "RETRY",
+ "RETURN",
+ "RETURN-CODE",
+ "RETURNING",
+ "REVERSED",
+ "REWIND",
+ "REWRITE",
+ "RF",
+ "RH",
+ "RIGHT",
+ "RIGHT-JUSTIFY",
+ "ROLLBACK",
+ "ROLLING",
+ "ROUNDED",
+ "RUN",
+
+ // S
+ "S01",
+ "S02",
+ "S03",
+ "S04",
+ "S05",
+ "SAME",
+ "SCREEN",
+ "SD",
+ "SEARCH",
+ "SECTION",
+ "SECURITY",
+ "SEEK",
+ "SEGMENT",
+ "SEGMENT-LIMIT",
+ "SELECT",
+ "SELECTIVE",
+ "SELF",
+ "SELFCLASS",
+ "SEMAPHORE-POINTER",
+ "SEND",
+ "SENTENCE",
+ "SEPARATE",
+ "SEQUENCE",
+ "SEQUENTIAL",
+ "SERVICE",
+ "SET",
+ "SHARING",
+ "SHIFT-IN",
+ "SHIFT-OUT",
+ "SIGN",
+ "SIZE",
+ "SKIP1",
+ "SKIP2",
+ "SKIP3",
+ "SORT",
+ "SORT-CONTROL",
+ "SORT-CORE-SIZE",
+ "SORT-FILE-SIZE",
+ "SORT-MERGE",
+ "SORT-MESSAGE",
+ "SORT-MODE-SIZE",
+ "SORT-OPTION",
+ "SORT-RETURN",
+ "SORT-TAPE",
+ "SORT-TAPES",
+ "SOURCE",
+ "SOURCE-COMPUTER",
+ "SOURCES",
+ "SPACE",
+ "SPACE-FILL",
+ "SPACES",
+ "SPECIAL-NAMES",
+ "STANDARD",
+ "STANDARD-1",
+ "STANDARD-2",
+ "STANDARD-3",
+ "START",
+ "STARTING",
+ "STATUS",
+ "STOP",
+ "STRING",
+ "SUB-QUEUE-1",
+ "SUB-QUEUE-2",
+ "SUB-QUEUE-3",
+ "SUBFILE",
+ "SUBTRACT",
+ "SUM",
+ "SUPER",
+ "SUPPRESS",
+ "SYMBOLIC",
+ "SYNC",
+ "SYNCHRONIZED",
+ "SYSIN",
+ "SYSIPT",
+ "SYSLST",
+ "SYSOUT",
+ "SYSPCH",
+ "SYSPUNCH",
+ "SYSTEM-DEFAULT",
+
+ // T
+ "TAB",
+ "TABLE",
+ "TALLY",
+ "TALLYING",
+ "TAPE",
+ "TAPES",
+ "TERMINAL",
+ "TERMINATE",
+ "TEST",
+ "TEXT",
+ "THAN",
+ "THEN",
+ "THREAD-LOCAL",
+ "THREAD-LOCAL-STORAGE",
+ "THREAD-POINTER",
+ "THROUGH",
+ "THRU",
+ "TIME",
+ "TIME-OF-DAY",
+ "TIME-OUT",
+ "TIMEOUT",
+ "TIMES",
+ "TITLE",
+ "TO",
+ "TOP",
+ "TOTALED",
+ "TOTALING",
+ "TRACE",
+ "TRACK-AREA",
+ "TRACK-LIMIT",
+ "TRACKS",
+ "TRAILING",
+ "TRAILING-SIGN",
+ "TRANSACTION",
+ "TRANSFORM",
+ "TRUE",
+ "TRY",
+ "TYPE",
+ "TYPEDEF",
+
+ // U
+ "UNEQUAL",
+ "UNIT",
+ "UNITS",
+ "UNIVERSAL",
+ "UNLOCK",
+ "UNSTRING",
+ "UNTIL",
+ "UP",
+ "UPDATE",
+ "UPON",
+ "UPPER",
+ "UPSI-0",
+ "UPSI-1",
+ "UPSI-2",
+ "UPSI-3",
+ "UPSI-4",
+ "UPSI-5",
+ "UPSI-6",
+ "UPSI-7",
+ "USAGE",
+ "USE",
+ "USER",
+ "USER-DEFAULT",
+ "USING",
+
+ // V
+ "VALID",
+ "VALIDATE",
+ "VALUE",
+ "VALUES",
+ "VARIABLE",
+ "VARYING",
+
+ // W
+ "WAIT",
+ "WHEN",
+ "WHEN-COMPILED",
+ "WITH",
+ "WORDS",
+ "WORKING-STORAGE",
+ "WRITE",
+ "WRITE-ONLY",
+ "WRITE-VERIFY",
+ "WRITING",
+
+ // X
+ "XML",
+ "XML-CODE",
+ "XML-EVENT",
+ "XML-NTEXT",
+ "XML-TEXT",
+
+ // Z
+ "ZERO",
+ "ZERO-FILL",
+ "ZEROES",
+ "ZEROS"
+ };
+
+}
--- /dev/null
+package coboled.editors;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.presentation.IPresentationDamager;
+import org.eclipse.jface.text.presentation.IPresentationRepairer;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.custom.StyleRange;
+
+public class NonRuleBasedDamagerRepairer
+ implements IPresentationDamager, IPresentationRepairer {
+
+ /** The document this object works on */
+ protected IDocument fDocument;
+ /** The default text attribute if non is returned as data by the current token */
+ protected TextAttribute fDefaultTextAttribute;
+
+ /**
+ * Constructor for NonRuleBasedDamagerRepairer.
+ */
+ public NonRuleBasedDamagerRepairer(TextAttribute defaultTextAttribute) {
+ Assert.isNotNull(defaultTextAttribute);
+
+ fDefaultTextAttribute = defaultTextAttribute;
+ }
+
+ /**
+ * @see IPresentationRepairer#setDocument(IDocument)
+ */
+ public void setDocument(IDocument document) {
+ fDocument = document;
+ }
+
+ /**
+ * Returns the end offset of the line that contains the specified offset or
+ * if the offset is inside a line delimiter, the end offset of the next line.
+ *
+ * @param offset the offset whose line end offset must be computed
+ * @return the line end offset for the given offset
+ * @exception BadLocationException if offset is invalid in the current document
+ */
+ protected int endOfLineOf(int offset) throws BadLocationException {
+
+ IRegion info = fDocument.getLineInformationOfOffset(offset);
+ if (offset <= info.getOffset() + info.getLength())
+ return info.getOffset() + info.getLength();
+
+ int line = fDocument.getLineOfOffset(offset);
+ try {
+ info = fDocument.getLineInformation(line + 1);
+ return info.getOffset() + info.getLength();
+ } catch (BadLocationException x) {
+ return fDocument.getLength();
+ }
+ }
+
+ /**
+ * @see IPresentationDamager#getDamageRegion(ITypedRegion, DocumentEvent, boolean)
+ */
+ public IRegion getDamageRegion(
+ ITypedRegion partition,
+ DocumentEvent event,
+ boolean documentPartitioningChanged) {
+ if (!documentPartitioningChanged) {
+ try {
+
+ IRegion info =
+ fDocument.getLineInformationOfOffset(event.getOffset());
+ int start = Math.max(partition.getOffset(), info.getOffset());
+
+ int end =
+ event.getOffset()
+ + (event.getText() == null
+ ? event.getLength()
+ : event.getText().length());
+
+ if (info.getOffset() <= end
+ && end <= info.getOffset() + info.getLength()) {
+ // optimize the case of the same line
+ end = info.getOffset() + info.getLength();
+ } else
+ end = endOfLineOf(end);
+
+ end =
+ Math.min(
+ partition.getOffset() + partition.getLength(),
+ end);
+ return new Region(start, end - start);
+
+ } catch (BadLocationException x) {
+ }
+ }
+
+ return partition;
+ }
+
+ /**
+ * @see IPresentationRepairer#createPresentation(TextPresentation, ITypedRegion)
+ */
+ public void createPresentation(
+ TextPresentation presentation,
+ ITypedRegion region) {
+ addRange(
+ presentation,
+ region.getOffset(),
+ region.getLength(),
+ fDefaultTextAttribute);
+ }
+
+ /**
+ * Adds style information to the given text presentation.
+ *
+ * @param presentation the text presentation to be extended
+ * @param offset the offset of the range to be styled
+ * @param length the length of the range to be styled
+ * @param attr the attribute describing the style of the range to be styled
+ */
+ protected void addRange(
+ TextPresentation presentation,
+ int offset,
+ int length,
+ TextAttribute attr) {
+ if (attr != null)
+ presentation.addStyleRange(
+ new StyleRange(
+ offset,
+ length,
+ attr.getForeground(),
+ attr.getBackground(),
+ attr.getStyle()));
+ }
+}
\ No newline at end of file
--- /dev/null
+package coboled.editors;
+
+import org.eclipse.jface.text.*;
+
+public class XMLDoubleClickStrategy implements ITextDoubleClickStrategy {
+ protected ITextViewer fText;
+
+ public void doubleClicked(ITextViewer part) {
+ int pos = part.getSelectedRange().x;
+
+ if (pos < 0)
+ return;
+
+ fText = part;
+
+ if (!selectComment(pos)) {
+ selectWord(pos);
+ }
+ }
+ protected boolean selectComment(int caretPos) {
+ IDocument doc = fText.getDocument();
+ int startPos, endPos;
+
+ try {
+ int pos = caretPos;
+ char c = ' ';
+
+ while (pos >= 0) {
+ c = doc.getChar(pos);
+ if (c == '\\') {
+ pos -= 2;
+ continue;
+ }
+ if (c == Character.LINE_SEPARATOR || c == '\"')
+ break;
+ --pos;
+ }
+
+ if (c != '\"')
+ return false;
+
+ startPos = pos;
+
+ pos = caretPos;
+ int length = doc.getLength();
+ c = ' ';
+
+ while (pos < length) {
+ c = doc.getChar(pos);
+ if (c == Character.LINE_SEPARATOR || c == '\"')
+ break;
+ ++pos;
+ }
+ if (c != '\"')
+ return false;
+
+ endPos = pos;
+
+ int offset = startPos + 1;
+ int len = endPos - offset;
+ fText.setSelectedRange(offset, len);
+ return true;
+ } catch (BadLocationException x) {
+ }
+
+ return false;
+ }
+ protected boolean selectWord(int caretPos) {
+
+ IDocument doc = fText.getDocument();
+ int startPos, endPos;
+
+ try {
+
+ int pos = caretPos;
+ char c;
+
+ while (pos >= 0) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ --pos;
+ }
+
+ startPos = pos;
+
+ pos = caretPos;
+ int length = doc.getLength();
+
+ while (pos < length) {
+ c = doc.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ ++pos;
+ }
+
+ endPos = pos;
+ selectRange(startPos, endPos);
+ return true;
+
+ } catch (BadLocationException x) {
+ }
+
+ return false;
+ }
+
+ private void selectRange(int startPos, int stopPos) {
+ int offset = startPos + 1;
+ int length = stopPos - offset;
+ fText.setSelectedRange(offset, length);
+ }
+}
\ No newline at end of file
--- /dev/null
+package coboled.editors.command;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class QuickOutLineHandler extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchWindow window = HandlerUtil
+ .getActiveWorkbenchWindowChecked(event);
+ MessageDialog.openInformation(window.getShell(),
+ "Newaction Plug-in",
+ "Hello, Eclipse world");
+ return null;
+ }
+}