summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjcheuoua2006-11-13 05:04:07 (EST)
committerjcheuoua2006-11-13 05:04:07 (EST)
commitf315bc92f37fa24cfe3cd1b0949c5371076a372d (patch)
tree8a1b64294d401eebdcf1a8bc4a94f8fd104161c3
parent8edc306ae17198c2d3bf5f54b3ec0cd0c79398b6 (diff)
downloadorg.eclipse.jet-f315bc92f37fa24cfe3cd1b0949c5371076a372d.zip
org.eclipse.jet-f315bc92f37fa24cfe3cd1b0949c5371076a372d.tar.gz
org.eclipse.jet-f315bc92f37fa24cfe3cd1b0949c5371076a372d.tar.bz2
Initial commit of JET2 template editor
-rw-r--r--plugins/org.eclipse.jet.editor/.classpath7
-rw-r--r--plugins/org.eclipse.jet.editor/.cvsignore1
-rw-r--r--plugins/org.eclipse.jet.editor/.jetproperties4
-rw-r--r--plugins/org.eclipse.jet.editor/.project34
-rw-r--r--plugins/org.eclipse.jet.editor/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--plugins/org.eclipse.jet.editor/.settings/org.eclipse.jet.prefs4
-rw-r--r--plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF26
-rw-r--r--plugins/org.eclipse.jet.editor/build.properties6
-rw-r--r--plugins/org.eclipse.jet.editor/icons/sample.gifbin0 -> 983 bytes
-rw-r--r--plugins/org.eclipse.jet.editor/plugin.xml24
-rw-r--r--plugins/org.eclipse.jet.editor/schema/partitionConfigurationDelegates.exsd105
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/Activator.java61
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETEditorHelper.java317
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETSourceViewer.java139
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETTextEditor.java254
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/DoubleClickStrategy.java112
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/IJETColorConstants.java17
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETDocumentProvider.java31
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETEditorPreferenceConstants.java109
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETSourceViewerConfiguration.java94
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETTokenStyleManager.java150
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETWhitespaceDetector.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/NonRuleBasedDamagerRepairer.java138
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/AbstractJETTextPartitionConfigurationDelegate.java38
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/IJETTextPartitionConfigurationDelegate.java24
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/JavaContentPartitionConfigurationDelegate.java249
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/AbstractJETAssistProcessor.java17
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETCustomTagAssistProcessor.java45
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETDirectiveAssistProcessor.java45
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaDeclarationAssistProcessor.java63
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaExpressionAssistProcessor.java101
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaScriptletAssistProcessor.java98
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETTagAssistProcessor.java47
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETCustomTagFormattingStrategy.java34
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETDirectiveFormattingStrategy.java34
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaDeclarationFormattingStrategy.java34
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaExpressionFormattingStrategy.java34
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaScriptletFormattingStrategy.java34
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/i18n/TextEditorMessages.properties1
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlineContentProvider.java180
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlineLabelProvider.java111
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlinePage.java57
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/partition/JETDocumentPartitionScanner.java509
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETBracketRule.java77
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETCommentRule.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETCustomTagRule.java78
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETDirectiveRule.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaDeclarationRule.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaExpressionRule.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaScriptletRule.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/WordListDetectorRule.java48
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETCommentScanner.java19
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETCustomTagScanner.java69
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETDefaultContentScanner.java12
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETDirectiveScanner.java61
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaCodeScanner.java241
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaDeclarationScanner.java34
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaExpressionScanner.java41
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaScriptletScanner.java35
59 files changed, 4175 insertions, 0 deletions
diff --git a/plugins/org.eclipse.jet.editor/.classpath b/plugins/org.eclipse.jet.editor/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/.classpath
@@ -0,0 +1,7 @@
+<?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>
diff --git a/plugins/org.eclipse.jet.editor/.cvsignore b/plugins/org.eclipse.jet.editor/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/plugins/org.eclipse.jet.editor/.jetproperties b/plugins/org.eclipse.jet.editor/.jetproperties
new file mode 100644
index 0000000..5585019
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/.jetproperties
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jet-settings>
+ <template-container>templates</template-container> <source-container>src</source-container>
+</jet-settings>
diff --git a/plugins/org.eclipse.jet.editor/.project b/plugins/org.eclipse.jet.editor/.project
new file mode 100644
index 0000000..9c4f7a4
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jet.editor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jet.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <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.jet.jet2Nature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.jet.editor/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.jet.editor/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..e9571be
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Fri Nov 03 16:29:20 PST 2006
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/plugins/org.eclipse.jet.editor/.settings/org.eclipse.jet.prefs b/plugins/org.eclipse.jet.editor/.settings/org.eclipse.jet.prefs
new file mode 100644
index 0000000..2767a7b
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/.settings/org.eclipse.jet.prefs
@@ -0,0 +1,4 @@
+#Sun Nov 12 18:00:04 PST 2006
+eclipse.preferences.version=1
+org.eclipse.jet.compiledTemplateSrcDir=src
+org.eclipse.jet.projectPrefs=true
diff --git a/plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..f434cc4
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JET Editor Plug-in
+Bundle-SymbolicName: org.eclipse.jet.editor; singleton:=true
+Bundle-Version: 0.0.1
+Bundle-Activator: org.eclipse.jet.editor.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.jface.text,
+ org.eclipse.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.ui.views,
+ org.eclipse.ui.views.properties.tabbed,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.ui,
+ org.eclipse.jet
+Eclipse-LazyStart: true
+Export-Package: org.eclipse.jet.editor,
+ org.eclipse.jet.editor.configuration,
+ org.eclipse.jet.editor.configuration.delegates,
+ org.eclipse.jet.editor.outline,
+ org.eclipse.jet.editor.partition,
+ org.eclipse.jet.editor.rules,
+ org.eclipse.jet.editor.scanners
diff --git a/plugins/org.eclipse.jet.editor/build.properties b/plugins/org.eclipse.jet.editor/build.properties
new file mode 100644
index 0000000..0d3d3a7
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/
diff --git a/plugins/org.eclipse.jet.editor/icons/sample.gif b/plugins/org.eclipse.jet.editor/icons/sample.gif
new file mode 100644
index 0000000..34fb3c9
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/icons/sample.gif
Binary files differ
diff --git a/plugins/org.eclipse.jet.editor/plugin.xml b/plugins/org.eclipse.jet.editor/plugin.xml
new file mode 100644
index 0000000..6f27b6b
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/plugin.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="partitionConfigurationDelegates" name="Partition Configuration Delegates" schema="schema/partitionConfigurationDelegates.exsd"/>
+
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ name="Java Emitter Templates Editor"
+ extensions="jet"
+ icon="icons/sample.gif"
+ contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
+ class="org.eclipse.jet.editor.JETTextEditor"
+ id="org.eclipse.jet.editor.editors.JETEditor">
+ </editor>
+ </extension>
+ <extension
+ point="org.eclipse.jet.editor.partitionConfigurationDelegates">
+ <partitionConfigurationDelegate
+ delegateClass="org.eclipse.jet.editor.configuration.delegates.JavaContentPartitionConfigurationDelegate">
+ </partitionConfigurationDelegate>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.jet.editor/schema/partitionConfigurationDelegates.exsd b/plugins/org.eclipse.jet.editor/schema/partitionConfigurationDelegates.exsd
new file mode 100644
index 0000000..e542633
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/schema/partitionConfigurationDelegates.exsd
@@ -0,0 +1,105 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.jet.editor">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.jet.editor" id="partitionConfigurationDelegates" name="Partition Configuration Delegates"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="partitionConfigurationDelegate" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="partitionConfigurationDelegate">
+ <complexType>
+ <attribute name="delegateClass" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.jet.editor.configuration.delegates.AbstractJETTextPartitionConfigurationDelegate"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/Activator.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/Activator.java
new file mode 100644
index 0000000..87de916
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/Activator.java
@@ -0,0 +1,61 @@
+package org.eclipse.jet.editor;
+
+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 = "org.eclipse.jet.editor";
+
+ // 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);
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETEditorHelper.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETEditorHelper.java
new file mode 100644
index 0000000..028941c
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETEditorHelper.java
@@ -0,0 +1,317 @@
+package org.eclipse.jet.editor;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.eval.IEvaluationContext;
+import org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal;
+import org.eclipse.jdt.ui.text.java.CompletionProposalCollector;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jet.BodyContentWriter;
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2TemplateLoader;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.compiler.Comment;
+import org.eclipse.jet.compiler.DefaultJET2ASTVisitor;
+import org.eclipse.jet.compiler.JET2ASTElement;
+import org.eclipse.jet.compiler.JET2CompilationUnit;
+import org.eclipse.jet.compiler.JET2Declaration;
+import org.eclipse.jet.compiler.JET2Directive;
+import org.eclipse.jet.compiler.JET2Expression;
+import org.eclipse.jet.compiler.JET2Scriptlet;
+import org.eclipse.jet.compiler.TextElement;
+import org.eclipse.jet.compiler.XMLBodyElement;
+import org.eclipse.jet.compiler.XMLBodyElementEnd;
+import org.eclipse.jet.compiler.XMLEmptyElement;
+import org.eclipse.jet.internal.compiler.MethodBodyCreator;
+import org.eclipse.jet.internal.compiler.templates.CodeGenTemplateLoader;
+import org.eclipse.jet.transform.TransformContextExtender;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+import org.eclipse.swt.graphics.Point;
+
+public class JETEditorHelper {
+
+ public static class JETEditorMethodBodyCreator extends MethodBodyCreator
+ {
+
+ private Map generatedBodyMappingPositions;
+
+ public JETEditorMethodBodyCreator(JET2TemplateLoader templateLoader, Map mappingPositions) {
+ super(templateLoader);
+ this.generatedBodyMappingPositions = mappingPositions;
+ }
+
+
+ /**
+ * @see org.eclipse.jet.compiler.DefaultJET2ASTVisitor#visit(org.eclipse.jet.compiler.XMLBodyElement)
+ */
+ public void visit(XMLBodyElement element)
+ {
+ Position position = new Position(getBuffer().length());
+ generatedBodyMappingPositions.put(element, position);
+ super.visit(element);
+ position.setLength(getBuffer().length() - position.offset);
+ }
+
+ /**
+ * @see org.eclipse.jet.compiler.DefaultJET2ASTVisitor#endVisit(org.eclipse.jet.compiler.XMLBodyElement)
+ */
+ public void endVisit(XMLBodyElement element)
+ {
+ Position position = new Position(getBuffer().length());
+ generatedBodyMappingPositions.put(element, position);
+ super.endVisit(element);
+ position.setLength(getBuffer().length() - position.offset);
+ }
+
+ /**
+ * @see org.eclipse.jet.compiler.DefaultJET2ASTVisitor#visit(org.eclipse.jet.compiler.XMLEmptyElement)
+ */
+ public void visit(XMLEmptyElement element)
+ {
+ Position position = new Position(getBuffer().length());
+ generatedBodyMappingPositions.put(element, position);
+ super.visit(element);
+ position.setLength(getBuffer().length() - position.offset);
+ }
+
+
+ /**
+ * @see org.eclipse.jet.compiler.DefaultJET2ASTVisitor#visit(org.eclipse.jet.compiler.JET2Expression)
+ */
+ public void visit(JET2Expression expression)
+ {
+ Position position = new Position(getBuffer().length());
+ generatedBodyMappingPositions.put(expression, position);
+ super.visit(expression);
+ position.setLength(getBuffer().length() - position.offset);
+ }
+
+ /**
+ * @see org.eclipse.jet.compiler.DefaultJET2ASTVisitor#visit(org.eclipse.jet.compiler.JET2Scriptlet)
+ */
+ public void visit(JET2Scriptlet scriptlet)
+ {
+ Position position = new Position(getBuffer().length());
+ generatedBodyMappingPositions.put(scriptlet, position);
+ super.visit(scriptlet);
+ position.setLength(getBuffer().length() - position.offset);
+ }
+
+ /**
+ * @see org.eclipse.jet.compiler.DefaultJET2ASTVisitor#visit(org.eclipse.jet.compiler.TextElement)
+ */
+ public void visit(TextElement text)
+ {
+ Position position = new Position(getBuffer().length());
+ generatedBodyMappingPositions.put(text, position);
+ super.visit(text);
+ position.setLength(getBuffer().length() - position.offset);
+ }
+
+ }
+ private static class RelevantElementFoundExcetion extends RuntimeException {
+ private static final long serialVersionUID = -7146049866718374643L;
+ }
+ private static class Detector extends DefaultJET2ASTVisitor {
+ JET2ASTElement match;
+ int documentOffset;
+
+ public Detector(int offset) {
+ documentOffset = offset;
+ }
+
+ public void visit(JET2Declaration declaration) {
+ matchOffset(declaration);
+ }
+
+ public void visit(JET2Directive directive) {
+ matchOffset(directive);
+ }
+
+ public void visit(JET2Expression expression) {
+ matchOffset(expression);
+ }
+
+ public void visit(JET2Scriptlet scriptlet) {
+ matchOffset(scriptlet);
+ }
+
+ public void visit(TextElement text) {
+ matchOffset(text);
+ }
+
+ public void visit(XMLEmptyElement xmlEmptyElement) {
+ matchOffset(xmlEmptyElement);
+ }
+
+ public void visit(XMLBodyElement xmlBodyElement) {
+ matchOffset(xmlBodyElement);
+ }
+
+ public void visit(XMLBodyElementEnd xmlBodyElementEnd) {
+ matchOffset(xmlBodyElementEnd);
+ }
+
+ public void visit(Comment comment) {
+ matchOffset(comment);
+ }
+
+ public void matchOffset(JET2ASTElement element) {
+ if (element.getStart() <= documentOffset && element.getEnd() > documentOffset) {
+ match = element;
+ throw new RelevantElementFoundExcetion();
+ }
+ }
+ }
+
+// public static String computeJavaSource(JET2CompilationUnit cu, Map mappedPositions) {
+// Map variables = new HashMap();
+// variables.put("org.eclipse.jet.storeJavaMappingPositions", mappedPositions);
+// variables.put("cu", cu);
+// JET2Context context = new JET2Context(null, variables); //$NON-NLS-1$
+// JET2TemplateLoader templateLoader = new CodeGenTemplateLoader();
+// TransformContextExtender.getInstance(context).setLoader(templateLoader);
+// JET2Template template = new JETEditorJET2JavaGenerator(); //$NON-NLS-1$
+// JET2Writer out = new BodyContentWriter();
+// template.generate(context, out);
+// return out.getDocument().get();
+// }
+
+ public static JET2ASTElement getASTElementAt(JET2CompilationUnit cu, int documentOffset) {
+ Detector detector = new Detector(documentOffset);
+ try {
+ cu.accept(detector);
+ } catch (RelevantElementFoundExcetion e) {
+ // element found
+ }
+ return detector.match;
+ }
+
+ private static JET2Declaration[] getAllJavaDeclarations(JET2CompilationUnit cu) {
+ final List result = new ArrayList();
+ cu.accept(new DefaultJET2ASTVisitor() {
+ public void visit(JET2Declaration declaration) {
+ result.add(declaration);
+ }
+ });
+ return (JET2Declaration[]) result.toArray(new JET2Declaration[result.size()]);
+ }
+
+ public static String getDeclarationsSourceCode(JET2CompilationUnit cu) {
+ JET2Declaration[] declarations = getAllJavaDeclarations(cu);
+ StringBuffer declarationsSource = new StringBuffer(declarations.length * 20);
+ for (int i = 0; i < declarations.length; i++) {
+ JET2Declaration declaration = declarations[i];
+ declarationsSource.append(declaration.getJavaContent());
+ }
+ return declarationsSource.toString();
+ }
+
+ public static String getPreviousGeneratedJavaSource(IJavaProject javaProject, JET2CompilationUnit cu,
+ JET2ASTElement bodyElement) {
+ JET2TemplateLoader templateLoader = new CodeGenTemplateLoader();
+ MethodBodyCreator generatedBody = new MethodBodyCreator(templateLoader);
+
+ List sortedPrevElements = new ArrayList();
+ JET2ASTElement prevASTElement = bodyElement.getPrevElement();
+ while (prevASTElement != null) {
+ sortedPrevElements.add(0, prevASTElement);
+ prevASTElement = prevASTElement.getPrevElement();
+ }
+ for (Iterator iterator = sortedPrevElements.iterator(); iterator.hasNext();) {
+ JET2ASTElement prevElement = (JET2ASTElement) iterator.next();
+ prevElement.accept(generatedBody);
+ }
+ return generatedBody.getBuffer();
+ }
+
+ public static CompletionProposalCollector collect(IJavaProject javaProject, JET2CompilationUnit cu,
+ String codeSnippet, int offset) {
+ IEvaluationContext context = javaProject.newEvaluationContext();
+ List importList = new ArrayList();
+ importList.addAll(cu.getImports());
+ importList.add("org.eclipse.jet.JET2Context");
+ importList.add("org.eclipse.jet.JET2Template");
+ importList.add("org.eclipse.jet.JET2Writer");
+ importList.add("org.eclipse.jet.taglib.RuntimeTagElement");
+ importList.add("org.eclipse.jet.taglib.TagInfo");
+ String[] imports = new String[importList.size()];
+ importList.toArray(imports);
+ String packageName = cu.getOutputJavaPackage();
+
+ context.setPackageName(packageName);
+ context.setImports(imports);
+
+ CompletionProposalCollector proposalCollector = new CompletionProposalCollector(javaProject);
+ try {
+ context.codeComplete(codeSnippet, offset, proposalCollector);
+ return proposalCollector;
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public static IJavaCompletionProposal[] getJavaCompletionProposal(IJavaProject javaProject, JET2CompilationUnit cu,
+ String codeSnippet, ITextViewer viewer, int offset) {
+ CompletionProposalCollector proposalCollector = collect(javaProject, cu, codeSnippet, offset);
+ if (proposalCollector != null) {
+ Point selection = viewer.getSelectedRange();
+ if (selection.y > 0)
+ proposalCollector.setReplacementLength(selection.y);
+ IJavaCompletionProposal[] javaProposals = proposalCollector.getJavaCompletionProposals();
+ IJavaCompletionProposal[] keywordsProposals = proposalCollector.getKeywordCompletionProposals();
+
+ IJavaCompletionProposal[] unsortedJavaProposals = new IJavaCompletionProposal[javaProposals.length
+ + keywordsProposals.length];
+ System.arraycopy(keywordsProposals, 0, unsortedJavaProposals, 0, keywordsProposals.length);
+ System.arraycopy(javaProposals, 0, unsortedJavaProposals, keywordsProposals.length, javaProposals.length);
+
+ // sort them by relevance (which is given, but they are unsorted)
+ List sortedJavaProposals = new LinkedList();
+ for (int i = 0; i < unsortedJavaProposals.length; i++) {
+ IJavaCompletionProposal unsortedJavaProposal = unsortedJavaProposals[i];
+ int index = 0;
+ for (Iterator iterator = sortedJavaProposals.iterator(); iterator.hasNext();) {
+ IJavaCompletionProposal proposal = (IJavaCompletionProposal) iterator.next();
+ if (proposal.getRelevance() <= unsortedJavaProposal.getRelevance()) {
+ index = sortedJavaProposals.indexOf(proposal);
+ break;
+ }
+ }
+ sortedJavaProposals.add(index, unsortedJavaProposal);
+ }
+ IJavaCompletionProposal[] results = new IJavaCompletionProposal[sortedJavaProposals.size()];
+ sortedJavaProposals.toArray(results);
+ return results;
+ }
+ return new IJavaCompletionProposal[0];
+ }
+
+ public static String getMethodBodySource(JET2CompilationUnit cu, Map generatedBodyMappingPositions) {
+ JET2TemplateLoader templateLoader = new CodeGenTemplateLoader();
+ JETEditorMethodBodyCreator generatedBody = new JETEditorMethodBodyCreator(templateLoader,
+ generatedBodyMappingPositions);
+ cu.accept(generatedBody);
+ return generatedBody.getBuffer();
+ }
+
+ public static void adjustResults(IJavaCompletionProposal[] results, int offset) {
+ for (int i = 0; i < results.length; i++) {
+ if (results[i] instanceof AbstractJavaCompletionProposal) {
+ AbstractJavaCompletionProposal proposal = (AbstractJavaCompletionProposal) results[i];
+ proposal.setReplacementOffset(offset);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETSourceViewer.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETSourceViewer.java
new file mode 100644
index 0000000..d07b38b
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETSourceViewer.java
@@ -0,0 +1,139 @@
+package org.eclipse.jet.editor;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.source.IOverviewRuler;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+
+public class JETSourceViewer extends ProjectionViewer implements IPropertyChangeListener {
+
+ private IPreferenceStore preferenceStore;
+ private Color foregroundColor;
+ private Color backgroundColor;
+ private Color selectionForegroundColor;
+ private Color selectionBackgroundColor;
+
+ public JETSourceViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler,
+ boolean showsAnnotationOverview, int styles, IPreferenceStore store) {
+ super(parent, ruler, overviewRuler, showsAnnotationOverview, styles);
+ setPreferenceStore(store);
+ // TODO Auto-generated constructor stub
+ }
+
+ public void setPreferenceStore(IPreferenceStore store) {
+ if (preferenceStore != null)
+ preferenceStore.removePropertyChangeListener(this);
+
+ preferenceStore = store;
+
+ if (preferenceStore != null) {
+ preferenceStore.addPropertyChangeListener(this);
+ initializeViewerColors();
+ }
+ }
+
+ private void initializeViewerColors() {
+ if (preferenceStore != null) {
+
+ StyledText styledText = getTextWidget();
+ if (styledText == null)
+ return;
+ // ----------- foreground color --------------------
+ Color color = preferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT) ? null
+ : createColor(preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
+ styledText.setForeground(color);
+
+ if (foregroundColor != null)
+ foregroundColor.dispose();
+
+ foregroundColor = color;
+
+ // ---------- background color ----------------------
+ color = preferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null
+ : createColor(preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
+ styledText.setBackground(color);
+
+ if (backgroundColor != null)
+ backgroundColor.dispose();
+
+ backgroundColor = color;
+
+ // ----------- selection foreground color --------------------
+ color = preferenceStore
+ .getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR) ? null
+ : createColor(preferenceStore,
+ AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, styledText.getDisplay());
+ styledText.setSelectionForeground(color);
+
+ if (selectionForegroundColor != null)
+ selectionForegroundColor.dispose();
+
+ selectionForegroundColor = color;
+
+ // ---------- selection background color ----------------------
+ color = preferenceStore
+ .getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR) ? null
+ : createColor(preferenceStore,
+ AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, styledText.getDisplay());
+ styledText.setSelectionBackground(color);
+
+ if (selectionBackgroundColor != null)
+ selectionBackgroundColor.dispose();
+
+ selectionBackgroundColor = color;
+ }
+ }
+
+ /**
+ * Creates a color from the information stored in the given preference store.
+ * Returns <code>null</code> if there is no such information available.
+ *
+ * @param store the store to read from
+ * @param key the key used for the lookup in the preference store
+ * @param display the display used create the color
+ * @return the created color according to the specification in the preference store
+ * @since 3.0
+ */
+ private Color createColor(IPreferenceStore store, String key, Display display) {
+
+ RGB rgb = null;
+
+ if (store.contains(key)) {
+
+ if (store.isDefault(key))
+ rgb = PreferenceConverter.getDefaultColor(store, key);
+ else
+ rgb = PreferenceConverter.getColor(store, key);
+
+ if (rgb != null)
+ return new Color(display, rgb);
+ }
+
+ return null;
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property)
+ || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property)
+ || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property)
+ || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)
+ || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR.equals(property)
+ || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR.equals(property)
+ || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR.equals(property)
+ || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR.equals(property))
+ {
+ initializeViewerColors();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETTextEditor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETTextEditor.java
new file mode 100644
index 0000000..1695b47
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/JETTextEditor.java
@@ -0,0 +1,254 @@
+package org.eclipse.jet.editor;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jet.JET2Platform;
+import org.eclipse.jet.compiler.JET2CompilationUnit;
+import org.eclipse.jet.editor.configuration.JETDocumentProvider;
+import org.eclipse.jet.editor.configuration.JETEditorPreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETSourceViewerConfiguration;
+import org.eclipse.jet.editor.configuration.JETTokenStyleManager;
+import org.eclipse.jet.editor.outline.JETOutlinePage;
+import org.eclipse.jet.editor.partition.JETDocumentPartitionScanner;
+import org.eclipse.jet.taglib.TagLibrary;
+import org.eclipse.jet.taglib.TagLibraryManager;
+import org.eclipse.jet.taglib.TagLibraryReference;
+import org.eclipse.jet.transform.IJETBundleDescriptor;
+import org.eclipse.jet.transform.IJETBundleManager;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.internal.text.link.contentassist.HTMLTextPresenter;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.projection.ProjectionSupport;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.editors.text.IEncodingSupport;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.texteditor.ContentAssistAction;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+public class JETTextEditor extends TextEditor {
+
+ private JETTokenStyleManager tokenStyleManager;
+ private JETSourceViewer sourceViewer;
+ private JETDocumentPartitionScanner partitionScanner;
+ private ProjectionSupport projectionSupport;
+ private IContentOutlinePage outlinePage;
+
+ private JET2CompilationUnit cUnit;
+ private IJavaProject javaProject;
+
+ public JETTextEditor() {
+ super();
+ IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
+ JETEditorPreferenceConstants.initializeDefaultValues(preferenceStore);
+ setPreferenceStore(preferenceStore);
+ tokenStyleManager = new JETTokenStyleManager(preferenceStore);
+ partitionScanner = new JETDocumentPartitionScanner(this);
+ setSourceViewerConfiguration(new JETSourceViewerConfiguration(this));
+ setDocumentProvider(new JETDocumentProvider(this) {
+ public void changed(Object element) {
+ super.changed(element);
+ JETTextEditor.this.changed();
+ }
+ });
+ }
+
+ public void dispose() {
+ tokenStyleManager.dispose();
+ super.dispose();
+ }
+
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ super.init(site, input);
+ if (input instanceof IFileEditorInput) {
+ IFile jetTemplateFile = ((IFileEditorInput) input).getFile();
+ javaProject = JavaCore.create(jetTemplateFile.getProject());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, int)
+ */
+ protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+ fAnnotationAccess= getAnnotationAccess();
+ fOverviewRuler= createOverviewRuler(getSharedColors());
+
+ sourceViewer= new JETSourceViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles, getPreferenceStore());
+ // ensure decoration support has been created and configured.
+ getSourceViewerDecorationSupport(sourceViewer);
+
+ projectionSupport= new ProjectionSupport(sourceViewer, getAnnotationAccess(), getSharedColors());
+ projectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
+ projectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
+ projectionSupport.setHoverControlCreator(new IInformationControlCreator() {
+ public IInformationControl createInformationControl(Shell shell) {
+ return new DefaultInformationControl(shell, SWT.TOOL | SWT.NO_TRIM | getOrientation(), SWT.NONE, new HTMLTextPresenter());
+ }
+ });
+ projectionSupport.install();
+ return sourceViewer;
+ }
+
+ public ISourceViewer getEditorSourceViewer() {
+ return sourceViewer;
+ }
+
+ public IPreferenceStore getEditorPreferenceStore() {
+ return super.getPreferenceStore();
+ }
+
+ public JETDocumentPartitionScanner getPartitionScanner() {
+ return partitionScanner;
+ }
+
+ public JETTokenStyleManager getTokenStyleManager() {
+ return tokenStyleManager;
+ }
+
+ protected void handleEditorInputChanged() {
+ super.handleEditorInputChanged();
+ changed();
+ }
+
+ private void changed() {
+ if (outlinePage != null && outlinePage.getControl().isVisible())
+ ((JETOutlinePage)outlinePage).setInput();
+ }
+
+ public JET2CompilationUnit requestCompilationUnit() {
+ if (cUnit == null || isDirty()) {
+ IEditorInput editorInput = getEditorInput();
+ String charset = "UTF-8";
+ InputStream is = new ByteArrayInputStream(sourceViewer.getDocument().get().getBytes());
+ cUnit = new JET2CompilationUnit();
+ Map predefinedLibraryMap = getRegisteredPrefixMap();
+ if (editorInput instanceof IFileEditorInput) {
+ IFile jetTemplateFile = ((IFileEditorInput) editorInput).getFile();
+ IJETBundleManager bundleManager = JET2Platform.getJETBundleManager();
+ IJETBundleDescriptor descriptor = bundleManager.getDescriptorForProject(jetTemplateFile.getProject().getName());
+ predefinedLibraryMap.putAll(descriptor != null ? getPredefinedPrefixMap(descriptor) : Collections.EMPTY_MAP);
+ }
+ cUnit.parse(is, charset);
+ cUnit.setPredefinedTagLibraries(predefinedLibraryMap);
+ }
+ return cUnit;
+ }
+
+ public IJavaProject getJETJavaProject() {
+ return javaProject;
+ }
+
+ private Map getRegisteredPrefixMap() {
+ String[] tagLibIds = TagLibraryManager.getInstance().getKnownLibraryIds();
+ final Map result = new HashMap(tagLibIds.length);
+ for (int i = 0; i < tagLibIds.length; i++) {
+ String id = tagLibIds[i];
+ TagLibrary tagLib = TagLibraryManager.getInstance().getTagLibrary(id, true);
+ result.put(tagLib.getDefaultPrefix(), tagLib.getLibraryId());
+ }
+ return result;
+ }
+
+ private Map getPredefinedPrefixMap(IJETBundleDescriptor descriptor) {
+ final TagLibraryReference[] tlRefs = descriptor.getTagLibraryReferences();
+ final Map result = new HashMap(tlRefs.length);
+ for (int i = 0; i < tlRefs.length; i++) {
+ if (tlRefs[i].isAutoImport()) {
+ result.put(tlRefs[i].getPrefix(), tlRefs[i].getTagLibraryId());
+ }
+ }
+ return result;
+ }
+
+ /*
+ * @see AbstractTextEditor#createActions()
+ */
+ protected void createActions() {
+ super.createActions();
+ ResourceBundle resourceBundle = ResourceBundle.getBundle("org.eclipse.jet.editor.i18n.TextEditorMessages");
+ Action action = new ContentAssistAction(resourceBundle,"ContentAssistProposal.", this); //$NON-NLS-1$
+ action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+ setAction("ContentAssistProposal", action); //$NON-NLS-1$
+ markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
+ }
+
+ protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
+ // TODO Auto-generated method stub
+ super.handlePreferenceStoreChanged(event);
+ if (event.getNewValue() instanceof RGB) {
+ getTokenStyleManager().bindColor(event.getProperty(), (RGB) event.getNewValue());
+ }
+ }
+
+ /*
+ * @see AbstractTextEditor#getAdapter(Class)
+ */
+ public Object getAdapter(Class required) {
+
+ if (IContentOutlinePage.class.equals(required)) {
+ if (outlinePage == null)
+ outlinePage= createOutlinePage();
+ return outlinePage;
+ }
+
+ if (IEncodingSupport.class.equals(required))
+ return fEncodingSupport;
+
+ if (projectionSupport != null) {
+ Object adapter= projectionSupport.getAdapter(getSourceViewer(), required);
+ if (adapter != null)
+ return adapter;
+ }
+
+ return super.getAdapter(required);
+ }
+
+ protected IContentOutlinePage createOutlinePage() {
+ JETOutlinePage page= new JETOutlinePage(this);
+ // Listen to selection so that we can handle it is a special way.
+ //
+ page.addSelectionChangedListener(new ISelectionChangedListener() {
+ // This ensures that we handle selections correctly.
+ //
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleContentOutlineSelection(event.getSelection());
+ }
+ });
+ return page;
+ }
+
+ protected void handleContentOutlineSelection(ISelection selection) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void createContextMenuFor(TreeViewer contentOutlineViewer) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/DoubleClickStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/DoubleClickStrategy.java
new file mode 100644
index 0000000..10fd0e9
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/DoubleClickStrategy.java
@@ -0,0 +1,112 @@
+package org.eclipse.jet.editor.configuration;
+
+import org.eclipse.jface.text.*;
+
+public class DoubleClickStrategy 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
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/IJETColorConstants.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/IJETColorConstants.java
new file mode 100644
index 0000000..f109ac0
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/IJETColorConstants.java
@@ -0,0 +1,17 @@
+package org.eclipse.jet.editor.configuration;
+
+import org.eclipse.swt.graphics.RGB;
+
+interface IJETColorConstants {
+ RGB JET_CUSTOM_TAG_FG = new RGB(180, 128, 0);
+ RGB JET_COMMENT_FG = new RGB(0, 155, 50);
+ RGB JET_DIRECTIVE_FG = new RGB(180, 128, 0);
+ RGB JET_EXPRESSION_FG = new RGB (180, 128, 0);
+ RGB JET_SCRIPTLET_FG = new RGB(180, 128, 0);
+
+ RGB JET_EXPRESSION_BG = new RGB(220, 230, 255);
+ RGB JET_DEFAULT_BG = new RGB(230, 230, 230);
+
+ RGB JET_JAVA_CODE = new RGB(128, 128, 128);
+ RGB PROC_INSTR = new RGB(128, 128, 128);
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETDocumentProvider.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETDocumentProvider.java
new file mode 100644
index 0000000..22b88eb
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETDocumentProvider.java
@@ -0,0 +1,31 @@
+package org.eclipse.jet.editor.configuration;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jet.editor.partition.JETDocumentPartitionScanner;
+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 JETDocumentProvider extends FileDocumentProvider {
+
+ private JETTextEditor editor;
+ public JETDocumentProvider(JETTextEditor editor) {
+ this.editor = editor;
+ }
+
+ protected IDocument createDocument(Object element) throws CoreException {
+ IDocument document = super.createDocument(element);
+ JETDocumentPartitionScanner partitionScanner = editor.getPartitionScanner();
+ if (document != null) {
+ IDocumentPartitioner partitioner =
+ new FastPartitioner(
+ partitionScanner,
+ partitionScanner.getContentTypes(editor.getEditorSourceViewer()));
+ partitioner.connect(document);
+ document.setDocumentPartitioner(partitioner);
+ }
+ return document;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETEditorPreferenceConstants.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETEditorPreferenceConstants.java
new file mode 100644
index 0000000..30f5ea5
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETEditorPreferenceConstants.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2005 - 2006 Joel Cheuoua & others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Joel Cheuoua - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jet.editor.configuration;
+
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+
+/**
+ * Preference Constants used for the IRL Editor
+ * @author lmirguet
+ * @version $Revision: 1.1 $
+ */
+public class JETEditorPreferenceConstants {
+ public static final String JET_CUSTOM_TAG_FG_COLOR = "jet_custom_tag_foreground";
+ public static final String JET_CUSTOM_TAG_BOLD = "jet_custom_tag_bold";
+ public static final String JET_CUSTOM_TAG_ITALIC = "jet_custom_tag_italic";
+ public static final String JET_CUSTOM_TAG_UNDERLINE = "jet_custom_tag_underline";
+
+ public static final String JET_COMMENT_FG_COLOR = "jet_comment_foreground";
+ public static final String JET_COMMENT_BOLD = "jet_comment_bold";
+ public static final String JET_COMMENT_ITALIC = "jet_comment_italic";
+ public static final String JET_COMMENT_UNDERLINE = "jet_comment_underline";
+
+ public static final String JET_EXPRESSION_FG_COLOR = "jet_expression_foreground";
+ public static final String JET_EXPRESSION_BOLD = "jet_expression_bold";
+ public static final String JET_EXPRESSION_ITALIC = "jet_expression_italic";
+ public static final String JET_EXPRESSION_UNDERLINE = "jet_expression_underline";
+
+ public static final String JET_SCRIPTLET_FG_COLOR = "jet_scriptlet_foreground";
+ public static final String JET_SCRIPTLET_BOLD = "jet_scriptlet_bold";
+ public static final String JET_SCRIPTLET_ITALIC = "jet_scriptlet_italic";
+ public static final String JET_SCRIPTLET_UNDERLINE = "jet_scriptlet_underline";
+
+ public static final String JET_DIRECTIVE_FG_COLOR = "jet_directive_foreground";
+ public static final String JET_DIRECTIVE_BOLD = "jet_directive_bold";
+ public static final String JET_DIRECTIVE_ITALIC = "jet_directive_italic";
+ public static final String JET_DIRECTIVE_UNDERLINE = "jet_directive_underline";
+
+ public static final String JET_DIRECTIVE_KEYWORD_BOLD = "jet_directive_keyword_bold";
+ public static final String JET_EXPRESSION_BG_COLOR = "jet_expression_background";
+ public static final String JET_DEFAULT_BG_COLOR = "jet_default_background";
+
+ public static final String AUTO_COMPLETE_ENABLED = "autoCompleteEnable";
+ public static final String AUTO_COMPLETE_DELAY = "autoCompleteDelay";
+
+
+
+
+
+ /**
+ * Should not be instanciated.
+ *
+ */
+ private JETEditorPreferenceConstants() {
+ }
+
+ /**
+ * Initialize with the default values.
+ * @param store IPreferenceStore
+ */
+ public static void initializeDefaultValues(IPreferenceStore store) {
+
+ PreferenceConstants.initializeDefaultValues(store);
+ AbstractDecoratedTextEditorPreferenceConstants.initializeDefaultValues(store);
+
+ PreferenceConverter.setDefault(store, JET_COMMENT_FG_COLOR, IJETColorConstants.JET_COMMENT_FG);
+ store.setDefault(JET_COMMENT_BOLD, false);
+ store.setDefault(JET_COMMENT_ITALIC, true);
+ store.setDefault(JET_COMMENT_UNDERLINE, false);
+
+ PreferenceConverter.setDefault(store, JET_CUSTOM_TAG_FG_COLOR, IJETColorConstants.JET_CUSTOM_TAG_FG);
+ store.setDefault(JET_CUSTOM_TAG_BOLD, false);
+ store.setDefault(JET_CUSTOM_TAG_ITALIC, false);
+ store.setDefault(JET_CUSTOM_TAG_UNDERLINE, true);
+
+ PreferenceConverter.setDefault(store, JET_EXPRESSION_FG_COLOR, IJETColorConstants.JET_EXPRESSION_FG);
+ store.setDefault(JET_EXPRESSION_BOLD, false);
+ store.setDefault(JET_EXPRESSION_ITALIC, false);
+ store.setDefault(JET_EXPRESSION_UNDERLINE, false);
+
+ PreferenceConverter.setDefault(store, JET_DIRECTIVE_FG_COLOR, IJETColorConstants.JET_DIRECTIVE_FG);
+ store.setDefault(JET_DIRECTIVE_BOLD, false);
+ store.setDefault(JET_DIRECTIVE_KEYWORD_BOLD, true);
+ store.setDefault(JET_DIRECTIVE_ITALIC, false);
+ store.setDefault(JET_DIRECTIVE_UNDERLINE, false);
+
+ PreferenceConverter.setDefault(store, JET_SCRIPTLET_FG_COLOR, IJETColorConstants.JET_SCRIPTLET_FG);
+ store.setDefault(JET_SCRIPTLET_BOLD, false);
+ store.setDefault(JET_SCRIPTLET_ITALIC, true);
+ store.setDefault(JET_SCRIPTLET_UNDERLINE, false);
+
+ PreferenceConverter.setDefault(store, JET_DEFAULT_BG_COLOR, IJETColorConstants.JET_DEFAULT_BG);
+ PreferenceConverter.setDefault(store, JET_EXPRESSION_BG_COLOR, IJETColorConstants.JET_EXPRESSION_BG);
+
+ store.setDefault(AUTO_COMPLETE_ENABLED, store.getDefaultBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION));
+ store.setDefault(AUTO_COMPLETE_DELAY, store.getDefaultInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETSourceViewerConfiguration.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETSourceViewerConfiguration.java
new file mode 100644
index 0000000..6ae34ef
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETSourceViewerConfiguration.java
@@ -0,0 +1,94 @@
+package org.eclipse.jet.editor.configuration;
+
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.formatter.IContentFormatter;
+import org.eclipse.jface.text.formatter.IFormattingStrategy;
+import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
+import org.eclipse.jface.text.presentation.IPresentationDamager;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.IPresentationRepairer;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+
+public class JETSourceViewerConfiguration extends SourceViewerConfiguration {
+ private DoubleClickStrategy doubleClickStrategy;
+ private JETTextEditor editor;
+
+ public JETSourceViewerConfiguration(JETTextEditor editor) {
+ this.editor = editor;
+ }
+
+ public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+ return editor.getPartitionScanner().getContentTypes(sourceViewer);
+ }
+
+ public ITextDoubleClickStrategy getDoubleClickStrategy(
+ ISourceViewer sourceViewer,
+ String contentType) {
+ if (doubleClickStrategy == null)
+ doubleClickStrategy = new DoubleClickStrategy();
+ return doubleClickStrategy;
+ }
+
+
+ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+ ContentAssistant assistant= new ContentAssistant();
+ assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+
+ //assistant.setRestoreCompletionProposalSize(getSettings("completion_proposal_size")); //$NON-NLS-1$
+
+ String[] configuredContentTypes = getConfiguredContentTypes(sourceViewer);
+ for (int i = 0; i < configuredContentTypes.length; i++) {
+ String contentType = configuredContentTypes[i];
+ IContentAssistProcessor processor = editor.getPartitionScanner().getCompletionProcessor(contentType, assistant);
+ if (processor != null)
+ assistant.setContentAssistProcessor(processor, contentType);
+ }
+
+ assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
+ assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
+
+ assistant.enableAutoInsert(false);
+ assistant.enableAutoActivation(true);
+ return assistant;
+ }
+
+ public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
+ MultiPassContentFormatter formatter= new MultiPassContentFormatter(getConfiguredDocumentPartitioning(sourceViewer), IDocument.DEFAULT_CONTENT_TYPE);
+
+ String[] configuredContentTypes = getConfiguredContentTypes(sourceViewer);
+ for (int i = 0; i < configuredContentTypes.length; i++) {
+ String contentType = configuredContentTypes[i];
+ IFormattingStrategy strategy = editor.getPartitionScanner().getFormattingStrategy(contentType);
+ if (strategy != null) {
+ if (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType))
+ formatter.setMasterStrategy(strategy);
+ else
+ formatter.setSlaveStrategy(strategy, contentType);
+ }
+ }
+ return formatter;
+ }
+
+ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
+ PresentationReconciler reconciler = new PresentationReconciler();
+ String[] configuredContentTypes = getConfiguredContentTypes(sourceViewer);
+ for (int i = 0; i < configuredContentTypes.length; i++) {
+ String contentType = configuredContentTypes[i];
+ IPresentationDamager damager = editor.getPartitionScanner().getDamager(contentType);
+ IPresentationRepairer repairer = editor.getPartitionScanner().getRepairer(contentType);
+ if (damager != null)
+ reconciler.setDamager(damager, contentType);
+ if (repairer != null)
+ reconciler.setRepairer(repairer, contentType);
+ }
+ return reconciler;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETTokenStyleManager.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETTokenStyleManager.java
new file mode 100644
index 0000000..638c566
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETTokenStyleManager.java
@@ -0,0 +1,150 @@
+package org.eclipse.jet.editor.configuration;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jdt.ui.text.IColorManager;
+import org.eclipse.jdt.ui.text.IColorManagerExtension;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+
+public class JETTokenStyleManager implements IColorManager, IColorManagerExtension {
+ private IPreferenceStore preferenceStore;
+
+ protected Map colorTable = new HashMap(10);
+ protected Map keyTable= new HashMap(10);
+ protected Map tokenMap = new HashMap(10);
+
+ public JETTokenStyleManager(IPreferenceStore store) {
+ this.preferenceStore = store;
+ }
+ public void dispose() {
+ Iterator e = colorTable.values().iterator();
+ while (e.hasNext())
+ ((Color) e.next()).dispose();
+ }
+ public Color getColor(RGB rgb) {
+ Color color = (Color) colorTable.get(rgb);
+ if (color == null) {
+ color = new Color(Display.getCurrent(), rgb);
+ colorTable.put(rgb, color);
+ }
+ return color;
+ }
+ public Color getColor(String key) {
+ if (key == null)
+ return null;
+ RGB rgb= (RGB) keyTable.get(key);
+ if (rgb == null) {
+ rgb= PreferenceConverter.getColor(preferenceStore, key);
+ if (rgb == null)
+ return null;
+ keyTable.put(key, rgb);
+ }
+ return getColor(rgb);
+ }
+
+ /*
+ * @see IColorManagerExtension#bindColor(String, RGB)
+ */
+ public void bindColor(String key, RGB rgb) {
+ Object value= keyTable.get(key);
+ if (value != null)
+ throw new UnsupportedOperationException();
+ keyTable.put(key, rgb);
+ }
+
+ /*
+ * @see IColorManagerExtension#unbindColor(String)
+ */
+ public void unbindColor(String key) {
+ keyTable.remove(key);
+ }
+
+ public IToken getCachedToken(String id) {
+ return ((IToken)tokenMap.get(id));
+ }
+
+ public IToken requestToken(String id,
+ String fgColorKey,
+ String bgColorKey,
+ String boldKey,
+ String italicKey,
+ String strikethroughKey,
+ String underlineKey) {
+ if (fgColorKey != null && getColor(fgColorKey) == null) {
+ RGB rgb= PreferenceConverter.getColor(preferenceStore, fgColorKey);
+ unbindColor(fgColorKey);
+ bindColor(fgColorKey, rgb);
+ }
+
+ if (bgColorKey != null && getColor(bgColorKey) == null) {
+ RGB rgb= PreferenceConverter.getColor(preferenceStore, bgColorKey);
+ unbindColor(bgColorKey);
+ bindColor(bgColorKey, rgb);
+ }
+
+ Token token= ((Token)tokenMap.get(id));
+ if (token == null) {
+ token = new Token(createTextAttribute(fgColorKey, bgColorKey, boldKey, italicKey, strikethroughKey, underlineKey));
+ tokenMap.put(id, token);
+ } else {
+ token.setData(createTextAttribute(fgColorKey, bgColorKey, boldKey, italicKey, strikethroughKey, underlineKey));
+ }
+ return token;
+ }
+
+ /**
+ * Create a text attribute based on the given color, bold, italic, strikethrough and underline preference keys.
+ *
+ * @param fgColorKey the fg color preference key
+ * @param bgColorKey the fg color preference key
+ * @param boldKey the bold preference key
+ * @param italicKey the italic preference key
+ * @param strikethroughKey the strikethrough preference key
+ * @param underlineKey the italic preference key
+ * @return the created text attribute
+ * @since 3.0
+ */
+ private TextAttribute createTextAttribute(String fgColorKey, String bgColorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
+ Color fgColor= null;
+ if (fgColorKey != null)
+ fgColor= getColor(fgColorKey);
+ Color bgColor= null;
+ if (bgColorKey != null)
+ bgColor= getColor(bgColorKey);
+
+ int style = (boldKey != null && preferenceStore.getBoolean(boldKey))? SWT.BOLD : SWT.NORMAL;
+
+ if (italicKey != null && preferenceStore.getBoolean(italicKey))
+ style |= SWT.ITALIC;
+
+ if (strikethroughKey != null && preferenceStore.getBoolean(strikethroughKey))
+ style |= TextAttribute.STRIKETHROUGH;
+
+ if (underlineKey != null && preferenceStore.getBoolean(underlineKey))
+ style |= TextAttribute.UNDERLINE;
+
+ return new TextAttribute(fgColor, bgColor, style);
+ }
+
+ public IToken requestDefaultToken() {
+ return requestToken("__jet_default_return_token",
+ AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
+ JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR,
+ null,
+ null,
+ null,
+ null);
+
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETWhitespaceDetector.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETWhitespaceDetector.java
new file mode 100644
index 0000000..dba8371
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/JETWhitespaceDetector.java
@@ -0,0 +1,10 @@
+package org.eclipse.jet.editor.configuration;
+
+import org.eclipse.jface.text.rules.IWhitespaceDetector;
+
+public class JETWhitespaceDetector implements IWhitespaceDetector {
+
+ public boolean isWhitespace(char c) {
+ return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/NonRuleBasedDamagerRepairer.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/NonRuleBasedDamagerRepairer.java
new file mode 100644
index 0000000..a494ca2
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/NonRuleBasedDamagerRepairer.java
@@ -0,0 +1,138 @@
+package org.eclipse.jet.editor.configuration;
+
+import org.eclipse.core.runtime.Assert;
+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.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
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/AbstractJETTextPartitionConfigurationDelegate.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/AbstractJETTextPartitionConfigurationDelegate.java
new file mode 100644
index 0000000..2f8f058
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/AbstractJETTextPartitionConfigurationDelegate.java
@@ -0,0 +1,38 @@
+package org.eclipse.jet.editor.configuration.delegates;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.text.presentation.IPresentationDamager;
+import org.eclipse.jface.text.presentation.IPresentationRepairer;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.ITokenScanner;
+import org.eclipse.ui.IEditorInput;
+
+public abstract class AbstractJETTextPartitionConfigurationDelegate implements IJETTextPartitionConfigurationDelegate {
+
+ private Map defaultDamagerRepairers = new HashMap();
+
+ public IPresentationDamager getDamager(String contentType) {
+ DefaultDamagerRepairer dr = (DefaultDamagerRepairer) defaultDamagerRepairers.get(contentType);
+ ITokenScanner tokenScanner = getTokenScanner(contentType);
+ if (dr == null && tokenScanner != null) {
+ dr = new DefaultDamagerRepairer(tokenScanner);
+ }
+ return dr;
+ }
+
+ public IPresentationRepairer getRepairer(String contentType) {
+ DefaultDamagerRepairer dr = (DefaultDamagerRepairer) defaultDamagerRepairers.get(contentType);
+ ITokenScanner tokenScanner = getTokenScanner(contentType);
+ if (dr == null && tokenScanner != null) {
+ dr = new DefaultDamagerRepairer(tokenScanner);
+ }
+ return dr;
+ }
+
+ public boolean isActiveFor(IEditorInput editorInput) {
+ return true;
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/IJETTextPartitionConfigurationDelegate.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/IJETTextPartitionConfigurationDelegate.java
new file mode 100644
index 0000000..63e34e3
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/IJETTextPartitionConfigurationDelegate.java
@@ -0,0 +1,24 @@
+package org.eclipse.jet.editor.configuration.delegates;
+
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.formatter.IFormattingStrategy;
+import org.eclipse.jface.text.presentation.IPresentationDamager;
+import org.eclipse.jface.text.presentation.IPresentationRepairer;
+import org.eclipse.jface.text.rules.IPredicateRule;
+import org.eclipse.jface.text.rules.ITokenScanner;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.IEditorInput;
+
+public interface IJETTextPartitionConfigurationDelegate {
+ boolean isActiveFor(IEditorInput editorInput);
+
+ String[] getContentTypes(ISourceViewer sourceViewer);
+ IPredicateRule[] getPartitioningRules();
+
+ IPresentationDamager getDamager(String contentType);
+ IPresentationRepairer getRepairer(String contentType);
+ IContentAssistProcessor getContentAssistProcessor(String contentType, ContentAssistant assistant);
+ IFormattingStrategy getFormattingStrategy(String contentType);
+ ITokenScanner getTokenScanner(String contentType);
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/JavaContentPartitionConfigurationDelegate.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/JavaContentPartitionConfigurationDelegate.java
new file mode 100644
index 0000000..fac5832
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/configuration/delegates/JavaContentPartitionConfigurationDelegate.java
@@ -0,0 +1,249 @@
+package org.eclipse.jet.editor.configuration.delegates;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.internal.ui.text.comment.CommentFormattingStrategy;
+import org.eclipse.jdt.internal.ui.text.java.JavaCompletionProcessor;
+import org.eclipse.jdt.internal.ui.text.java.JavaFormattingStrategy;
+import org.eclipse.jdt.internal.ui.text.javadoc.JavadocCompletionProcessor;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.text.IJavaPartitions;
+import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.formatter.IFormattingStrategy;
+import org.eclipse.jface.text.rules.EndOfLineRule;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IPredicateRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.ITokenScanner;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.MultiLineRule;
+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.WordRule;
+import org.eclipse.jface.text.source.ISourceViewer;
+
+public class JavaContentPartitionConfigurationDelegate extends AbstractJETTextPartitionConfigurationDelegate {
+ private JETJavaSourceViewerConfiguration javaConfiguration;
+
+ public JavaContentPartitionConfigurationDelegate(JETTextEditor editor) {
+ javaConfiguration = new JETJavaSourceViewerConfiguration(editor);
+ }
+
+ public String[] getContentTypes(ISourceViewer sourceViewer) {
+ return new String[] {
+ IDocument.DEFAULT_CONTENT_TYPE,
+ IJavaPartitions.JAVA_DOC,
+ IJavaPartitions.JAVA_MULTI_LINE_COMMENT,
+ IJavaPartitions.JAVA_SINGLE_LINE_COMMENT,
+ IJavaPartitions.JAVA_STRING,
+ IJavaPartitions.JAVA_CHARACTER
+ };
+ }
+
+ public IPredicateRule[] getPartitioningRules() {
+ IToken string= new Token(IJavaPartitions.JAVA_STRING);
+ IToken character= new Token(IJavaPartitions.JAVA_CHARACTER);
+ IToken javaDoc= new Token(IJavaPartitions.JAVA_DOC);
+ IToken multiLineComment= new Token(IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
+ IToken singleLineComment= new Token(IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
+
+ List rules= new ArrayList();
+
+ // Add rule for single line comments.
+ rules.add(new EndOfLineRule("//", singleLineComment)); //$NON-NLS-1$
+
+ // Add rule for strings.
+ rules.add(new SingleLineRule("\"", "\"", string, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
+
+ // Add rule for character constants.
+ rules.add(new SingleLineRule("'", "'", character, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
+
+ // Add special case word rule.
+ EmptyCommentRule wordRule= new EmptyCommentRule(multiLineComment);
+ rules.add(wordRule);
+
+ // Add rules for multi-line comments and javadoc.
+ rules.add(new MultiLineRule("/**", "*/", javaDoc)); //$NON-NLS-1$ //$NON-NLS-2$
+ rules.add(new MultiLineRule("/*", "*/", multiLineComment)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ IPredicateRule[] result= new IPredicateRule[rules.size()];
+ rules.toArray(result);
+ return result;
+ }
+
+ public ITokenScanner getTokenScanner(String contentType) {
+ if (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType))
+ return javaConfiguration.getCodeScanner();
+ if (IJavaPartitions.JAVA_DOC.equals(contentType))
+ return javaConfiguration.getJavaDocScanner();
+ if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(contentType))
+ return javaConfiguration.getMultilineCommentScanner();
+ if (IJavaPartitions.JAVA_SINGLE_LINE_COMMENT.equals(contentType))
+ return javaConfiguration.getSinglelineCommentScanner();
+ if (IJavaPartitions.JAVA_STRING.equals(contentType))
+ return javaConfiguration.getStringScanner();
+ if (IJavaPartitions.JAVA_CHARACTER.equals(contentType))
+ return javaConfiguration.getStringScanner();
+ return javaConfiguration.getCodeScanner();
+ }
+
+ public IContentAssistProcessor getContentAssistProcessor(String contentType, ContentAssistant assistant) {
+ if (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType))
+ return javaConfiguration.getCodeAssistProcessor(assistant);
+ if (IJavaPartitions.JAVA_DOC.equals(contentType))
+ return javaConfiguration.getJavaDocAssistProcessor(assistant);
+ if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(contentType))
+ return javaConfiguration.getMultilineCommentAssistProcessor(assistant);
+ if (IJavaPartitions.JAVA_SINGLE_LINE_COMMENT.equals(contentType))
+ return javaConfiguration.getSinglelineCommentAssistProcessor(assistant);
+ if (IJavaPartitions.JAVA_STRING.equals(contentType))
+ return javaConfiguration.getStringAssistProcessor(assistant);
+ if (IJavaPartitions.JAVA_CHARACTER.equals(contentType))
+ return javaConfiguration.getStringAssistProcessor(assistant);
+ return null;
+ }
+
+ public IFormattingStrategy getFormattingStrategy(String contentType) {
+ if (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType))
+ return javaConfiguration.getCodeFormattingStrategy();
+ if (IJavaPartitions.JAVA_DOC.equals(contentType))
+ return javaConfiguration.getJavaDocFormattingStrategy();
+ if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(contentType))
+ return javaConfiguration.getMultilineCommentFormattingStrategy();
+ if (IJavaPartitions.JAVA_SINGLE_LINE_COMMENT.equals(contentType))
+ return javaConfiguration.getSinglelineCommentFormattingStrategy();
+ return null;
+ }
+
+ private class JETJavaSourceViewerConfiguration extends JavaSourceViewerConfiguration {
+ public JETJavaSourceViewerConfiguration(JETTextEditor editor) {
+ super(JavaUI.getColorManager(), editor.getEditorPreferenceStore(), editor, null);
+ }
+
+ public IFormattingStrategy getSinglelineCommentFormattingStrategy() {
+ IFormattingStrategy strategy = new CommentFormattingStrategy();
+ return strategy;
+ }
+
+ public IFormattingStrategy getMultilineCommentFormattingStrategy() {
+ IFormattingStrategy strategy = new CommentFormattingStrategy();
+ return strategy;
+ }
+
+ public IFormattingStrategy getJavaDocFormattingStrategy() {
+ IFormattingStrategy strategy = new CommentFormattingStrategy();
+ return strategy;
+ }
+
+ public IFormattingStrategy getCodeFormattingStrategy() {
+ IFormattingStrategy strategy = new JavaFormattingStrategy();
+ return strategy;
+ }
+
+ public IContentAssistProcessor getStringAssistProcessor(ContentAssistant assistant) {
+ IContentAssistProcessor stringProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_STRING);
+ return stringProcessor;
+ }
+
+ public IContentAssistProcessor getSinglelineCommentAssistProcessor(ContentAssistant assistant) {
+ IContentAssistProcessor singleLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
+ return singleLineProcessor;
+ }
+
+ public IContentAssistProcessor getMultilineCommentAssistProcessor(ContentAssistant assistant) {
+ IContentAssistProcessor multiLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
+ return multiLineProcessor;
+ }
+
+ public IContentAssistProcessor getJavaDocAssistProcessor(ContentAssistant assistant) {
+ IContentAssistProcessor javadocProcessor= new JavadocCompletionProcessor(getEditor(), assistant);
+ return javadocProcessor;
+ }
+
+ public IContentAssistProcessor getCodeAssistProcessor(ContentAssistant assistant) {
+ IContentAssistProcessor javaProcessor= new JavaCompletionProcessor(getEditor(), assistant, IDocument.DEFAULT_CONTENT_TYPE);
+ return javaProcessor;
+ }
+
+ public RuleBasedScanner getCodeScanner() {
+ return super.getCodeScanner();
+ };
+
+ public RuleBasedScanner getMultilineCommentScanner() {
+ return super.getMultilineCommentScanner();
+ }
+
+ public RuleBasedScanner getSinglelineCommentScanner() {
+ return super.getSinglelineCommentScanner();
+ }
+
+ public RuleBasedScanner getStringScanner() {
+ return super.getStringScanner();
+ }
+
+ public RuleBasedScanner getJavaDocScanner() {
+ return super.getJavaDocScanner();
+ }
+ }
+
+ /**
+ * Detector for empty comments.
+ */
+ static class EmptyCommentDetector implements IWordDetector {
+
+ /*
+ * @see IWordDetector#isWordStart
+ */
+ public boolean isWordStart(char c) {
+ return (c == '/');
+ }
+
+ /*
+ * @see IWordDetector#isWordPart
+ */
+ public boolean isWordPart(char c) {
+ return (c == '*' || c == '/');
+ }
+ }
+
+
+ /**
+ * Word rule for empty comments.
+ */
+ static class EmptyCommentRule extends WordRule implements IPredicateRule {
+
+ private IToken fSuccessToken;
+ /**
+ * Constructor for EmptyCommentRule.
+ * @param successToken
+ */
+ public EmptyCommentRule(IToken successToken) {
+ super(new EmptyCommentDetector());
+ fSuccessToken= successToken;
+ addWord("/**/", fSuccessToken); //$NON-NLS-1$
+ }
+
+ /*
+ * @see IPredicateRule#evaluate(ICharacterScanner, boolean)
+ */
+ public IToken evaluate(ICharacterScanner scanner, boolean resume) {
+ return evaluate(scanner);
+ }
+
+ /*
+ * @see IPredicateRule#getSuccessToken()
+ */
+ public IToken getSuccessToken() {
+ return fSuccessToken;
+ }
+ }
+
+
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/AbstractJETAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/AbstractJETAssistProcessor.java
new file mode 100644
index 0000000..f79aee8
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/AbstractJETAssistProcessor.java
@@ -0,0 +1,17 @@
+package org.eclipse.jet.editor.contentassist;
+
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+
+public abstract class AbstractJETAssistProcessor implements IContentAssistProcessor {
+ protected JETTextEditor editor;
+ public AbstractJETAssistProcessor(JETTextEditor editor) {
+ this.editor = editor;
+ }
+
+ public String getErrorMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETCustomTagAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETCustomTagAssistProcessor.java
new file mode 100644
index 0000000..ffb654b
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETCustomTagAssistProcessor.java
@@ -0,0 +1,45 @@
+package org.eclipse.jet.editor.contentassist;
+
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+
+public class JETCustomTagAssistProcessor extends AbstractJETAssistProcessor {
+
+ public JETCustomTagAssistProcessor(JETTextEditor editor) {
+ super(editor);
+ }
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public char[] getContextInformationAutoActivationCharacters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IContextInformationValidator getContextInformationValidator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getErrorMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETDirectiveAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETDirectiveAssistProcessor.java
new file mode 100644
index 0000000..642cbf7
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETDirectiveAssistProcessor.java
@@ -0,0 +1,45 @@
+package org.eclipse.jet.editor.contentassist;
+
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+
+public class JETDirectiveAssistProcessor extends AbstractJETAssistProcessor {
+
+ public JETDirectiveAssistProcessor(JETTextEditor editor) {
+ super(editor);
+ }
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public char[] getContextInformationAutoActivationCharacters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IContextInformationValidator getContextInformationValidator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getErrorMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaDeclarationAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaDeclarationAssistProcessor.java
new file mode 100644
index 0000000..8abf132
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaDeclarationAssistProcessor.java
@@ -0,0 +1,63 @@
+package org.eclipse.jet.editor.contentassist;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jet.compiler.JET2CompilationUnit;
+import org.eclipse.jet.compiler.JET2Declaration;
+import org.eclipse.jet.editor.JETEditorHelper;
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+
+public class JETJavaDeclarationAssistProcessor extends AbstractJETAssistProcessor {
+ private char[] completionProposalAutoActivationCharacters;
+ public JETJavaDeclarationAssistProcessor(JETTextEditor editor) {
+ super(editor);
+ completionProposalAutoActivationCharacters = editor.getEditorPreferenceStore().getString(PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA).toCharArray();
+ }
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+ JET2CompilationUnit cu = editor.requestCompilationUnit();
+ JET2Declaration declaration = (JET2Declaration) JETEditorHelper.getASTElementAt(cu, offset);
+
+ int jetStart = declaration.getStart() + 3; // 3 = "<%!" length
+
+ IJavaProject javaProject = editor.getJETJavaProject();
+ if (javaProject != null && javaProject.isOpen()) {
+ int javaOffset = offset - jetStart;
+ String javaContent = declaration.getJavaContent();
+ IJavaCompletionProposal[] javaCompletionProposals = JETEditorHelper.getJavaCompletionProposal(javaProject, cu, javaContent, viewer, javaOffset);
+ JETEditorHelper.adjustResults(javaCompletionProposals, offset);
+ return javaCompletionProposals;
+ }
+ return null;
+ }
+
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ return completionProposalAutoActivationCharacters;
+ }
+
+ public char[] getContextInformationAutoActivationCharacters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IContextInformationValidator getContextInformationValidator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getErrorMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaExpressionAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaExpressionAssistProcessor.java
new file mode 100644
index 0000000..e91cdb4
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaExpressionAssistProcessor.java
@@ -0,0 +1,101 @@
+package org.eclipse.jet.editor.contentassist;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jet.compiler.JET2CompilationUnit;
+import org.eclipse.jet.compiler.JET2Expression;
+import org.eclipse.jet.editor.JETEditorHelper;
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+
+public class JETJavaExpressionAssistProcessor extends AbstractJETAssistProcessor {
+
+ private char[] completionProposalAutoActivationCharacters;
+
+ public JETJavaExpressionAssistProcessor(JETTextEditor editor) {
+ super(editor);
+ completionProposalAutoActivationCharacters = editor.getEditorPreferenceStore().getString(
+ PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA).toCharArray();
+ }
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+ JET2CompilationUnit cu = editor.requestCompilationUnit();
+ JET2Expression expression = (JET2Expression) JETEditorHelper.getASTElementAt(cu, offset);
+
+ int jetStart = expression.getStart();// + 3; // 3 = "<%=" length
+ // Look for the start of the first non null character
+ try {
+ while (viewer.getDocument().getChar(jetStart) == '<' ||
+ viewer.getDocument().getChar(jetStart) == '%' ||
+ viewer.getDocument().getChar(jetStart) == '=' ||
+ viewer.getDocument().getChar(jetStart) == ' ' ||
+ viewer.getDocument().getChar(jetStart) == '\t' ||
+ viewer.getDocument().getChar(jetStart) == '\r' ||
+ viewer.getDocument().getChar(jetStart) == '\n')
+ jetStart++;
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+// try {
+// System.out.println(" JET Text at offset : " + viewer.getDocument().get(offset, 50));
+// } catch (BadLocationException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// Map mappedPositions = new HashMap();
+// String javaSource = JETEditorHelper.computeJavaSource(cu, mappedPositions);
+
+ IJavaProject javaProject = editor.getJETJavaProject();
+ if (javaProject != null && javaProject.isOpen()) {
+ String declarationsSource = JETEditorHelper.getDeclarationsSourceCode(cu);
+ String bodyMethodDecl = "public void generate(final JET2Context context, JET2Writer out) {\r\n" ;
+ String previousJavaBodyContent = JETEditorHelper.getPreviousGeneratedJavaSource(javaProject, cu, expression);
+ String writeStr = "out.write(";
+ String expBody = "out.write(" + expression.getJavaContent().trim() + ");";
+
+ String javaContent = declarationsSource + bodyMethodDecl + previousJavaBodyContent + expBody;
+ int javaOffset = (offset - jetStart) + declarationsSource.length() + bodyMethodDecl.length() + previousJavaBodyContent.length() + writeStr.length();
+
+ //System.out.println(" Java Text at offset : " + javaContent.substring(javaOffset, javaOffset + 50));
+
+ IJavaCompletionProposal[] javaCompletionProposals = JETEditorHelper.getJavaCompletionProposal(javaProject, cu,
+ javaContent, viewer, javaOffset);
+ JETEditorHelper.adjustResults(javaCompletionProposals, offset);
+ return javaCompletionProposals;
+ }
+ return null;
+ }
+
+
+
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ return completionProposalAutoActivationCharacters;
+ }
+
+ public char[] getContextInformationAutoActivationCharacters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IContextInformationValidator getContextInformationValidator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getErrorMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaScriptletAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaScriptletAssistProcessor.java
new file mode 100644
index 0000000..fee9b38
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETJavaScriptletAssistProcessor.java
@@ -0,0 +1,98 @@
+package org.eclipse.jet.editor.contentassist;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jet.compiler.JET2CompilationUnit;
+import org.eclipse.jet.compiler.JET2Scriptlet;
+import org.eclipse.jet.editor.JETEditorHelper;
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+
+public class JETJavaScriptletAssistProcessor extends AbstractJETAssistProcessor {
+
+ private char[] completionProposalAutoActivationCharacters;
+
+ public JETJavaScriptletAssistProcessor(JETTextEditor editor) {
+ super(editor);
+ completionProposalAutoActivationCharacters = editor.getEditorPreferenceStore().getString(
+ PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA).toCharArray();
+ }
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+ JET2CompilationUnit cu = editor.requestCompilationUnit();
+ JET2Scriptlet scriptlet = (JET2Scriptlet) JETEditorHelper.getASTElementAt(cu, offset);
+
+ int jetStart = scriptlet.getStart();// + 2; // 2 = "<%" length
+ // Look for the start of the first non null character
+ try {
+ while (viewer.getDocument().getChar(jetStart) == '<' ||
+ viewer.getDocument().getChar(jetStart) == '%' ||
+ viewer.getDocument().getChar(jetStart) == ' ' ||
+ viewer.getDocument().getChar(jetStart) == '\t' ||
+ viewer.getDocument().getChar(jetStart) == '\r' ||
+ viewer.getDocument().getChar(jetStart) == '\n')
+ jetStart++;
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+// try {
+// System.out.println(" JET Text at offset : " + viewer.getDocument().get(offset, 50));
+// } catch (BadLocationException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+// Map mappedPositions = new HashMap();
+// String javaSource = JETEditorHelper.computeJavaSource(cu, mappedPositions);
+
+ IJavaProject javaProject = editor.getJETJavaProject();
+ if (javaProject != null && javaProject.isOpen()) {
+ String declarationsSource = JETEditorHelper.getDeclarationsSourceCode(cu);
+ String bodyMethodDecl = "public void generate(final JET2Context context, JET2Writer out) {\r\n" ;
+ String previousJavaBodyContent = JETEditorHelper.getPreviousGeneratedJavaSource(javaProject, cu, scriptlet);
+
+ String scriptletBody = scriptlet.getJavaContent().trim();
+
+ String javaContent = declarationsSource + bodyMethodDecl + previousJavaBodyContent + scriptletBody;
+ int javaOffset = (offset - jetStart) + declarationsSource.length() + bodyMethodDecl.length() + previousJavaBodyContent.length();
+
+ //System.out.println(" Java Text at offset : " + javaContent.substring(javaOffset, javaOffset + 50));
+
+ IJavaCompletionProposal[] javaCompletionProposals = JETEditorHelper.getJavaCompletionProposal(javaProject, cu,
+ javaContent, viewer, javaOffset);
+ JETEditorHelper.adjustResults(javaCompletionProposals, offset);
+ return javaCompletionProposals;
+ }
+ return null;
+ }
+
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ return completionProposalAutoActivationCharacters;
+ }
+
+ public char[] getContextInformationAutoActivationCharacters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IContextInformationValidator getContextInformationValidator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getErrorMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETTagAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETTagAssistProcessor.java
new file mode 100644
index 0000000..d242a7d
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/contentassist/JETTagAssistProcessor.java
@@ -0,0 +1,47 @@
+package org.eclipse.jet.editor.contentassist;
+
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+
+
+public class JETTagAssistProcessor extends AbstractJETAssistProcessor {
+
+ public JETTagAssistProcessor(JETTextEditor editor) {
+ super(editor);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public char[] getContextInformationAutoActivationCharacters() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IContextInformationValidator getContextInformationValidator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getErrorMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETCustomTagFormattingStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETCustomTagFormattingStrategy.java
new file mode 100644
index 0000000..b9b7178
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETCustomTagFormattingStrategy.java
@@ -0,0 +1,34 @@
+package org.eclipse.jet.editor.formatter;
+
+import org.eclipse.jface.text.formatter.IFormattingContext;
+import org.eclipse.jface.text.formatter.IFormattingStrategy;
+import org.eclipse.jface.text.formatter.IFormattingStrategyExtension;
+
+public class JETCustomTagFormattingStrategy implements IFormattingStrategy, IFormattingStrategyExtension {
+
+ public String format(String content, boolean isLineStart, String indentation, int[] positions) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void formatterStarts(String initialIndentation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void formatterStops() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void format() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void formatterStarts(IFormattingContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETDirectiveFormattingStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETDirectiveFormattingStrategy.java
new file mode 100644
index 0000000..990a8d3
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETDirectiveFormattingStrategy.java
@@ -0,0 +1,34 @@
+package org.eclipse.jet.editor.formatter;
+
+import org.eclipse.jface.text.formatter.IFormattingContext;
+import org.eclipse.jface.text.formatter.IFormattingStrategy;
+import org.eclipse.jface.text.formatter.IFormattingStrategyExtension;
+
+public class JETDirectiveFormattingStrategy implements IFormattingStrategy, IFormattingStrategyExtension {
+
+ public String format(String content, boolean isLineStart, String indentation, int[] positions) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void formatterStarts(String initialIndentation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void formatterStops() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void format() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void formatterStarts(IFormattingContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaDeclarationFormattingStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaDeclarationFormattingStrategy.java
new file mode 100644
index 0000000..62d8a24
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaDeclarationFormattingStrategy.java
@@ -0,0 +1,34 @@
+package org.eclipse.jet.editor.formatter;
+
+import org.eclipse.jface.text.formatter.IFormattingContext;
+import org.eclipse.jface.text.formatter.IFormattingStrategy;
+import org.eclipse.jface.text.formatter.IFormattingStrategyExtension;
+
+public class JETJavaDeclarationFormattingStrategy implements IFormattingStrategy, IFormattingStrategyExtension {
+
+ public String format(String content, boolean isLineStart, String indentation, int[] positions) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void formatterStarts(String initialIndentation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void formatterStops() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void format() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void formatterStarts(IFormattingContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaExpressionFormattingStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaExpressionFormattingStrategy.java
new file mode 100644
index 0000000..cab496e
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaExpressionFormattingStrategy.java
@@ -0,0 +1,34 @@
+package org.eclipse.jet.editor.formatter;
+
+import org.eclipse.jface.text.formatter.IFormattingContext;
+import org.eclipse.jface.text.formatter.IFormattingStrategy;
+import org.eclipse.jface.text.formatter.IFormattingStrategyExtension;
+
+public class JETJavaExpressionFormattingStrategy implements IFormattingStrategy, IFormattingStrategyExtension {
+
+ public String format(String content, boolean isLineStart, String indentation, int[] positions) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void formatterStarts(String initialIndentation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void formatterStops() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void format() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void formatterStarts(IFormattingContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaScriptletFormattingStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaScriptletFormattingStrategy.java
new file mode 100644
index 0000000..3103c4b
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/formatter/JETJavaScriptletFormattingStrategy.java
@@ -0,0 +1,34 @@
+package org.eclipse.jet.editor.formatter;
+
+import org.eclipse.jface.text.formatter.IFormattingContext;
+import org.eclipse.jface.text.formatter.IFormattingStrategy;
+import org.eclipse.jface.text.formatter.IFormattingStrategyExtension;
+
+public class JETJavaScriptletFormattingStrategy implements IFormattingStrategy, IFormattingStrategyExtension {
+
+ public String format(String content, boolean isLineStart, String indentation, int[] positions) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void formatterStarts(String initialIndentation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void formatterStops() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void format() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void formatterStarts(IFormattingContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/i18n/TextEditorMessages.properties b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/i18n/TextEditorMessages.properties
new file mode 100644
index 0000000..7deaa82
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/i18n/TextEditorMessages.properties
@@ -0,0 +1 @@
+ContentAssistProposal.label = Content Assist \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlineContentProvider.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlineContentProvider.java
new file mode 100644
index 0000000..a21a742
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlineContentProvider.java
@@ -0,0 +1,180 @@
+package org.eclipse.jet.editor.outline;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.jet.compiler.JET2ASTElement;
+import org.eclipse.jet.compiler.JET2CompilationUnit;
+import org.eclipse.jet.compiler.TextElement;
+import org.eclipse.jet.compiler.XMLBodyElement;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class JETOutlineContentProvider implements ITreeContentProvider {
+
+ private ImportsContainerInput importContainerInput;
+ private CompilationUnitContainerInput astContainerInput;
+ private OutputPackageInput outputPackageInput;
+
+ private JET2CompilationUnit cu;
+ private OutputClassInput outputClassInput;
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+ }
+
+ public class OutputClassInput {
+ private JET2CompilationUnit compilationUnit;
+ public OutputClassInput(JET2CompilationUnit cu) {
+ this.compilationUnit = cu;
+ }
+ public JET2CompilationUnit getCompilationUnit() {
+ return compilationUnit;
+ }
+ }
+
+ public class OutputPackageInput {
+ private JET2CompilationUnit compilationUnit;
+ public OutputPackageInput(JET2CompilationUnit cu) {
+ this.compilationUnit = cu;
+ }
+ public JET2CompilationUnit getCompilationUnit() {
+ return compilationUnit;
+ }
+ }
+
+ public class ImportInput {
+ private ImportsContainerInput container;
+ private String imp;
+
+ public ImportInput(ImportsContainerInput container, String imp) {
+ this.container = container;
+ this.imp = imp;
+ }
+ public ImportsContainerInput getImportsContainerInput() {
+ return container;
+ }
+ public String toString() {
+ return imp;
+ }
+ }
+
+ public class ImportsContainerInput {
+ private JET2CompilationUnit compilationUnit;
+ private Collection importInputs;
+ public ImportsContainerInput(JET2CompilationUnit cu) {
+ this.compilationUnit = cu;
+ importInputs = new ArrayList();
+ for (Iterator iterator = cu.getImports().iterator(); iterator.hasNext();) {
+ String imp = (String) iterator.next();
+ importInputs.add(new ImportInput(this, imp));
+ }
+ }
+ public JET2CompilationUnit getCompilationUnit() {
+ return compilationUnit;
+ }
+ public Collection getImportImputs() {
+ return importInputs;
+ }
+ }
+
+ public class CompilationUnitContainerInput {
+ private Collection bodyElements;
+ private JET2CompilationUnit compilationUnit;
+ public CompilationUnitContainerInput(JET2CompilationUnit cu) {
+ this.bodyElements = new ArrayList();
+ this.compilationUnit = cu;
+ for (Iterator iterator = cu.getBodyElements().iterator(); iterator.hasNext();) {
+ JET2ASTElement elt = (JET2ASTElement) iterator.next();
+ if (isFiltered(elt))
+ continue;
+ bodyElements.add(elt);
+ }
+ }
+ public Collection getFilteredASTElements() {
+ return bodyElements;
+ }
+ public JET2CompilationUnit getCompilationUnit() {
+ return compilationUnit;
+ }
+ private boolean isFiltered(JET2ASTElement elt) {
+ if (elt instanceof TextElement) {
+ String text = new String(((TextElement)elt).getText());
+ text = text.replace('\r', ' ');
+ text = text.replace('\n', ' ');
+ text = text.replace('\t', ' ');
+ text = text.trim();
+ return text.length() == 0;
+ }
+// if (elt instanceof JET2Directive) {
+// JET2Directive directive = (JET2Directive) elt;
+// if ("import".equals(directive.getName()) ||
+// "package".equals(directive.getName()))
+// return true;
+// }
+ return false;
+ }
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ cu = (JET2CompilationUnit) newInput;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ Collection results = new ArrayList();
+ if (inputElement instanceof JET2CompilationUnit) {
+ JET2CompilationUnit cu = (JET2CompilationUnit) inputElement;
+ results.add(outputPackageInput = new OutputPackageInput(cu));
+ results.add(importContainerInput = new ImportsContainerInput(cu));
+ results.add(astContainerInput = new CompilationUnitContainerInput(cu));
+ results.addAll(Arrays.asList(cu.getTagLibraryReferences()));
+ }
+ return results.toArray();
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement == outputPackageInput) {
+ return new Object[] {outputClassInput = new OutputClassInput(cu)};
+ }
+ if (parentElement == importContainerInput) {
+ return importContainerInput.getImportImputs().toArray();
+ }
+ if (parentElement == astContainerInput) {
+ return astContainerInput.bodyElements.toArray();
+ }
+ if (parentElement instanceof XMLBodyElement) {
+ XMLBodyElement astElement = (XMLBodyElement) parentElement;
+ return astElement.getBodyElements().toArray();
+ }
+ return null;
+ }
+
+ public Object getParent(Object element) {
+ if (element == outputPackageInput ||
+ element == importContainerInput ||
+ element == astContainerInput)
+ return cu;
+ if (element == outputClassInput)
+ return outputPackageInput;
+ if (element instanceof ImportInput)
+ return ((ImportInput)element).getImportsContainerInput();
+ if (element instanceof JET2ASTElement) {
+ if (((JET2ASTElement)element).getParent() == cu)
+ return astContainerInput;
+ return ((JET2ASTElement)element).getParent();
+ }
+ if (importContainerInput.getCompilationUnit().getImports().contains(element))
+ return importContainerInput;
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return (element instanceof XMLBodyElement) ||
+ (element == outputPackageInput) ||
+ (element == importContainerInput) ||
+ (element == astContainerInput);
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlineLabelProvider.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlineLabelProvider.java
new file mode 100644
index 0000000..3adc7eb
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlineLabelProvider.java
@@ -0,0 +1,111 @@
+package org.eclipse.jet.editor.outline;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jet.compiler.Comment;
+import org.eclipse.jet.compiler.JET2Declaration;
+import org.eclipse.jet.compiler.JET2Directive;
+import org.eclipse.jet.compiler.JET2Expression;
+import org.eclipse.jet.compiler.JET2Scriptlet;
+import org.eclipse.jet.compiler.TextElement;
+import org.eclipse.jet.compiler.XMLElement;
+import org.eclipse.jet.editor.Activator;
+import org.eclipse.jet.taglib.TagLibraryReference;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+
+public class JETOutlineLabelProvider extends LabelProvider {
+
+ public Image getImage(Object element) {
+ if (element instanceof Comment) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_JAVADOCTAG);
+ } else if (element instanceof JET2Declaration) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PUBLIC);
+ } else if (element instanceof JET2Expression) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_DEFAULT);
+ } else if (element instanceof JET2Scriptlet) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PUBLIC);
+ } else if (element instanceof JET2Directive) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PROTECTED);
+ } else if (element instanceof TextElement) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_IMPDECL);
+ } else if (element instanceof XMLElement) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PROTECTED);
+ } else if (element instanceof JETOutlineContentProvider.ImportsContainerInput) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_IMPCONT);
+ } else if (element instanceof JETOutlineContentProvider.ImportInput) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_IMPDECL);
+ } else if (element instanceof JETOutlineContentProvider.CompilationUnitContainerInput) {
+ return Activator.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
+ } else if (element instanceof JETOutlineContentProvider.OutputPackageInput) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PACKDECL);
+ } else if (element instanceof JETOutlineContentProvider.OutputClassInput) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_CUNIT);
+ } else if (element instanceof TagLibraryReference) {
+ return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_ANNOTATION);
+ }
+ return super.getImage(element);
+ }
+
+ public String getText(Object element) {
+ if (element instanceof Comment) {
+ return getShortText(((Comment)element).getCommentText());
+ } else if (element instanceof JET2Declaration) {
+ return "<%!" + getShortText(((JET2Declaration)element).getJavaContent()) + "%>";
+ } else if (element instanceof JET2Expression) {
+ return "<%=" + getShortText(((JET2Expression)element).getJavaContent()) + "%>";
+ } else if (element instanceof JET2Scriptlet) {
+ return "<%" + getShortText(((JET2Scriptlet)element).getJavaContent()) + "%>";
+ } else if (element instanceof JET2Directive) {
+ return "<%@" + ((JET2Directive)element).getName() + " " + getAttributesText(((JET2Directive)element)) + "%>";
+ } else if (element instanceof TextElement) {
+ return getShortText(new String(((TextElement)element).getText()));
+ } else if (element instanceof XMLElement) {
+ return "<" + ((XMLElement)element).getName() + " " + getAttributesText(((XMLElement)element)) + ">";
+ } else if (element instanceof JETOutlineContentProvider.ImportsContainerInput) {
+ return "import declarations";
+ } else if (element instanceof JETOutlineContentProvider.CompilationUnitContainerInput) {
+ return "Template AST";
+ } else if (element instanceof JETOutlineContentProvider.OutputPackageInput) {
+ return ((JETOutlineContentProvider.OutputPackageInput)element).getCompilationUnit().getOutputJavaPackage();
+ } else if (element instanceof JETOutlineContentProvider.OutputClassInput) {
+ return ((JETOutlineContentProvider.OutputClassInput)element).getCompilationUnit().getOutputJavaClassName();
+ } else if (element instanceof TagLibraryReference) {
+ return ((TagLibraryReference)element).getTagLibraryId();
+ }
+ return super.getText(element);
+ }
+
+ private String getShortText(String text) {
+ if (text.length() > 25)
+ text = text.substring(0, 25) + "...";
+ return text;
+ }
+
+ private String getAttributesText(XMLElement element) {
+ Map attributes = element.getAttributes();
+ StringBuffer textBuffer = new StringBuffer(attributes.size() * 5);
+ for (Iterator iterator = attributes.keySet().iterator(); iterator.hasNext();) {
+ String attrName = (String) iterator.next();
+ String attrValue = (String) attributes.get(attrName);
+ textBuffer.append(attrName).append("=\"").append(attrValue).append("\"");
+ textBuffer.append(' ');
+ }
+ return textBuffer.toString();
+ }
+
+ private String getAttributesText(JET2Directive directive) {
+ Map attributes = directive.getAttributes();
+ StringBuffer textBuffer = new StringBuffer(attributes.size() * 5);
+ for (Iterator iterator = attributes.keySet().iterator(); iterator.hasNext();) {
+ String attrName = (String) iterator.next();
+ String attrValue = (String) attributes.get(attrName);
+ textBuffer.append(attrName).append("=\"").append(attrValue).append("\"");
+ textBuffer.append(' ');
+ }
+ return textBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlinePage.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlinePage.java
new file mode 100644
index 0000000..b2286da
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/outline/JETOutlinePage.java
@@ -0,0 +1,57 @@
+package org.eclipse.jet.editor.outline;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jet.compiler.JET2CompilationUnit;
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jface.viewers.IPostSelectionProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+
+public class JETOutlinePage extends ContentOutlinePage implements IAdaptable , IPostSelectionProvider {
+ private JETTextEditor editor;
+ private TreeViewer contentOutlineViewer;
+ public JETOutlinePage(JETTextEditor editor) {
+ this.editor = editor;
+ }
+
+ public void createControl(Composite parent) {
+ // TODO Auto-generated method stub
+ super.createControl(parent);
+ contentOutlineViewer = getTreeViewer();
+ contentOutlineViewer.addSelectionChangedListener(this);
+
+ // Set up the tree viewer.
+ //
+ contentOutlineViewer.setContentProvider(new JETOutlineContentProvider());
+ contentOutlineViewer.setLabelProvider(new JETOutlineLabelProvider());
+
+ setInput();
+
+ // Make sure our popups work.
+ //
+ editor.createContextMenuFor(contentOutlineViewer);
+ }
+
+ public void setInput() {
+ JET2CompilationUnit cu = editor.requestCompilationUnit();
+ contentOutlineViewer.setInput(cu);
+ }
+
+ public Object getAdapter(Class adapter) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/partition/JETDocumentPartitionScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/partition/JETDocumentPartitionScanner.java
new file mode 100644
index 0000000..a1bc135
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/partition/JETDocumentPartitionScanner.java
@@ -0,0 +1,509 @@
+package org.eclipse.jet.editor.partition;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jet.editor.JETTextEditor;
+import org.eclipse.jet.editor.configuration.JETTokenStyleManager;
+import org.eclipse.jet.editor.configuration.delegates.IJETTextPartitionConfigurationDelegate;
+import org.eclipse.jet.editor.contentassist.JETCustomTagAssistProcessor;
+import org.eclipse.jet.editor.contentassist.JETDirectiveAssistProcessor;
+import org.eclipse.jet.editor.contentassist.JETJavaDeclarationAssistProcessor;
+import org.eclipse.jet.editor.contentassist.JETJavaExpressionAssistProcessor;
+import org.eclipse.jet.editor.contentassist.JETJavaScriptletAssistProcessor;
+import org.eclipse.jet.editor.formatter.JETCustomTagFormattingStrategy;
+import org.eclipse.jet.editor.formatter.JETDirectiveFormattingStrategy;
+import org.eclipse.jet.editor.formatter.JETJavaDeclarationFormattingStrategy;
+import org.eclipse.jet.editor.formatter.JETJavaExpressionFormattingStrategy;
+import org.eclipse.jet.editor.formatter.JETJavaScriptletFormattingStrategy;
+import org.eclipse.jet.editor.rules.JETCommentRule;
+import org.eclipse.jet.editor.rules.JETCustomTagRule;
+import org.eclipse.jet.editor.rules.JETDirectiveRule;
+import org.eclipse.jet.editor.rules.JETJavaDeclarationRule;
+import org.eclipse.jet.editor.rules.JETJavaExpressionRule;
+import org.eclipse.jet.editor.rules.JETJavaScriptletRule;
+import org.eclipse.jet.editor.scanners.JETCommentScanner;
+import org.eclipse.jet.editor.scanners.JETCustomTagScanner;
+import org.eclipse.jet.editor.scanners.JETDefaultContentScanner;
+import org.eclipse.jet.editor.scanners.JETDirectiveScanner;
+import org.eclipse.jet.editor.scanners.JETJavaDeclarationScanner;
+import org.eclipse.jet.editor.scanners.JETJavaExpressionScanner;
+import org.eclipse.jet.editor.scanners.JETJavaScriptletScanner;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.formatter.IFormattingStrategy;
+import org.eclipse.jface.text.presentation.IPresentationDamager;
+import org.eclipse.jface.text.presentation.IPresentationRepairer;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.IPredicateRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.ITokenScanner;
+import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.osgi.framework.Bundle;
+
+public class JETDocumentPartitionScanner extends RuleBasedPartitionScanner {
+
+ public final static String JET_COMMENT = "__jet_comment";
+ public final static String JET_CUSTOM_TAG = "__jet_xml_tag";
+ public final static String JET_DIRECTIVE = "__jet_directive";
+ public final static String JET_JAVA_DECLARATION = "__jet_java_declaration";
+ public final static String JET_JAVA_EXPRESSION = "__jet_java_expression";
+ public final static String JET_JAVA_SCRIPTLET = "__jet_java_scriptlet";
+
+ private Map tokenScanners;
+ private Map damagerRepairers;
+ private Map damagersOnly;
+ private Map repairersOnly;
+ private Map completionProcessors;
+ private Map formattingStrategies;
+
+ private JETTextEditor editor;
+
+ private List contentTypes;
+ private Map delegatesContentTypes;
+
+ private Collection partitionConfigurationDelegates;
+
+ private JETDefaultContentScanner defaultContentScanner;
+ private JETCustomTagScanner tagScanner;
+ private JETDirectiveScanner directiveScanner;
+ private JETJavaDeclarationScanner declarationScanner;
+ private JETJavaExpressionScanner expressionScanner;
+ private JETJavaScriptletScanner scriptletScanner;
+ private JETCommentScanner commentScanner;
+
+ private IContentAssistProcessor tagAssistProcessor;
+ private IContentAssistProcessor scriptletAssistProcessor;
+ private IContentAssistProcessor expressionAssistProcessor;
+ private IContentAssistProcessor declarationAssistProcessor;
+ private IContentAssistProcessor directiveAssistProcessor;
+
+ private IFormattingStrategy tagFormattingStrategy;
+ private IFormattingStrategy scriptletFormattingStrategy;
+ private IFormattingStrategy expressionFormattingStrategy;
+ private IFormattingStrategy declarationFormattingStrategy;
+ private IFormattingStrategy directiveFormattingStrategy;
+
+ public JETDocumentPartitionScanner(JETTextEditor editor) {
+ this.editor = editor;
+ initPartitionScannerDelegetes();
+ List rules = new ArrayList();
+
+ IToken jetComments = new Token(JET_COMMENT);
+ IToken jetCustomTags = new Token(JET_CUSTOM_TAG);
+ IToken jetDirective = new Token(JET_DIRECTIVE);
+ IToken jetJavaDeclaration = new Token(JET_JAVA_DECLARATION);
+ IToken jetJavaExpression = new Token(JET_JAVA_EXPRESSION);
+ IToken jetJavaScriptlet = new Token(JET_JAVA_SCRIPTLET);
+
+ rules.add(new JETCommentRule(jetComments));
+ rules.add(new JETCustomTagRule(jetCustomTags));
+ rules.add(new JETDirectiveRule(jetDirective));
+ rules.add(new JETJavaDeclarationRule(jetJavaDeclaration));
+ rules.add(new JETJavaExpressionRule(jetJavaExpression));
+ rules.add(new JETJavaScriptletRule(jetJavaScriptlet));
+
+ for (Iterator iterator = partitionConfigurationDelegates.iterator(); iterator.hasNext();) {
+ IJETTextPartitionConfigurationDelegate delegate = (IJETTextPartitionConfigurationDelegate) iterator.next();
+ if (delegate.isActiveFor(editor.getEditorInput())) {
+ IPredicateRule[] partitioningRules = delegate.getPartitioningRules();
+ for (int i = 0; i < partitioningRules.length; i++) {
+ IPredicateRule rule = partitioningRules[i];
+ rules.add(rule);
+ }
+ }
+ }
+
+ IPredicateRule[] result = new IPredicateRule[rules.size()];
+ result = (IPredicateRule[]) rules.toArray(result);
+ setPredicateRules(result);
+ }
+
+ private void initPartitionScannerDelegetes() {
+ partitionConfigurationDelegates = new ArrayList();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.jet.editor", "partitionConfigurationDelegates");
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement element = elements[i];
+ Bundle bundle = Platform.getBundle(element.getNamespaceIdentifier());
+ String delegateClass = element.getAttribute("delegateClass");
+ IJETTextPartitionConfigurationDelegate delegate = null;
+ try {
+ Class clazz = bundle.loadClass(delegateClass);
+ Class[] argTypes = new Class[] {JETTextEditor.class};
+ Constructor ctorWithTextEditor = null;
+ try {
+ ctorWithTextEditor = clazz.getConstructor(argTypes);
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (ctorWithTextEditor != null)
+ delegate = (IJETTextPartitionConfigurationDelegate) ctorWithTextEditor.newInstance(new Object[] {editor});
+ else
+ delegate = (IJETTextPartitionConfigurationDelegate) clazz.newInstance();
+ partitionConfigurationDelegates.add(delegate);
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ public String[] getContentTypes(ISourceViewer sourceViewer) {
+ if (contentTypes == null) {
+ contentTypes = new ArrayList();
+ delegatesContentTypes = new HashMap();
+
+ contentTypes.add(IDocument.DEFAULT_CONTENT_TYPE);
+ contentTypes.add(JET_COMMENT);
+ contentTypes.add(JET_CUSTOM_TAG);
+ contentTypes.add(JET_DIRECTIVE);
+ contentTypes.add(JET_JAVA_DECLARATION);
+ contentTypes.add(JET_JAVA_EXPRESSION);
+ contentTypes.add(JET_JAVA_SCRIPTLET);
+
+ for (Iterator iterator = partitionConfigurationDelegates.iterator(); iterator.hasNext();) {
+ IJETTextPartitionConfigurationDelegate delegate = (IJETTextPartitionConfigurationDelegate) iterator.next();
+ if (delegate.isActiveFor(editor.getEditorInput())) {
+ String[] delegateContentTypes = delegate.getContentTypes(sourceViewer);
+ for (int i = 0; i < delegateContentTypes.length; i++) {
+ String contentType = delegateContentTypes[i];
+ contentTypes.add(contentType);
+ delegatesContentTypes.put(contentType, delegate);
+ }
+ }
+ }
+ }
+ String[] result = new String[contentTypes.size()];
+ result = (String[]) contentTypes.toArray(result);
+ return result;
+ }
+
+ private void initTokenScanners() {
+ tokenScanners = new HashMap();
+ tokenScanners.put(IDocument.DEFAULT_CONTENT_TYPE, getDefaultContentScanner());
+ tokenScanners.put(JET_COMMENT, getCommentScanner());
+ tokenScanners.put(JET_CUSTOM_TAG, getCustomTagScanner());
+ tokenScanners.put(JET_DIRECTIVE, getDirectiveScanner());
+ tokenScanners.put(JET_JAVA_DECLARATION, getJavaDeclarationScanner());
+ tokenScanners.put(JET_JAVA_EXPRESSION, getJavaExpressionScanner());
+ tokenScanners.put(JET_JAVA_SCRIPTLET, getJavaScriptletScanner());
+
+ for (Iterator iterator = delegatesContentTypes.keySet().iterator(); iterator.hasNext();) {
+ String contentType = (String) iterator.next();
+ IJETTextPartitionConfigurationDelegate delegate = (IJETTextPartitionConfigurationDelegate) delegatesContentTypes.get(contentType);
+ ITokenScanner tokenScanner = delegate.getTokenScanner(contentType);
+ if (tokenScanner != null)
+ tokenScanners.put(contentType, tokenScanner);
+ }
+ }
+
+ private void initCompletionProcessors(ContentAssistant assistant) {
+ completionProcessors = new HashMap();
+ completionProcessors.put(IDocument.DEFAULT_CONTENT_TYPE, getDefaultContentAssistProcessor(assistant));
+ completionProcessors.put(JET_COMMENT, getCommentAssistProcessor(assistant));
+ completionProcessors.put(JET_CUSTOM_TAG, getCustomTagAssistProcessor(assistant));
+ completionProcessors.put(JET_DIRECTIVE, getDirectiveAssistProcessor(assistant));
+ completionProcessors.put(JET_JAVA_DECLARATION, getJavaDeclarationAssistProcessor(assistant));
+ completionProcessors.put(JET_JAVA_EXPRESSION, getJavaExpressionAssistProcessor(assistant));
+ completionProcessors.put(JET_JAVA_SCRIPTLET, getJavaScriptletAssistProcessor(assistant));
+
+ for (Iterator iterator = delegatesContentTypes.keySet().iterator(); iterator.hasNext();) {
+ String contentType = (String) iterator.next();
+ IJETTextPartitionConfigurationDelegate delegate = (IJETTextPartitionConfigurationDelegate) delegatesContentTypes.get(contentType);
+ IContentAssistProcessor processor = delegate.getContentAssistProcessor(contentType, assistant);
+ if (processor != null)
+ completionProcessors.put(contentType, processor);
+ }
+ }
+
+ private void initFormattingStrategies() {
+ formattingStrategies = new HashMap();
+ formattingStrategies.put(IDocument.DEFAULT_CONTENT_TYPE, getDefaultFormattingStrategy());
+ formattingStrategies.put(JET_COMMENT, getCommentFormattingStrategy());
+ formattingStrategies.put(JET_CUSTOM_TAG, getCustomTagFormattingStrategy());
+ formattingStrategies.put(JET_DIRECTIVE, getDirectiveFormattingStrategy());
+ formattingStrategies.put(JET_JAVA_DECLARATION, getJavaDeclarationFormattingStrategy());
+ formattingStrategies.put(JET_JAVA_EXPRESSION, getJavaExpressionFormattingStrategy());
+ formattingStrategies.put(JET_JAVA_SCRIPTLET, getJavaScriptletFormattingStrategy());
+
+ for (Iterator iterator = delegatesContentTypes.keySet().iterator(); iterator.hasNext();) {
+ String contentType = (String) iterator.next();
+ IJETTextPartitionConfigurationDelegate delegate = (IJETTextPartitionConfigurationDelegate) delegatesContentTypes.get(contentType);
+ IFormattingStrategy strategy = delegate.getFormattingStrategy(contentType);
+ if (strategy != null)
+ formattingStrategies.put(contentType, strategy);
+ }
+ }
+
+ private void initDamagerRepairers() {
+ damagerRepairers = new HashMap();
+
+ damagerRepairers.put(JET_COMMENT, createDefaultDamagerRepairer(JET_COMMENT));
+ damagerRepairers.put(JET_CUSTOM_TAG, createDefaultDamagerRepairer(JET_CUSTOM_TAG));
+ damagerRepairers.put(JET_DIRECTIVE, createDefaultDamagerRepairer(JET_DIRECTIVE));
+ damagerRepairers.put(JET_JAVA_DECLARATION, createDefaultDamagerRepairer(JET_JAVA_DECLARATION));
+ damagerRepairers.put(JET_JAVA_EXPRESSION, createDefaultDamagerRepairer(JET_JAVA_EXPRESSION));
+ damagerRepairers.put(JET_JAVA_SCRIPTLET, createDefaultDamagerRepairer(JET_JAVA_SCRIPTLET));
+ for (Iterator iterator = delegatesContentTypes.keySet().iterator(); iterator.hasNext();) {
+ String contentType = (String) iterator.next();
+ IJETTextPartitionConfigurationDelegate delegate = (IJETTextPartitionConfigurationDelegate) delegatesContentTypes.get(contentType);
+ IPresentationDamager delegateDamager = delegate.getDamager(contentType);
+ IPresentationRepairer delegateRepairer = delegate.getRepairer(contentType);
+ if (delegateDamager != null && delegateDamager == delegateRepairer)
+ damagerRepairers.put(contentType, delegateDamager);
+ }
+ }
+
+ private void initDamagersOnly() {
+ damagersOnly = new HashMap();
+ for (Iterator iterator = delegatesContentTypes.keySet().iterator(); iterator.hasNext();) {
+ String contentType = (String) iterator.next();
+ IJETTextPartitionConfigurationDelegate delegate = (IJETTextPartitionConfigurationDelegate) delegatesContentTypes.get(contentType);
+ IPresentationDamager delegateDamager = delegate.getDamager(contentType);
+ if (delegateDamager != null && !damagerRepairers.containsValue(delegateDamager))
+ damagersOnly.put(contentType, delegateDamager);
+ }
+ }
+
+ protected void initRepairersOnly() {
+ repairersOnly = new HashMap();
+ for (Iterator iterator = delegatesContentTypes.keySet().iterator(); iterator.hasNext();) {
+ String contentType = (String) iterator.next();
+ IJETTextPartitionConfigurationDelegate delegate = (IJETTextPartitionConfigurationDelegate) delegatesContentTypes.get(contentType);
+ IPresentationRepairer delegateRepairer = delegate.getRepairer(contentType);
+ if (delegateRepairer != null && !damagerRepairers.containsValue(delegateRepairer))
+ repairersOnly.put(contentType, delegateRepairer);
+ }
+ }
+
+ protected IFormattingStrategy getDefaultFormattingStrategy() {
+ return null;
+ }
+
+ protected IFormattingStrategy getCommentFormattingStrategy() {
+ return null;
+ }
+
+ protected IFormattingStrategy getCustomTagFormattingStrategy() {
+ if (tagFormattingStrategy == null) {
+ tagFormattingStrategy = new JETCustomTagFormattingStrategy();
+ }
+ return tagFormattingStrategy;
+ }
+
+ protected IFormattingStrategy getJavaScriptletFormattingStrategy() {
+ if (scriptletFormattingStrategy == null) {
+ scriptletFormattingStrategy = new JETJavaScriptletFormattingStrategy();
+ }
+ return scriptletFormattingStrategy;
+ }
+
+ protected IFormattingStrategy getJavaExpressionFormattingStrategy() {
+ if (expressionFormattingStrategy == null) {
+ expressionFormattingStrategy = new JETJavaExpressionFormattingStrategy();
+ }
+ return expressionFormattingStrategy;
+ }
+
+ protected IFormattingStrategy getJavaDeclarationFormattingStrategy() {
+ if (declarationFormattingStrategy == null) {
+ declarationFormattingStrategy = new JETJavaDeclarationFormattingStrategy();
+ }
+ return declarationFormattingStrategy;
+ }
+
+ protected IFormattingStrategy getDirectiveFormattingStrategy() {
+ if (directiveFormattingStrategy == null) {
+ directiveFormattingStrategy = new JETDirectiveFormattingStrategy();
+ }
+ return directiveFormattingStrategy;
+ }
+
+ protected IContentAssistProcessor getDefaultContentAssistProcessor(ContentAssistant assistant) {
+ return null;
+ }
+
+ protected IContentAssistProcessor getCommentAssistProcessor(ContentAssistant assistant) {
+ return null;
+ }
+
+ protected IContentAssistProcessor getCustomTagAssistProcessor(ContentAssistant assistant) {
+ if (tagAssistProcessor == null) {
+ tagAssistProcessor = new JETCustomTagAssistProcessor(editor);
+ }
+ return tagAssistProcessor;
+ }
+
+ protected IContentAssistProcessor getJavaScriptletAssistProcessor(ContentAssistant assistant) {
+ if (scriptletAssistProcessor == null) {
+ scriptletAssistProcessor = new JETJavaScriptletAssistProcessor(editor);
+ }
+ return scriptletAssistProcessor;
+ }
+
+ protected IContentAssistProcessor getJavaExpressionAssistProcessor(ContentAssistant assistant) {
+ if (expressionAssistProcessor == null) {
+ expressionAssistProcessor = new JETJavaExpressionAssistProcessor(editor);
+ }
+ return expressionAssistProcessor;
+ }
+
+ protected IContentAssistProcessor getJavaDeclarationAssistProcessor(ContentAssistant assistant) {
+ if (declarationAssistProcessor == null) {
+ declarationAssistProcessor = new JETJavaDeclarationAssistProcessor(editor);
+ }
+ return declarationAssistProcessor;
+ }
+
+ protected IContentAssistProcessor getDirectiveAssistProcessor(ContentAssistant assistant) {
+ if (directiveAssistProcessor == null) {
+ directiveAssistProcessor = new JETDirectiveAssistProcessor(editor);
+ }
+ return directiveAssistProcessor;
+ }
+
+ protected ITokenScanner getDefaultContentScanner() {
+ JETTokenStyleManager tokenStyleManager = editor.getTokenStyleManager();
+ IPreferenceStore preferenceStore = editor.getEditorPreferenceStore();
+ if (defaultContentScanner == null) {
+ defaultContentScanner = new JETDefaultContentScanner(tokenStyleManager, preferenceStore);
+ }
+ return defaultContentScanner;
+ }
+
+ protected ITokenScanner getCommentScanner() {
+ JETTokenStyleManager tokenStyleManager = editor.getTokenStyleManager();
+ IPreferenceStore preferenceStore = editor.getEditorPreferenceStore();
+ if (commentScanner == null) {
+ commentScanner = new JETCommentScanner(tokenStyleManager, preferenceStore);
+ }
+ return commentScanner;
+ }
+
+ protected ITokenScanner getCustomTagScanner() {
+ JETTokenStyleManager tokenStyleManager = editor.getTokenStyleManager();
+ IPreferenceStore preferenceStore = editor.getEditorPreferenceStore();
+ if (tagScanner == null) {
+ tagScanner = new JETCustomTagScanner(tokenStyleManager, preferenceStore);
+ }
+ return tagScanner;
+ }
+
+ protected ITokenScanner getJavaScriptletScanner() {
+ JETTokenStyleManager tokenStyleManager = editor.getTokenStyleManager();
+ IPreferenceStore preferenceStore = editor.getEditorPreferenceStore();
+ if (scriptletScanner == null) {
+ scriptletScanner = new JETJavaScriptletScanner(tokenStyleManager, preferenceStore);
+ }
+ return scriptletScanner;
+ }
+
+ protected ITokenScanner getJavaExpressionScanner() {
+ JETTokenStyleManager tokenStyleManager = editor.getTokenStyleManager();
+ IPreferenceStore preferenceStore = editor.getEditorPreferenceStore();
+ if (expressionScanner == null) {
+ expressionScanner = new JETJavaExpressionScanner(tokenStyleManager, preferenceStore);
+ }
+ return expressionScanner;
+ }
+
+ protected ITokenScanner getJavaDeclarationScanner() {
+ JETTokenStyleManager tokenStyleManager = editor.getTokenStyleManager();
+ IPreferenceStore preferenceStore = editor.getEditorPreferenceStore();
+ if (declarationScanner == null) {
+ declarationScanner = new JETJavaDeclarationScanner(tokenStyleManager, preferenceStore);
+ }
+ return declarationScanner;
+ }
+
+ protected ITokenScanner getDirectiveScanner() {
+ JETTokenStyleManager tokenStyleManager = editor.getTokenStyleManager();
+ IPreferenceStore preferenceStore = editor.getEditorPreferenceStore();
+ if (directiveScanner == null) {
+ directiveScanner = new JETDirectiveScanner(tokenStyleManager, preferenceStore);
+ }
+ return directiveScanner;
+ }
+
+ public ITokenScanner getTokenScanner(String contentType) {
+ if (tokenScanners == null)
+ initTokenScanners();
+ ITokenScanner scanner = (ITokenScanner) tokenScanners.get(contentType);
+ return scanner;
+ }
+
+ private DefaultDamagerRepairer createDefaultDamagerRepairer(String contentType) {
+ ITokenScanner tokenScanner = getTokenScanner(contentType);
+ return tokenScanner == null ? null : new DefaultDamagerRepairer(tokenScanner);
+ }
+
+ public IPresentationDamager getDamager(String contentType) {
+ if (damagerRepairers == null)
+ initDamagerRepairers();
+ IPresentationDamager damager = (IPresentationDamager) damagerRepairers.get(contentType);
+ if (damager == null) {
+ if (damagersOnly == null)
+ initDamagersOnly();
+ damager = (IPresentationDamager) damagersOnly.get(contentType);
+ }
+ return damager;
+ }
+
+ public IPresentationRepairer getRepairer(String contentType) {
+ if (damagerRepairers == null)
+ initDamagerRepairers();
+ IPresentationRepairer repairer = (IPresentationRepairer) damagerRepairers.get(contentType);
+ if (repairer == null) {
+ if (repairersOnly == null)
+ initRepairersOnly();
+ repairer = (IPresentationRepairer) repairersOnly.get(contentType);
+ }
+ return repairer;
+ }
+
+ public IContentAssistProcessor getCompletionProcessor(String contentType, ContentAssistant assistant) {
+ if (completionProcessors == null)
+ initCompletionProcessors(assistant);
+ IContentAssistProcessor processor = (IContentAssistProcessor) completionProcessors.get(contentType);
+ return processor;
+ }
+
+ public IFormattingStrategy getFormattingStrategy(String contentType) {
+ if (formattingStrategies == null)
+ initFormattingStrategies();
+ IFormattingStrategy formatter = (IFormattingStrategy) formattingStrategies.get(contentType);
+ return formatter;
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETBracketRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETBracketRule.java
new file mode 100644
index 0000000..0ccaf0f
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETBracketRule.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2005 - 2006 Joel Cheuoua & others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Joel Cheuoua - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jet.editor.rules;
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.MultiLineRule;
+import org.eclipse.jface.text.rules.Token;
+
+/**
+ * @author jcheuoua
+ * @version $Revision: 1.1 $
+ */
+public class JETBracketRule extends MultiLineRule {
+ protected IToken token;
+
+ /**
+ * Constructor for JETBracketRule.
+ *
+ * @param token
+ * IToken
+ */
+ public JETBracketRule(IToken token) {
+ super("<%", "%>", token);
+ this.token = token;
+ }
+
+ /**
+ * Method evaluate.
+ *
+ * @param scanner
+ * ICharacterScanner
+ * @return IToken
+ * @see org.eclipse.jface.text.rules.IRule#evaluate(ICharacterScanner)
+ */
+ public IToken evaluate(ICharacterScanner scanner) {
+ char c = (char) scanner.read();
+ if (c == '%') { // we're reaching the end of the token zone
+ c = (char) scanner.read();
+ if (c == '>') {
+ return token;
+ } else {
+ scanner.unread();
+ scanner.unread();
+ return Token.UNDEFINED;
+ }
+ }
+ if (c == '<') { // we're at the beginning of the token zone
+ c = (char) scanner.read();
+ if (c == '%') {
+ c = (char) scanner.read();
+ if (c == '!' || c == '@' || c == '=' || c == '-') {
+ return token;
+ } else {
+ scanner.unread();
+ return token;
+ }
+ } else {
+ scanner.unread();
+ scanner.unread();
+ return Token.UNDEFINED;
+ }
+ } else {
+ scanner.unread();
+ return Token.UNDEFINED;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETCommentRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETCommentRule.java
new file mode 100644
index 0000000..6133aad
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETCommentRule.java
@@ -0,0 +1,10 @@
+package org.eclipse.jet.editor.rules;
+
+import org.eclipse.jface.text.rules.*;
+
+public class JETCommentRule extends MultiLineRule {
+
+ public JETCommentRule(IToken token) {
+ super("<%--", "--%>", token, '\\');
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETCustomTagRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETCustomTagRule.java
new file mode 100644
index 0000000..c926667
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETCustomTagRule.java
@@ -0,0 +1,78 @@
+package org.eclipse.jet.editor.rules;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jet.taglib.TagLibrary;
+import org.eclipse.jet.taglib.TagLibraryManager;
+import org.eclipse.jface.text.rules.*;
+
+public class JETCustomTagRule extends MultiLineRule {
+ private Set tagElementNames;
+ public JETCustomTagRule(IToken token) {
+ super("<", ">", token, '\\');
+ String[] tagLibIds = TagLibraryManager.getInstance().getKnownLibraryIds();
+ tagElementNames = new HashSet();
+ for (int i = 0; i < tagLibIds.length; i++) {
+ String id = tagLibIds[i];
+ TagLibrary tagLib = TagLibraryManager.getInstance().getTagLibrary(id, true);
+ String[] names = tagLib.getTagNames();
+ for (int j = 0; j < names.length; j++) {
+ String name = names[j];
+ tagElementNames.add(tagLib.getDefaultPrefix() + ":" + name);
+ }
+ }
+ }
+
+ public IToken evaluate(ICharacterScanner scanner, boolean resume) {
+ // TODO Auto-generated method stub
+ return super.evaluate(scanner, resume);
+ }
+
+ protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed) {
+ int c = scanner.read();
+ int readCount = 1;
+ if (sequence[0] == '<') {
+ // Cut through obvious cases
+ if ((char)c == '%') {
+ // processing jet instruction - abort
+ scanner.unread();
+ return false;
+ }
+ if ((char)c == '?') {
+ // processing instruction - abort
+ scanner.unread();
+ return false;
+ }
+ if ((char)c == '!') {
+ scanner.unread();
+ // comment - abort
+ return false;
+ }
+ StringBuffer name = new StringBuffer();
+ while ((char)c == ' ') {
+ c = scanner.read();
+ readCount++;
+ }
+ if (c == ICharacterScanner.EOF) {
+ for (int i = 0; i < readCount; i++) scanner.unread();
+ return false;
+ }
+ while ((char)c != ' ' && c != ICharacterScanner.EOF && (char)c != '>') {
+ name.append((char)c);
+ c = scanner.read();
+ readCount++;
+ }
+ if (tagElementNames.contains(name.toString())) {
+ scanner.unread();
+ return true;
+ } else {
+ for (int i = 0; i < readCount; i++) scanner.unread();
+ return false;
+ }
+ } else if (sequence[0] == '>') {
+ scanner.unread();
+ }
+ return super.sequenceDetected(scanner, sequence, eofAllowed);
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETDirectiveRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETDirectiveRule.java
new file mode 100644
index 0000000..b9e184b
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETDirectiveRule.java
@@ -0,0 +1,10 @@
+package org.eclipse.jet.editor.rules;
+
+import org.eclipse.jface.text.rules.*;
+
+public class JETDirectiveRule extends MultiLineRule {
+
+ public JETDirectiveRule(IToken token) {
+ super("<%@", "%>", token, '\\');
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaDeclarationRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaDeclarationRule.java
new file mode 100644
index 0000000..3c53b13
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaDeclarationRule.java
@@ -0,0 +1,10 @@
+package org.eclipse.jet.editor.rules;
+
+import org.eclipse.jface.text.rules.*;
+
+public class JETJavaDeclarationRule extends MultiLineRule {
+
+ public JETJavaDeclarationRule(IToken token) {
+ super("<%!", "%>", token, '\\');
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaExpressionRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaExpressionRule.java
new file mode 100644
index 0000000..b0c83af
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaExpressionRule.java
@@ -0,0 +1,10 @@
+package org.eclipse.jet.editor.rules;
+
+import org.eclipse.jface.text.rules.*;
+
+public class JETJavaExpressionRule extends MultiLineRule {
+
+ public JETJavaExpressionRule(IToken token) {
+ super("<%=", "%>", token, '\\');
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaScriptletRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaScriptletRule.java
new file mode 100644
index 0000000..0ca798e
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/JETJavaScriptletRule.java
@@ -0,0 +1,10 @@
+package org.eclipse.jet.editor.rules;
+
+import org.eclipse.jface.text.rules.*;
+
+public class JETJavaScriptletRule extends MultiLineRule {
+
+ public JETJavaScriptletRule(IToken token) {
+ super("<%", "%>", token, '\\');
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/WordListDetectorRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/WordListDetectorRule.java
new file mode 100644
index 0000000..cb00e5d
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/rules/WordListDetectorRule.java
@@ -0,0 +1,48 @@
+/**
+ *
+ */
+package org.eclipse.jet.editor.rules;
+
+import java.util.Collection;
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+public class WordListDetectorRule implements IRule {
+ private IToken success;
+ private String[] words;
+ public WordListDetectorRule(IToken token, String[] words) {
+ this.success = token;
+ this.words = words;
+ }
+ public WordListDetectorRule(IToken token, Collection words) {
+ this.success = token;
+ this.words = new String[words.size()];
+ this.words = (String[]) words.toArray(this.words);
+ }
+ public IToken evaluate(ICharacterScanner scanner) {
+ char c = (char) scanner.read();
+ char initialChar = c;
+ for (int i = 0; i < words.length; i++) {
+ String keyword = words[i];
+ int index = 0;
+ while (keyword.length() > index && c == keyword.charAt(index)) {
+ c = (char) scanner.read();
+ index++;
+ }
+ if (index == keyword.length()) {// success for this keyword ... we'read until the end
+ scanner.unread(); // there is one read in excess at the end
+ return success;
+ }
+ // otherwise, unread and proceed to the next word
+ for (int j = 0; j < index; j++) {
+ scanner.unread();
+ }
+ c = initialChar;
+ }
+ scanner.unread();
+ return Token.UNDEFINED;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETCommentScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETCommentScanner.java
new file mode 100644
index 0000000..8cf75c9
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETCommentScanner.java
@@ -0,0 +1,19 @@
+package org.eclipse.jet.editor.scanners;
+
+import org.eclipse.jet.editor.configuration.JETEditorPreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETTokenStyleManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+
+public class JETCommentScanner extends RuleBasedScanner {
+
+ public JETCommentScanner(JETTokenStyleManager manager, IPreferenceStore preferenceStore) {
+ setDefaultReturnToken(manager.requestToken("__jet_comment",
+ JETEditorPreferenceConstants.JET_COMMENT_FG_COLOR,
+ JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR,
+ JETEditorPreferenceConstants.JET_COMMENT_BOLD,
+ JETEditorPreferenceConstants.JET_COMMENT_ITALIC,
+ null,
+ null));
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETCustomTagScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETCustomTagScanner.java
new file mode 100644
index 0000000..468c0ce
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETCustomTagScanner.java
@@ -0,0 +1,69 @@
+package org.eclipse.jet.editor.scanners;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETEditorPreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETTokenStyleManager;
+import org.eclipse.jet.editor.rules.WordListDetectorRule;
+import org.eclipse.jet.taglib.TagLibrary;
+import org.eclipse.jet.taglib.TagLibraryManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+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;
+
+public class JETCustomTagScanner extends RuleBasedScanner {
+
+ public JETCustomTagScanner(JETTokenStyleManager manager, IPreferenceStore preferenceStore) {
+ IToken tagElementName = manager.requestToken("__jet_custom_tag_elementName",
+ JETEditorPreferenceConstants.JET_CUSTOM_TAG_FG_COLOR,
+ JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR,
+ JETEditorPreferenceConstants.JET_CUSTOM_TAG_BOLD,
+ JETEditorPreferenceConstants.JET_CUSTOM_TAG_ITALIC,
+ null,
+ JETEditorPreferenceConstants.JET_CUSTOM_TAG_UNDERLINE);
+
+ IToken string = manager.requestToken("__jet_custom_tag_string",
+ PreferenceConstants.EDITOR_STRING_COLOR,
+ JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR,
+ PreferenceConstants.EDITOR_STRING_BOLD,
+ PreferenceConstants.EDITOR_STRING_ITALIC,
+ null,
+ PreferenceConstants.EDITOR_STRING_UNDERLINE);
+
+ Collection tagNames = new ArrayList();
+ String[] tagLibIds = TagLibraryManager.getInstance().getKnownLibraryIds();
+ for (int i = 0; i < tagLibIds.length; i++) {
+ String id = tagLibIds[i];
+ TagLibrary tagLib = TagLibraryManager.getInstance().getTagLibrary(id, true);
+ String[] names = tagLib.getTagNames();
+ for (int j = 0; j < names.length; j++) {
+ String name = names[j];
+ tagNames.add(tagLib.getDefaultPrefix() + ":" + name);
+ }
+ }
+
+ IRule[] rules = new IRule[3];
+
+ // Add rule for double quotes
+ rules[0] = new SingleLineRule("\"", "\"", string, '\\');
+ // Add a rule for single quotes
+ rules[1] = new SingleLineRule("'", "'", string, '\\');
+ // Add a rule for the custom tag identifier
+ rules[2] = new WordListDetectorRule(tagElementName, tagNames);
+
+ setRules(rules);
+
+ IToken defaultReturnToken = manager.requestToken("__jet_custom_tag",
+ JETEditorPreferenceConstants.JET_CUSTOM_TAG_FG_COLOR,
+ JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR,
+ null,
+ null,
+ null,
+ null);
+ setDefaultReturnToken(defaultReturnToken);
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETDefaultContentScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETDefaultContentScanner.java
new file mode 100644
index 0000000..c46b9df
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETDefaultContentScanner.java
@@ -0,0 +1,12 @@
+package org.eclipse.jet.editor.scanners;
+
+import org.eclipse.jet.editor.configuration.JETTokenStyleManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+
+public class JETDefaultContentScanner extends RuleBasedScanner {
+
+ public JETDefaultContentScanner(JETTokenStyleManager manager, IPreferenceStore preferenceStore) {
+ setDefaultReturnToken(manager.requestDefaultToken());
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETDirectiveScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETDirectiveScanner.java
new file mode 100644
index 0000000..a962126
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETDirectiveScanner.java
@@ -0,0 +1,61 @@
+package org.eclipse.jet.editor.scanners;
+
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETEditorPreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETTokenStyleManager;
+import org.eclipse.jet.editor.rules.JETBracketRule;
+import org.eclipse.jet.editor.rules.WordListDetectorRule;
+import org.eclipse.jface.preference.IPreferenceStore;
+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;
+
+public class JETDirectiveScanner extends RuleBasedScanner {
+
+ public JETDirectiveScanner(JETTokenStyleManager manager, IPreferenceStore preferenceStore) {
+ IToken keyword = manager.requestToken("__jet_directive_keyword",
+ JETEditorPreferenceConstants.JET_DIRECTIVE_FG_COLOR,
+ JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR,
+ JETEditorPreferenceConstants.JET_DIRECTIVE_KEYWORD_BOLD,
+ JETEditorPreferenceConstants.JET_DIRECTIVE_ITALIC,
+ null,
+ JETEditorPreferenceConstants.JET_DIRECTIVE_UNDERLINE);
+ IToken string = manager.requestToken("__jet_directive_string",
+ PreferenceConstants.EDITOR_STRING_COLOR,
+ JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR,
+ PreferenceConstants.EDITOR_STRING_BOLD,
+ PreferenceConstants.EDITOR_STRING_ITALIC,
+ null,
+ PreferenceConstants.EDITOR_STRING_UNDERLINE);
+ IToken bracket = manager.requestToken("__jet_bracket",
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR,
+ JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC,
+ null,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_UNDERLINE);
+
+ IRule[] rules = new IRule[4];
+
+ // Add rule for brackets
+ rules[0] = new JETBracketRule(bracket);
+ // Add rule for double quotes
+ rules[1] = new SingleLineRule("\"", "\"", string, '\\');
+ // Add a rule for single quotes
+ rules[2] = new SingleLineRule("'", "'", string, '\\');
+ // Add word rule for reserved jet directive words
+ rules[3] = new WordListDetectorRule(keyword, new String[] {"jet", "taglib", "include", "start", "end"});
+
+ setRules(rules);
+
+ IToken defaultReturnToken = manager.requestToken("__jet_directive",
+ JETEditorPreferenceConstants.JET_DIRECTIVE_FG_COLOR,
+ JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR,
+ JETEditorPreferenceConstants.JET_DIRECTIVE_BOLD,
+ JETEditorPreferenceConstants.JET_DIRECTIVE_ITALIC,
+ null,
+ JETEditorPreferenceConstants.JET_DIRECTIVE_UNDERLINE);
+ setDefaultReturnToken(defaultReturnToken);
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaCodeScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaCodeScanner.java
new file mode 100644
index 0000000..8c205fd
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaCodeScanner.java
@@ -0,0 +1,241 @@
+package org.eclipse.jet.editor.scanners;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETTokenStyleManager;
+import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.MultiLineRule;
+import org.eclipse.jface.text.rules.SingleLineRule;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WordRule;
+
+
+/**
+ * A Java code scanner for JET-java sections.
+ */
+public class JETJavaCodeScanner extends BufferedRuleBasedScanner {
+
+ /**
+ * Rule to detect java operators.
+ */
+ private class OperatorRule implements IRule {
+ private char[] JAVA_OPERATORS= { ';', '.', '=', '/', '\\', '+', '-', '*', '<', '>', ':', '?', '!', ',', '|', '&', '^', '%', '~'};
+ private IToken fToken;
+
+ public OperatorRule(IToken token) {
+ fToken= token;
+ }
+
+ public boolean isOperator(char character) {
+ for (int index= 0; index < JAVA_OPERATORS.length; index++) {
+ if (JAVA_OPERATORS[index] == character)
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
+ */
+ public IToken evaluate(ICharacterScanner scanner) {
+ int character= scanner.read();
+ if (isOperator((char) character)) {
+ do {
+ character= scanner.read();
+ } while (isOperator((char) character));
+ scanner.unread();
+ return fToken;
+ } else {
+ scanner.unread();
+ return Token.UNDEFINED;
+ }
+ }
+ }
+
+ /**
+ * Rule to detect java brackets.
+ */
+ private class BracketRule implements IRule {
+
+ private char[] JAVA_BRACKETS= { '(', ')', '{', '}', '[', ']' };
+ private final IToken success;
+
+ public BracketRule(IToken token) {
+ success= token;
+ }
+
+ public boolean isBracket(char character) {
+ for (int index= 0; index < JAVA_BRACKETS.length; index++) {
+ if (JAVA_BRACKETS[index] == character)
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
+ */
+ public IToken evaluate(ICharacterScanner scanner) {
+ int character= scanner.read();
+ if (isBracket((char) character)) {
+ do {
+ character= scanner.read();
+ } while (isBracket((char) character));
+ scanner.unread();
+ return success;
+ } else {
+ scanner.unread();
+ return Token.UNDEFINED;
+ }
+ }
+ }
+
+ private class JavaWordDetector implements IWordDetector {
+ /*
+ * @see IWordDetector#isWordStart
+ */
+ public boolean isWordStart(char c) {
+ return Character.isJavaIdentifierStart(c);
+ }
+
+ /*
+ * @see IWordDetector#isWordPart
+ */
+ public boolean isWordPart(char c) {
+ return Character.isJavaIdentifierPart(c);
+ }
+ }
+
+ private String[] javaKeywords= {
+ "abstract", //$NON-NLS-1$
+ "break", //$NON-NLS-1$
+ "case", "catch", "class", "const", "continue", //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ "default", "do", //$NON-NLS-2$ //$NON-NLS-1$
+ "else", "extends", //$NON-NLS-2$ //$NON-NLS-1$
+ "final", "finally", "for", //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ "goto", //$NON-NLS-1$
+ "if", "implements", "import", "instanceof", "interface", //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ "native", "new", //$NON-NLS-2$ //$NON-NLS-1$
+ "package", "private", "protected", "public", //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ "static", "super", "switch", "synchronized", //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ "this", "throw", "throws", "transient", "try", //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+ "volatile", //$NON-NLS-1$
+ "while", //$NON-NLS-1$
+ "assert", //$NON-NLS-1$
+ "enum", //$NON-NLS-1$
+ "return" //$NON-NLS-1$
+ };
+
+ private String[] javaTypes= { "class", "interface", "void", "boolean", "char", "byte", "short", "strictfp", "int", "long", "float", "double" }; //$NON-NLS-1$ //$NON-NLS-5$ //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-2$
+
+ private String[] javaConstants= { "false", "null", "true" }; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+
+ private String defaultBg;
+ /**
+ * Creates a Java code scanner
+ *
+ * @param manager the color manager
+ * @param store the preference store
+ */
+ public JETJavaCodeScanner(JETTokenStyleManager manager, String defaultBg) {
+ this.defaultBg = defaultBg;
+ List rules = createRules(manager);
+ IRule[] result= new IRule[rules.size()];
+ rules.toArray(result);
+ setRules(result);
+ }
+
+
+ protected List createRules(JETTokenStyleManager manager) {
+ List rules= new ArrayList();
+
+ // Add rule for character constants.
+ IToken token= manager.requestToken("__jet_java_string_" + defaultBg,
+ PreferenceConstants.EDITOR_STRING_COLOR,
+ defaultBg,
+ PreferenceConstants.EDITOR_STRING_BOLD,
+ PreferenceConstants.EDITOR_STRING_ITALIC,
+ PreferenceConstants.EDITOR_STRING_STRIKETHROUGH,
+ PreferenceConstants.EDITOR_STRING_UNDERLINE);
+ rules.add(new SingleLineRule("'", "'", token, '\\')); //$NON-NLS-2$ //$NON-NLS-1$
+
+
+ // Add generic whitespace rule.
+ //rules.add(new WhitespaceRule(new JETWhitespaceDetector()));
+
+ // Add rule for multiline comments
+ token= manager.requestToken("__jet_java_multi_line_comment_" + defaultBg,
+ PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR,
+ defaultBg,
+ PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD,
+ PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_ITALIC,
+ PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_STRIKETHROUGH,
+ PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_UNDERLINE);
+ MultiLineRule multiLineCommentsRule = new MultiLineRule("/*", "*/", token, '\\');
+ rules.add(multiLineCommentsRule);
+
+ // Add rule for single line comments
+ token= manager.requestToken("__jet_java_single_line_comment_" + defaultBg,
+ PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR,
+ defaultBg,
+ PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD,
+ PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_ITALIC,
+ PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_STRIKETHROUGH,
+ PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_UNDERLINE);
+ SingleLineRule singleLineCommentsRule = new SingleLineRule("//", null, token);
+ rules.add(singleLineCommentsRule);
+
+ // Add word rule for keywords,types and constants
+ JavaWordDetector wordDetector= new JavaWordDetector();
+ token= manager.requestToken("__jet_java_default_" + defaultBg,
+ PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR,
+ defaultBg,
+ PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD,
+ PreferenceConstants.EDITOR_JAVA_DEFAULT_ITALIC,
+ PreferenceConstants.EDITOR_JAVA_DEFAULT_STRIKETHROUGH,
+ PreferenceConstants.EDITOR_JAVA_DEFAULT_UNDERLINE);
+ WordRule wordRule= new WordRule(wordDetector, token);
+
+ token = manager.requestToken("__jet_java_keyword_" + defaultBg,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR,
+ defaultBg,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_STRIKETHROUGH,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_UNDERLINE);
+ for (int i=0; i<javaKeywords.length; i++)
+ wordRule.addWord(javaKeywords[i], token);
+ for (int i=0; i<javaTypes.length; i++)
+ wordRule.addWord(javaTypes[i], token);
+ for (int i=0; i<javaConstants.length; i++)
+ wordRule.addWord(javaConstants[i], token);
+ rules.add(wordRule);
+
+ // Add rule for operators
+ token = manager.requestToken("__jet_java_operator_" + defaultBg,
+ PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR,
+ defaultBg,
+ PreferenceConstants.EDITOR_JAVA_OPERATOR_BOLD,
+ PreferenceConstants.EDITOR_JAVA_OPERATOR_ITALIC,
+ PreferenceConstants.EDITOR_JAVA_OPERATOR_STRIKETHROUGH,
+ PreferenceConstants.EDITOR_JAVA_OPERATOR_UNDERLINE);;
+ rules.add(new OperatorRule(token));
+
+ // Add rule for brackets
+ token = manager.requestToken("__jet_java_bracket_" + defaultBg,
+ PreferenceConstants.EDITOR_JAVA_BRACKET_COLOR,
+ defaultBg,
+ PreferenceConstants.EDITOR_JAVA_BRACKET_BOLD,
+ PreferenceConstants.EDITOR_JAVA_BRACKET_ITALIC,
+ PreferenceConstants.EDITOR_JAVA_BRACKET_STRIKETHROUGH,
+ PreferenceConstants.EDITOR_JAVA_BRACKET_UNDERLINE);;
+ rules.add(new BracketRule(token));
+ return rules;
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaDeclarationScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaDeclarationScanner.java
new file mode 100644
index 0000000..2c3f408
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaDeclarationScanner.java
@@ -0,0 +1,34 @@
+package org.eclipse.jet.editor.scanners;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETEditorPreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETTokenStyleManager;
+import org.eclipse.jet.editor.rules.JETBracketRule;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.IToken;
+
+public class JETJavaDeclarationScanner extends JETJavaCodeScanner {
+ public JETJavaDeclarationScanner(JETTokenStyleManager manager, IPreferenceStore preferenceStore) {
+ super(manager, JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR);
+ setDefaultReturnToken(manager.requestDefaultToken());
+ }
+
+ protected List createRules(JETTokenStyleManager manager) {
+ List rules = new ArrayList();
+ List parentRules = super.createRules(manager);
+ IToken bracket = manager.requestToken("__jet_bracket",
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR,
+ JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC,
+ null,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_UNDERLINE);
+ // Add rule for brackets
+ rules.add(new JETBracketRule(bracket));
+ rules.addAll(parentRules);
+ return rules;
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaExpressionScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaExpressionScanner.java
new file mode 100644
index 0000000..440838d
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaExpressionScanner.java
@@ -0,0 +1,41 @@
+package org.eclipse.jet.editor.scanners;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETEditorPreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETTokenStyleManager;
+import org.eclipse.jet.editor.rules.JETBracketRule;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.IToken;
+
+public class JETJavaExpressionScanner extends JETJavaCodeScanner {
+
+ public JETJavaExpressionScanner(JETTokenStyleManager manager, IPreferenceStore preferenceStore) {
+ super(manager, JETEditorPreferenceConstants.JET_EXPRESSION_BG_COLOR);
+ setDefaultReturnToken(manager.requestToken("__jet_expression_default",
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR,
+ JETEditorPreferenceConstants.JET_EXPRESSION_BG_COLOR,
+ null,
+ null,
+ null,
+ null));
+ }
+
+ protected List createRules(JETTokenStyleManager manager) {
+ List rules = new ArrayList();
+ List parentRules = super.createRules(manager);
+ IToken bracket = manager.requestToken("__jet_expression_bracket",
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR,
+ JETEditorPreferenceConstants.JET_EXPRESSION_BG_COLOR,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC,
+ null,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_UNDERLINE);
+ // Add rule for brackets
+ rules.add(new JETBracketRule(bracket));
+ rules.addAll(parentRules);
+ return rules;
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaScriptletScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaScriptletScanner.java
new file mode 100644
index 0000000..fcec5eb
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/editor/scanners/JETJavaScriptletScanner.java
@@ -0,0 +1,35 @@
+package org.eclipse.jet.editor.scanners;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETEditorPreferenceConstants;
+import org.eclipse.jet.editor.configuration.JETTokenStyleManager;
+import org.eclipse.jet.editor.rules.JETBracketRule;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.IToken;
+
+public class JETJavaScriptletScanner extends JETJavaCodeScanner {
+
+ public JETJavaScriptletScanner(JETTokenStyleManager manager, IPreferenceStore preferenceStore) {
+ super(manager, JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR);
+ setDefaultReturnToken(manager.requestDefaultToken());
+ }
+
+ protected List createRules(JETTokenStyleManager manager) {
+ List rules = new ArrayList();
+ List parentRules = super.createRules(manager);
+ IToken bracket = manager.requestToken("__jet_bracket",
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR,
+ JETEditorPreferenceConstants.JET_DEFAULT_BG_COLOR,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_ITALIC,
+ null,
+ PreferenceConstants.EDITOR_JAVA_KEYWORD_UNDERLINE);
+ // Add rule for brackets
+ rules.add(new JETBracketRule(bracket));
+ rules.addAll(parentRules);
+ return rules;
+ }
+}