summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjcheuoua2007-06-04 04:09:37 (EDT)
committer jcheuoua2007-06-04 04:09:37 (EDT)
commit7226bdd2264a7a36b672e978de6a0d9b1956f305 (patch)
tree3803ff7629c02999fe4c5488d93968147b554cdb
parentb0b0b8b83596c90dc751ae80fbbc1a754ba47d4e (diff)
downloadorg.eclipse.jet-7226bdd2264a7a36b672e978de6a0d9b1956f305.zip
org.eclipse.jet-7226bdd2264a7a36b672e978de6a0d9b1956f305.tar.gz
org.eclipse.jet-7226bdd2264a7a36b672e978de6a0d9b1956f305.tar.bz2
Major refactorings to comply with new non-deprecated JET API + comply with legal requirements for file headers
-rw-r--r--plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF30
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET1JavaGenerator.java140
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGenerator.java128
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGeneratorNew.java306
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/Activator.java21
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETDocumentReader.java12
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditor.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditorHelper.java340
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETSourceViewer.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETTextEditor.java250
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETTextPreviewViewer.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/actions/SetContentColorerAction.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETAnnotationHover.java13
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETAnnotationModel.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETProblemAnnotation.java28
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/autoedit/JETTemplateAutoEditStrategy.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/DoubleClickStrategy.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/IJETColorConstants.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETDocumentProvider.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETReconcilingStrategy.java19
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETSourceViewerConfiguration.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETTokenStyleManager.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETWhitespaceDetector.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/NonRuleBasedDamagerRepairer.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/IJETDefaultTextColorerDelegate.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/java/JavaContentPartitionConfigurationDelegate.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/xml/XMLContentPartitionConfigurationDelegate.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/AbstractJETAssistProcessor.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/AbstractXMLTagsBasedAssistProcessor.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETCustomTagAssistProcessor.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETDirectiveAssistProcessor.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaDeclarationAssistProcessor.java53
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaExpressionAssistProcessor.java79
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaScriptletAssistProcessor.java70
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETTagAssistProcessor.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETCustomTagFormattingStrategy.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETDirectiveFormattingStrategy.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaDeclarationFormattingStrategy.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaExpressionFormattingStrategy.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaScriptletFormattingStrategy.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/gen/JETEditorJET2JavaGenerator.java115
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlineContentProvider.java78
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlineLabelProvider.java58
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlinePage.java58
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/ITokenScannerProvider.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/JETDocumentPartitionScanner.java14
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/PartitionScannerBasedDamagerRepairer.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTElementScannerRule.java16
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETCommentRule.java16
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETCustomTagRule.java16
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETDirectiveRule.java18
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaDeclarationRule.java18
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaExpressionRule.java18
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaScriptletRule.java18
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETBracketRule.java3
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETCommentRule.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETCustomTagRule.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETDirectiveRule.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaDeclarationRule.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaExpressionRule.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaScriptletRule.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/WordListDetectorRule.java13
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETCommentScanner.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETCustomTagScanner.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETDefaultContentScanner.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETDirectiveScanner.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaCodeScanner.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaDeclarationScanner.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaExpressionScanner.java10
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaScriptletScanner.java10
-rw-r--r--plugins/org.eclipse.jet.editor/templates/jet2java.jet94
71 files changed, 1618 insertions, 844 deletions
diff --git a/plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF
index 18dd27d..2dacf83 100644
--- a/plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF
@@ -4,21 +4,21 @@ Bundle-Name: %pluginrName
Bundle-SymbolicName: org.eclipse.jet.editor; singleton:=true
Bundle-Version: 0.8.0.qualifier
Bundle-Activator: org.eclipse.jet.internal.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,
- org.eclipse.emf.codegen.ecore,
- org.eclipse.emf.ecore,
- org.eclipse.emf.codegen.ecore.ui
+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.jface.text;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.ui.editors;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.ui.workbench.texteditor;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.ui.views;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.ui.views.properties.tabbed;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.jdt.ui;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.jet;bundle-version="[0.8.0,1.0.0)",
+ org.eclipse.emf.codegen.ecore;bundle-version="[2.2.0,3.0.0)",
+ org.eclipse.emf.ecore;bundle-version="[2.2.0,3.0.0)",
+ org.eclipse.emf.codegen.ecore.ui;bundle-version="[2.2.0,3.0.0)"
Eclipse-LazyStart: true
Export-Package: org.eclipse.jet.internal.editor,
org.eclipse.jet.internal.editor.configuration,
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET1JavaGenerator.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET1JavaGenerator.java
new file mode 100644
index 0000000..6afe243
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET1JavaGenerator.java
@@ -0,0 +1,140 @@
+package org.eclipse.jet.internal.compiler.templates;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.core.parser.ast.*;
+import org.eclipse.jet.internal.compiler.SafeJETASTVisitor;
+import java.util.Iterator;
+import org.eclipse.jet.internal.JavaUtil;
+
+public class JET1JavaGenerator implements JET2Template {
+
+ public JET1JavaGenerator() {
+ super();
+ }
+
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
+
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
+
+ JETCompilationUnit cu = (JETCompilationUnit)context.getVariable("cu"); //$NON-NLS-1$
+
+ out.write("package "); //$NON-NLS-1$
+ out.write( cu.getOutputJavaPackage() );
+ out.write(";"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ for(Iterator i=cu.getImports().iterator();i.hasNext();) {
+ String importName = (String)i.next();
+ out.write("import "); //$NON-NLS-1$
+ out.write(importName);
+ out.write(";"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ out.write(NL);
+ out.write("public class "); //$NON-NLS-1$
+ out.write( cu.getOutputJavaClassName() );
+ out.write(NL);
+ out.write("{"); //$NON-NLS-1$
+ out.write(NL);
+ cu.accept(new SafeJETASTVisitor(context,out) {
+ public boolean visit(JavaDeclaration decl) {
+
+ out.write("\t"); //$NON-NLS-1$
+ out.write( decl.getJavaContent() );
+ out.write(NL);
+
+ return true;
+ }
+ });
+
+ out.write(" protected static String nl;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" public static synchronized "); //$NON-NLS-1$
+ out.write( cu.getOutputJavaClassName() );
+ out.write(" create(String lineSeparator)"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" nl = lineSeparator;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write( cu.getOutputJavaClassName() );
+ out.write(" result = new "); //$NON-NLS-1$
+ out.write( cu.getOutputJavaClassName() );
+ out.write("();"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" nl = null;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" return result;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" protected final String NL = nl == null ? (System.getProperties().getProperty(\"line.separator\")) : nl; //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ cu.accept(new SafeJETASTVisitor(context,out) {
+ private int textCount = 0;
+ public boolean visit(TextElement text) {
+ textCount++;
+
+ out.write(" protected final String TEXT_"); //$NON-NLS-1$
+ out.write(textCount);
+ out.write(" = "); //$NON-NLS-1$
+ out.write(JavaUtil.asJavaQuoteStringWithNLRemoved(text.getText()));
+ out.write(";"); //$NON-NLS-1$
+ out.write(JavaUtil.nlsCommentsForJavaQuoteStringWithNLRemoved(text.getText()));
+ out.write(NL);
+
+ return true;
+ }
+ });
+
+ out.write(NL);
+ out.write(" public String generate(Object argument)"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" final StringBuffer stringBuffer = new StringBuffer();"); //$NON-NLS-1$
+ out.write(NL);
+ cu.accept(new SafeJETASTVisitor(context,out) {
+ private int textCount = 0;
+ public boolean visit(TextElement text) {
+ textCount++;
+
+ out.write(" stringBuffer.append(TEXT_"); //$NON-NLS-1$
+ out.write(textCount);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
+
+ return true;
+ }
+ public boolean visit(JavaScriptlet scriptlet) {
+
+ out.write(" "); //$NON-NLS-1$
+ out.write( scriptlet.getJavaContent() );
+ out.write(NL);
+
+ return true;
+ }
+ public boolean visit(JavaExpression expr) {
+
+ out.write(" stringBuffer.append("); //$NON-NLS-1$
+ out.write( expr.getJavaContent() );
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
+
+ return true;
+ }
+ });
+
+ out.write(" return stringBuffer.toString();"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("}"); //$NON-NLS-1$
+ out.write(NL);
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGenerator.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGenerator.java
deleted file mode 100644
index ec774cd..0000000
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGenerator.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.eclipse.jet.internal.compiler.templates;
-
-import org.eclipse.jet.JET2Context;
-import org.eclipse.jet.JET2Template;
-import org.eclipse.jet.JET2Writer;
-import org.eclipse.jet.taglib.RuntimeTagElement;
-import org.eclipse.jet.taglib.TagInfo;
-import org.eclipse.jet.internal.compiler.*;
-import org.eclipse.jet.compiler.*;
-import org.eclipse.jet.transform.TransformContextExtender;
-import org.eclipse.jet.taglib.TagLibraryReference;
-import java.util.*;
-import org.eclipse.jface.text.Position;
-
-public class JET2JavaGenerator implements JET2Template {
- public static final String _jetns_java = "org.eclipse.jet.javaTags"; //$NON-NLS-1$
- public static final String _jetns_ws = "org.eclipse.jet.workspaceTags"; //$NON-NLS-1$
- public static final String _jetns_c = "org.eclipse.jet.controlTags"; //$NON-NLS-1$
- public static final String _jetns_f = "org.eclipse.jet.formatTags"; //$NON-NLS-1$
-
- private XMLElement[] getAllXMLTags(JET2CompilationUnit cu) {
- final List result = new ArrayList();
- cu.accept(new DefaultJET2ASTVisitor() {
- public void visit(XMLBodyElement element) {
- result.add(element);
- }
-
- public void visit(XMLEmptyElement element) {
- result.add(element);
- }
- });
- return (XMLElement[])result.toArray(new XMLElement[result.size()]);
- }
-
- private 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()]);
- }
-
- private void adjustGeneratedBodyPositions(Map mappingPositions, int generatedBodyOffsetStart) {
- for (Iterator iterator = mappingPositions.keySet().iterator(); iterator.hasNext();) {
- Object element = iterator.next();
- if (!(element instanceof JET2Declaration)) {
- Position position = (Position) mappingPositions.get(element);
- position.offset += generatedBodyOffsetStart;
- }
- }
- }
-
-
- public JET2JavaGenerator() {
- super();
- }
-
- public void generate(final JET2Context context, JET2Writer out) {
- final TagInfo _jettd_c_include_89_4 = new TagInfo("c:include", //$NON-NLS-1$
- 89, 4,
- new String[] {
- "template", //$NON-NLS-1$
- },
- new String[] {
- "templates/tagDataDeclarations.jet", //$NON-NLS-1$
- } );
- out.write( "\n" ); //$NON-NLS-1$
- out.write( "\n" ); //$NON-NLS-1$
- out.write( "\n" ); //$NON-NLS-1$
- out.write( "\n" ); //$NON-NLS-1$
- out.write( "\n" ); //$NON-NLS-1$
- out.write( "\n" ); //$NON-NLS-1$
- out.write( "\n" ); //$NON-NLS-1$
- out.write( "\n" ); //$NON-NLS-1$
-
- JET2CompilationUnit cu = (JET2CompilationUnit) context.getVariable("cu");
- JET2Declaration allMemberDeclarations[] = getAllJavaDeclarations(cu);
- XMLElement allXMLElements[] = getAllXMLTags(cu);
- TagLibraryReference tlRefs[] = cu.getTagLibraryReferences();
- Map generatedBodyMappingPositions = new HashMap();
- Map mappingPositions = (Map) context.getVariable("org.eclipse.jet.storeJavaMappingPositions");
- org.eclipse.jet.internal.editor.JETEditorHelper.JETEditorMethodBodyCreator generatedBody = new org.eclipse.jet.internal.editor.JETEditorHelper.JETEditorMethodBodyCreator(
- TransformContextExtender.getInstance(context).getLoader(), generatedBodyMappingPositions);
- cu.accept(generatedBody);
- out.write( "\npackage " ); //$NON-NLS-1$
- out.write( cu.getOutputJavaPackage() );
- out.write( ";\n\nimport org.eclipse.jet.JET2Context;\nimport org.eclipse.jet.JET2Template;\nimport org.eclipse.jet.JET2Writer;\n" ); //$NON-NLS-1$
- if( allXMLElements.length > 0) { out.write( "\nimport org.eclipse.jet.taglib.RuntimeTagElement;\nimport org.eclipse.jet.taglib.TagInfo;\n" ); //$NON-NLS-1$
- } out.write( "\n" ); //$NON-NLS-1$
- for(Iterator i=cu.getImports().iterator();i.hasNext();) {
- String importName = (String)i.next(); out.write( "\nimport " ); //$NON-NLS-1$
- out.write(importName);
- out.write( ";\n" ); //$NON-NLS-1$
- } out.write( "\n\npublic class " ); //$NON-NLS-1$
- out.write( cu.getOutputJavaClassName() );
- out.write( " implements JET2Template {\n" ); //$NON-NLS-1$
- if( allXMLElements.length > 0) { out.write( "\n" ); //$NON-NLS-1$
- for(int i = 0; i < tlRefs.length; i++ ) { out.write( "\n public static final String _jetns_" ); //$NON-NLS-1$
- out.write( tlRefs[i].getPrefix() );
- out.write( " = \"" ); //$NON-NLS-1$
- out.write( tlRefs[i].getTagLibraryId() );
- out.write( "\"; //$NON-NLS-1$\n" ); //$NON-NLS-1$
- } out.write( "\n" ); //$NON-NLS-1$
- } out.write( "\n" ); //$NON-NLS-1$
- for(int i = 0; i < allMemberDeclarations.length; i++) { out.write( "\n\n" ); //$NON-NLS-1$
- out.write( allMemberDeclarations[i].getJavaContent() );
- out.write( "\n" ); //$NON-NLS-1$
- } out.write( "\n\n\tpublic " ); //$NON-NLS-1$
- out.write( cu.getOutputJavaClassName() );
- out.write( "() {\n\t\tsuper();\n\t}\n\n\tpublic void generate(final JET2Context context, JET2Writer out) {\n" ); //$NON-NLS-1$
- for(int i = 0; i < allXMLElements.length; i++) {
- context.setVariable("element", allXMLElements[i]); //$NON-NLS-1$
- out.write( "\n\t\t\t" ); //$NON-NLS-1$
- RuntimeTagElement _jettag_c_include_89_4 = context.getTagFactory().createRuntimeTag(_jetns_c, "include", "c:include", _jettd_c_include_89_4); //$NON-NLS-1$ //$NON-NLS-2$
- _jettag_c_include_89_4.setRuntimeParent(null);
- _jettag_c_include_89_4.setTagInfo(_jettd_c_include_89_4);
- _jettag_c_include_89_4.doStart(context, out);
- _jettag_c_include_89_4.doEnd();
- out.write( "\n" ); //$NON-NLS-1$
- } out.write( "\n" ); //$NON-NLS-1$
- out.write( generatedBody.getBuffer() );
- out.write( "\n\t}\n\n}\n" ); //$NON-NLS-1$
-
- }
-
-}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGeneratorNew.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGeneratorNew.java
new file mode 100644
index 0000000..5cd227c
--- /dev/null
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGeneratorNew.java
@@ -0,0 +1,306 @@
+package org.eclipse.jet.internal.compiler.templates;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.core.parser.ast.*;
+import org.eclipse.jet.internal.compiler.V2CodeGenVisitor;
+import org.eclipse.jet.internal.compiler.HasNewlinesUtil;
+import org.eclipse.jet.internal.compiler.TagUsageVisitor;
+import org.eclipse.jet.taglib.TagLibraryReference;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import org.eclipse.jet.internal.JavaUtil;
+
+public class JET2JavaGeneratorNew implements JET2Template {
+
+ public JET2JavaGeneratorNew() {
+ super();
+ }
+
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
+
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
+
+ JETCompilationUnit cu = (JETCompilationUnit)context.getVariable("cu"); //$NON-NLS-1$
+ TagUsageVisitor tuv = new TagUsageVisitor();
+ cu.accept(tuv);
+ TagLibraryReference[] tlrefs = tuv.getUsedTagLibraryReferences(cu);
+ Arrays.sort(tlrefs, new Comparator() {
+ public int compare(Object o1, Object o2) {
+ return ((TagLibraryReference)o1).getTagLibraryId().compareTo(((TagLibraryReference)o2).getTagLibraryId());
+ }
+ });
+ final String nlConstantName = "NL"; //$NON-NLS-1$
+
+ out.write("package "); //$NON-NLS-1$
+ out.write( cu.getOutputJavaPackage() );
+ out.write(";"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2Context;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2Template;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2Writer;"); //$NON-NLS-1$
+ out.write(NL);
+ if(tuv.hasTags()) {
+ out.write("import org.eclipse.jet.taglib.RuntimeTagElement;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import org.eclipse.jet.taglib.TagInfo;"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ for(Iterator i=cu.getImports().iterator();i.hasNext();) {
+ out.write("import "); //$NON-NLS-1$
+ out.write( (String)i.next() );
+ out.write(";"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ out.write(NL);
+ out.write("public class "); //$NON-NLS-1$
+ out.write( cu.getOutputJavaClassName() );
+ out.write(" implements JET2Template {"); //$NON-NLS-1$
+ out.write(NL);
+ for(int i = 0; i < tlrefs.length; i++ ) {
+ out.write(" private static final String _jetns_"); //$NON-NLS-1$
+ out.write( tlrefs[i].getPrefix() );
+ out.write(" = \""); //$NON-NLS-1$
+ out.write( tlrefs[i].getTagLibraryId() );
+ out.write("\"; //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ out.write(NL);
+ cu.accept(new V2CodeGenVisitor(context,out) {
+ public boolean visit(JavaDeclaration decl) {
+
+ out.write(" "); //$NON-NLS-1$
+ out.write( decl.getJavaContent() );
+ out.write(NL);
+
+ return true;
+ }
+ });
+
+ out.write(" public "); //$NON-NLS-1$
+ out.write( cu.getOutputJavaClassName() );
+ out.write("() {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" super();"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ if(HasNewlinesUtil.test(cu)) {
+ out.write(NL);
+ out.write(" private static final String "); //$NON-NLS-1$
+ out.write(nlConstantName);
+ out.write(" = System.getProperty(\"line.separator\"); //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ if(tuv.hasTags()) {
+ out.write(" "); //$NON-NLS-1$
+ out.write(NL);
+ cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
+ public boolean visit(XMLBodyElement e) {
+ doElementVisit(e);
+ return true;
+ }
+ public boolean visit(XMLEmptyElement e) {
+ doElementVisit(e);
+ return true;
+ }
+ public void doElementVisit(XMLElement e) {
+
+ out.write(" private static final TagInfo _td_"); //$NON-NLS-1$
+ out.write( tagInfoVar(e) );
+ out.write(" = new TagInfo(\""); //$NON-NLS-1$
+ out.write(e.getName());
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write( e.getLine() );
+ out.write(", "); //$NON-NLS-1$
+ out.write( e.getColumn() );
+ out.write(","); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" new String[] {"); //$NON-NLS-1$
+ out.write(NL);
+ for (Iterator i = e.getAttributes().keySet().iterator(); i.hasNext();) {
+ out.write(" \""); //$NON-NLS-1$
+ out.write( (String) i.next() );
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ out.write(" },"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" new String[] {"); //$NON-NLS-1$
+ out.write(NL);
+ for (Iterator i = e.getAttributes().values().iterator(); i.hasNext();) {
+ String attrValue = (String) i.next();
+ out.write(" \""); //$NON-NLS-1$
+ out.write( JavaUtil.escapeJavaString(attrValue.toCharArray()) );
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ out.write(" } );"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ });
+ }
+ out.write(NL);
+ out.write(" public void generate(final JET2Context context, final JET2Writer __out) {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" JET2Writer out = __out;"); //$NON-NLS-1$
+ out.write(NL);
+ cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
+ public boolean visit(TextElement text) {
+ if(text.getText().length > 0) {
+ String[] strings = textConstants(text, nlConstantName);
+ for(int i = 0; i < strings.length; i++) {
+
+ out.write(" out.write("); //$NON-NLS-1$
+ out.write(strings[i]);
+ out.write("); "); //$NON-NLS-1$
+ if(strings[i].startsWith("\"")) { //$NON-NLS-1$
+ out.write(" //$NON-NLS-1$"); //$NON-NLS-1$
+ }
+ out.write(" "); //$NON-NLS-1$
+ out.write(NL);
+
+ }
+ }
+ return true;
+ }
+ public boolean visit(JavaScriptlet scriptlet) {
+
+ out.write(" "); //$NON-NLS-1$
+ out.write( scriptlet.getJavaContent() );
+ out.write(NL);
+
+ return true;
+ }
+ public boolean visit(JavaExpression expr) {
+
+ out.write(" out.write("); //$NON-NLS-1$
+ out.write( expr.getJavaContent() );
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
+
+ return true;
+ }
+ public boolean visit(XMLBodyElement e) {
+
+ out.write(" RuntimeTagElement "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(" = context.getTagFactory().createRuntimeTag(_jetns_"); //$NON-NLS-1$
+ out.write( e.getNSPrefix() );
+ out.write(", \""); //$NON-NLS-1$
+ out.write( e.getTagNCName() );
+ out.write("\", \""); //$NON-NLS-1$
+ out.write( e.getName() );
+ out.write("\", _td_"); //$NON-NLS-1$
+ out.write( tagInfoVar(e) );
+ out.write("); //$NON-NLS-1$ //$NON-NLS-2$"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(".setRuntimeParent("); //$NON-NLS-1$
+ out.write( parentTagVar(e) );
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(".setTagInfo(_td_"); //$NON-NLS-1$
+ out.write( tagInfoVar(e) );
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(".doStart(context, out);"); //$NON-NLS-1$
+ out.write(NL);
+ if(requiresOwnWriter(e)) {
+ out.write(" JET2Writer "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write("_saved_out = out;"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ out.write(" while ("); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(".okToProcessBody()) {"); //$NON-NLS-1$
+ out.write(NL);
+ if(requiresOwnWriter(e)) {
+ out.write(" out = out.newNestedContentWriter();"); //$NON-NLS-1$
+ out.write(NL);
+ }
+
+ in();
+ return true;
+ }
+ public void endVisit(XMLBodyElement e) {
+ out();
+
+ out.write(" "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(".handleBodyContent(out);"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ if(requiresOwnWriter(e)) {
+ out.write(" out = "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write("_saved_out;"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ out.write(" "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(".doEnd();"); //$NON-NLS-1$
+ out.write(NL);
+
+
+ }
+ public boolean visit(XMLEmptyElement e) {
+
+ out.write(" RuntimeTagElement "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(" = context.getTagFactory().createRuntimeTag(_jetns_"); //$NON-NLS-1$
+ out.write( e.getNSPrefix() );
+ out.write(", \""); //$NON-NLS-1$
+ out.write( e.getTagNCName() );
+ out.write("\", \""); //$NON-NLS-1$
+ out.write( e.getName() );
+ out.write("\", _td_"); //$NON-NLS-1$
+ out.write( tagInfoVar(e) );
+ out.write("); //$NON-NLS-1$ //$NON-NLS-2$"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(".setRuntimeParent("); //$NON-NLS-1$
+ out.write( parentTagVar(e) );
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(".setTagInfo(_td_"); //$NON-NLS-1$
+ out.write( tagInfoVar(e) );
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(".doStart(context, out);"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write( tagVar(e) );
+ out.write(".doEnd();"); //$NON-NLS-1$
+ out.write(NL);
+
+ return true;
+ }
+ });
+
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("}"); //$NON-NLS-1$
+ out.write(NL);
+ }
+}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/Activator.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/Activator.java
index da0412d..0db1e31 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/Activator.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/Activator.java
@@ -1,5 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -58,4 +70,13 @@ public class Activator extends AbstractUIPlugin {
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
+
+ /**
+ * Log an exception in Eclipse's logger with this plugin ID
+ * @param e
+ */
+ public static void log(Exception e) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e);
+ getDefault().getLog().log(status);
+ }
}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETDocumentReader.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETDocumentReader.java
index 8e66197..49388d9 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETDocumentReader.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETDocumentReader.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor;
import org.eclipse.jface.text.BadLocationException;
@@ -8,7 +18,7 @@ import org.eclipse.jface.text.IDocument;
*
* To change the template for this generated type comment go to Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code
* and Comments
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class JETDocumentReader {
public static final int EOF = -1;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditor.java
index f44c389..e7023e1 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditor.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor;
import org.eclipse.core.resources.IMarker;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditorHelper.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditorHelper.java
index 8204c41..c67a185 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditorHelper.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditorHelper.java
@@ -1,5 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor;
+import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -21,233 +32,238 @@ 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.JET2TemplateLoader;
import org.eclipse.jet.compiler.CompileOptionsManager;
-import org.eclipse.jet.compiler.DefaultJET2ASTVisitor;
-import org.eclipse.jet.compiler.JET2ASTElement;
-import org.eclipse.jet.compiler.JET2CompilationUnit;
-import org.eclipse.jet.compiler.JET2Compiler;
-import org.eclipse.jet.compiler.JET2Declaration;
-import org.eclipse.jet.compiler.JET2Expression;
-import org.eclipse.jet.compiler.JET2Scriptlet;
-import org.eclipse.jet.compiler.Problem;
-import org.eclipse.jet.internal.compiler.MethodBodyCreator;
-import org.eclipse.jet.internal.compiler.templates.CodeGenTemplateLoader;
-import org.eclipse.jet.internal.editor.gen.JETEditorJET2JavaGenerator;
-import org.eclipse.jet.internal.parser.ParseProblemSeverity;
-import org.eclipse.jet.transform.TransformContextExtender;
+import org.eclipse.jet.core.compiler.JETCompilerOptions;
+import org.eclipse.jet.core.parser.ProblemSeverity;
+import org.eclipse.jet.core.parser.ast.JETASTElement;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
+import org.eclipse.jet.core.parser.ast.JavaDeclaration;
+import org.eclipse.jet.core.parser.ast.JavaExpression;
+import org.eclipse.jet.core.parser.ast.JavaScriptlet;
+import org.eclipse.jet.core.parser.ast.Problem;
import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Position;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IFileEditorInput;
+/**
+ * Helper class for code completion and JET compilation unit processing purposespurposes
+ * @author Joel
+ *
+ */
public class JETEditorHelper {
- public static class JETEditorMethodBodyCreator extends MethodBodyCreator {
-
- public void setStartOffset(int offset) {
- startOffset = offset;
- }
-
- public void visit(JET2Expression expression) {
- Position position = new Position(getBuffer().length());
- generatedBodyMappingPositions.put(expression, position);
- super.visit(expression);
- String writtenContent = getBuffer().substring(position.offset);
- int javaContentIndex = writtenContent.indexOf(expression.getJavaContent());
- position.setLength(getBuffer().length() - position.offset);
- position.setOffset(startOffset + position.offset + javaContentIndex);
- }
-
- public void visit(JET2Scriptlet scriptlet) {
- Position position = new Position(getBuffer().length());
- generatedBodyMappingPositions.put(scriptlet, position);
- super.visit(scriptlet);
- String writtenContent = getBuffer().substring(position.offset);
- int javaContentIndex = writtenContent.indexOf(scriptlet.getJavaContent());
- position.setLength(getBuffer().length() - position.offset);
- position.setOffset(startOffset + position.offset + javaContentIndex);
- }
-
- private Map generatedBodyMappingPositions;
-
- private int startOffset;
-
- public JETEditorMethodBodyCreator(JET2TemplateLoader templateLoader, Map mappingPositions) {
- super(templateLoader);
- startOffset = 0;
- generatedBodyMappingPositions = mappingPositions;
- }
- }
-
+ /**
+ * Problem requestor for java expressions of the JET template
+ * @author Joel
+ *
+ */
private static final class JETJavaContentProblemRequestor implements IProblemRequestor {
+ /**
+ * The JET problems computed from the java problems
+ */
private List problems;
+ /**
+ * The problems collected from the compiled java source
+ */
private List javaProblems;
- private IDocument javaDocument;
-
+ /**
+ * The jet source
+ */
private IDocument jetDocument;
private Map mappingPositions;
- private JETJavaContentProblemRequestor(List problems, Map mappings, IDocument javaDocument, IDocument jetDocument) {
+ private JETJavaContentProblemRequestor(List problems, Map mappings, IDocument jetDocument) {
this.problems = problems;
mappingPositions = mappings;
javaProblems = new ArrayList();
- this.javaDocument = javaDocument;
this.jetDocument = jetDocument;
}
+ /**
+ * @return
+ */
public List getProblems() {
return problems;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.IProblemRequestor#acceptProblem(org.eclipse.jdt.core.compiler.IProblem)
+ */
public void acceptProblem(IProblem problem) {
javaProblems.add(problem);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.IProblemRequestor#beginReporting()
+ */
public void beginReporting() {
javaProblems.clear();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.IProblemRequestor#endReporting()
+ */
public void endReporting() {
Problem problem;
- for (Iterator iter = javaProblems.iterator(); iter.hasNext(); problems.add(problem)) {
+ // walk through the java problems collected from the generated java source and create the
+ // corresponding JET problems in the JET source using the position mappings
+ for (Iterator iter = javaProblems.iterator(); iter.hasNext(); ) {
IProblem javaProblem = (IProblem) iter.next();
- int javaOffset = javaProblem.getSourceStart();
- int problemLength = (javaProblem.getSourceEnd() - javaProblem.getSourceStart()) + 1;
- JET2ASTElement astElement = getElementForJavaOffset(javaOffset);
+
+ int javaProblemOffset = javaProblem.getSourceStart();
+ int problemLength = (javaProblem.getSourceEnd() - javaProblemOffset) + 1;
+
+ // Retrieve the corresponding JET AST Element and its position in the JET source
+ JETASTElement astElement = getElementForJavaOffset(javaProblemOffset);
Position pos = (Position) mappingPositions.get(astElement);
- int javaStart = pos.getOffset();
- int jetOffset = JETEditorHelper.getASTElementContentStart(astElement, jetDocument) + (javaOffset - javaStart);
- problem = new Problem("", javaProblem.isWarning() ? ParseProblemSeverity.WARNING : ParseProblemSeverity.ERROR,
- -1, javaProblem.getMessage(), javaProblem.getArguments(), jetOffset, jetOffset + problemLength, -1, -1);
- }
+ // jetOffset =
+ // start position of the AST element in JET Code +
+ // offset till the position delimited by the javaProblemOffset
+ // The offset till the position delimited by the javaProblemOffset
+ // depends on the starting offset of the java content in the JET AST element.
+ // This is due to the fact that the JET AST element first position does not represents the starting offset of
+ // offset of its java content.
+
+ int astElementJavaContentStart = pos == null ? -1 : pos.getOffset();
+ int jetOffset = pos == null ? 0 : JETEditorHelper.getASTElementContentStart(astElement, jetDocument) + (javaProblemOffset - astElementJavaContentStart);
+
+ // Create the problem at the specified location
+ URI baseLocation = URI.create("");
+ problem = new Problem(baseLocation,
+ "",
+ javaProblem.isWarning() ? ProblemSeverity.WARNING : ProblemSeverity.ERROR,
+ -1,
+ javaProblem.getMessage(),
+ javaProblem.getArguments(),
+ jetOffset,
+ jetOffset + problemLength,
+ -1,
+ -1);
+ // add the problem to the problems list
+ problems.add(problem);
+ }
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.core.IProblemRequestor#isActive()
+ */
public boolean isActive() {
return true;
}
- private JET2ASTElement getElementForJavaOffset(int javaOffset) {
+ /**
+ * Find the JET AST element that matches the given java offset in
+ * the generated java template source
+ * @param javaOffset
+ * @return
+ */
+ private JETASTElement getElementForJavaOffset(int javaOffset) {
for (Iterator iterator = mappingPositions.keySet().iterator(); iterator.hasNext();) {
- JET2ASTElement element = (JET2ASTElement) iterator.next();
+ JETASTElement element = (JETASTElement) iterator.next();
Position pos = (Position) mappingPositions.get(element);
if (pos.getOffset() <= javaOffset && javaOffset < pos.getOffset() + pos.getLength())
return element;
}
-
return null;
}
- }
-
- public static int getASTElementContentStart(JET2ASTElement astElement, IDocument jetDocument) {
+ } // End class JETJavaContentProblemRequestor
+
+ /**
+ * @param astElement
+ * @param jetDocument
+ * @return
+ */
+ public static int getASTElementContentStart(JETASTElement astElement, IDocument jetDocument) {
int jetStart = astElement.getStart();
- if (astElement instanceof JET2Declaration)
+ if (astElement instanceof JavaDeclaration)
jetStart += 3;
- if ((astElement instanceof JET2Expression) || (astElement instanceof JET2Scriptlet))
+ if ((astElement instanceof JavaExpression) || (astElement instanceof JavaScriptlet))
try {
String jetSnippet = jetDocument.get(jetStart, astElement.getEnd() - jetStart);
- String javaContent = (astElement instanceof JET2Expression) ? ((JET2Expression) astElement).getJavaContent()
- : ((JET2Scriptlet) astElement).getJavaContent();
+ String javaContent = (astElement instanceof JavaExpression) ? ((JavaExpression) astElement).getJavaContent()
+ : ((JavaScriptlet) astElement).getJavaContent();
int idx = jetSnippet.indexOf(javaContent);
jetStart += idx;
} catch (BadLocationException e) {
- e.printStackTrace();
+ Activator.log(e);
}
return jetStart;
}
-
- public static IDocument computeJavaSource(JET2CompilationUnit cu, Map mappingPositions) {
- HashMap arguments = new HashMap();
- arguments.put("cu", cu);
- arguments.put("org.eclipse.jet.storeJavaMappingPositions", mappingPositions);
- JET2Context context = new JET2Context(null, arguments);
- org.eclipse.jet.JET2TemplateLoader templateLoader = new CodeGenTemplateLoader();
- TransformContextExtender.getInstance(context).setLoader(templateLoader);
- JETEditorJET2JavaGenerator generator = new JETEditorJET2JavaGenerator();
- BodyContentWriter out = new BodyContentWriter();
- generator.generate(context, out);
- return out.getDocument();
- }
-
- 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());
+
+ public static boolean checkOffsetPositions(String javaSource, String jetSource, int jetOffset, int javaOffset, int checkDepth) {
+ boolean result = false;
+
+ String javaCheckString = javaSource.substring(javaOffset, javaOffset + checkDepth);
+ String jetCheckString = jetSource.substring(jetOffset, jetOffset + checkDepth);
+ result = javaCheckString.compareTo(jetCheckString) == 0;
+ if (!result) {
+ System.err.println("position matching error");
+ System.err.println("JET Check String : " + jetCheckString);
+ System.err.println("Java Check String : " + javaCheckString);
}
-
- return declarationsSource.toString();
+ return result;
}
- public static String getPreviousGeneratedJavaSource(IJavaProject javaProject, JET2CompilationUnit cu,
- JET2ASTElement bodyElement) {
- org.eclipse.jet.JET2TemplateLoader templateLoader = new CodeGenTemplateLoader();
- MethodBodyCreator generatedBody = new MethodBodyCreator(templateLoader);
- List sortedPrevElements = new ArrayList();
- for (JET2ASTElement prevASTElement = bodyElement.getPrevElement(); prevASTElement != null; prevASTElement = prevASTElement
- .getPrevElement())
- sortedPrevElements.add(0, prevASTElement);
-
- JET2ASTElement prevElement;
- for (Iterator iterator = sortedPrevElements.iterator(); iterator.hasNext(); prevElement.accept(generatedBody))
- prevElement = (JET2ASTElement) iterator.next();
-
- return generatedBody.getBuffer();
- }
-
- public static List evaluateProblems(IJavaProject javaProject, JET2CompilationUnit cu, IDocument jetDocument) {
+ /**
+ * @param jetEditor
+ * @param cu
+ * @param jetDocument
+ * @return
+ */
+ public static List evaluateProblems(JETTextEditor jetEditor, IDocument jetDocument) {
+ JETCompilationUnit cu = jetEditor.requestCompilationUnit();
String packageName = cu.getOutputJavaPackage();
String className = cu.getOutputJavaClassName();
List problems = new ArrayList();
if (packageName == null || className == null)
return problems;
Map mappingPositions = new HashMap();
- IDocument javaDocument = computeJavaSource(cu, mappingPositions);
- JETJavaContentProblemRequestor problemRequestor = new JETJavaContentProblemRequestor(problems, mappingPositions,
- javaDocument, jetDocument);
+ String javaSource = jetEditor.compilationHelper().getJavaCode(cu, mappingPositions);
+ JETJavaContentProblemRequestor problemRequestor =
+ new JETJavaContentProblemRequestor(problems,
+ mappingPositions,
+ jetDocument);
try {
ICompilationUnit compilationUnit = null;
+ IJavaProject javaProject = jetEditor.getJavaProject();
IPackageFragmentRoot roots[] = javaProject.getPackageFragmentRoots();
for (int i = 0; i < roots.length;) {
IPackageFragmentRoot root = roots[i];
IPackageFragment packageFragment = root.getPackageFragment(packageName);
if (packageFragment == null || !packageFragment.exists())
packageFragment = root.createPackageFragment(packageName, true, new NullProgressMonitor());
- compilationUnit = packageFragment.createCompilationUnit((new StringBuilder(String.valueOf(className))).append(
- ".java").toString(), javaDocument.get(), true, new NullProgressMonitor());
+ compilationUnit = packageFragment.createCompilationUnit(
+ (new StringBuilder(String.valueOf(className))).append(".java").toString(),
+ javaSource,
+ true,
+ new NullProgressMonitor());
break;
}
-
- org.eclipse.jdt.core.WorkingCopyOwner owner = new WorkingCopyOwner() {
- };
+ WorkingCopyOwner owner = new WorkingCopyOwner() {};
ICompilationUnit copy = compilationUnit.getWorkingCopy(owner, problemRequestor, null);
copy.reconcile(0, true, owner, null);
} catch (JavaModelException e) {
- e.printStackTrace();
+ Activator.log(e);
}
return problems;
}
- public static CompletionProposalCollector collect(IJavaProject javaProject, JET2CompilationUnit cu,
+ /**
+ * @param javaProject
+ * @param cu
+ * @param codeSnippet
+ * @param offset
+ * @return
+ */
+ public static CompletionProposalCollector collect(IJavaProject javaProject, JETCompilationUnit cu,
String codeSnippet, int offset) {
IEvaluationContext context;
CompletionProposalCollector proposalCollector;
@@ -265,7 +281,7 @@ public class JETEditorHelper {
if (packageName == null) {
Map options = CompileOptionsManager.getOptions(javaProject.getProject());
if (options.isEmpty())
- options = JET2Compiler.getDefaultCompilerOptions();
+ options = JETCompilerOptions.getDefaultCompilerOptions();
packageName = (String) options.get("org.eclipse.jet.compiledTemplatePackage");
}
context.setPackageName(packageName);
@@ -275,31 +291,36 @@ public class JETEditorHelper {
context.codeComplete(codeSnippet, offset, proposalCollector);
return proposalCollector;
} catch (JavaModelException e) {
- // TODO : log this exception
- e.printStackTrace();
+ Activator.log(e);
}
return null;
}
- public static IJavaCompletionProposal[] getJavaCompletionProposal(JETTextEditor editor, ITextViewer viewer,
+ /**
+ * @param editor
+ * @param viewer
+ * @param completionOffset
+ * @return
+ */
+ public static IJavaCompletionProposal[] getJavaCompletionProposal(JETTextEditor jetEditor, ITextViewer viewer,
int completionOffset) {
IJavaProject javaProject;
String packageName;
String className;
Map mappingPositions;
IDocument javaDocument;
- JET2CompilationUnit cu = editor.requestCompilationUnit();
- javaProject = editor.getJETJavaProject();
+ JETCompilationUnit cu = jetEditor.requestCompilationUnit();
+ javaProject = jetEditor.getJavaProject();
packageName = cu.getOutputJavaPackage();
className = cu.getOutputJavaClassName();
if (packageName == null) {
Map options = CompileOptionsManager.getOptions(javaProject.getProject());
if (options.isEmpty())
- options = JET2Compiler.getDefaultCompilerOptions();
+ options = JETCompilerOptions.getDefaultCompilerOptions();
packageName = (String) options.get("org.eclipse.jet.compiledTemplatePackage");
}
- if (className == null && (editor.getEditorInput() instanceof IFileEditorInput)) {
- IFile file = ((IFileEditorInput) editor.getEditorInput()).getFile();
+ if (className == null && (jetEditor.getEditorInput() instanceof IFileEditorInput)) {
+ IFile file = ((IFileEditorInput) jetEditor.getEditorInput()).getFile();
String inputName = file.getFullPath().removeFileExtension().lastSegment();
String baseClassName = makeJavaClassName(inputName);
className = baseClassName;
@@ -307,7 +328,7 @@ public class JETEditorHelper {
if (packageName == null || className == null)
return new IJavaCompletionProposal[0];
mappingPositions = new HashMap();
- javaDocument = computeJavaSource(cu, mappingPositions);
+ javaDocument = new Document(jetEditor.compilationHelper().getJavaCode(cu, mappingPositions));
IJavaCompletionProposal results[];
ICompilationUnit compilationUnit = null;
try {
@@ -323,7 +344,7 @@ public class JETEditorHelper {
}
CompletionProposalCollector proposalCollector = new CompletionProposalCollector(compilationUnit);
- JET2ASTElement astElement = editor.getASTElement(completionOffset);
+ JETASTElement astElement = jetEditor.getASTElement(completionOffset);
Position javaPosition = (Position) mappingPositions.get(astElement);
int jetStart = getASTElementContentStart(astElement, viewer.getDocument());
int javaStart = javaPosition.getOffset();
@@ -358,13 +379,20 @@ public class JETEditorHelper {
adjustResults(results, completionOffset);
return results;
} catch (JavaModelException e) {
- // TODO log this exception
- e.printStackTrace();
+ Activator.log(e);
}
return new IJavaCompletionProposal[0];
}
- public static IJavaCompletionProposal[] getJavaCompletionProposal(IJavaProject javaProject, JET2CompilationUnit cu,
+ /**
+ * @param javaProject
+ * @param cu
+ * @param codeSnippet
+ * @param viewer
+ * @param offset
+ * @return
+ */
+ public static IJavaCompletionProposal[] getJavaCompletionProposal(IJavaProject javaProject, JETCompilationUnit cu,
String codeSnippet, ITextViewer viewer, int offset) {
CompletionProposalCollector proposalCollector = collect(javaProject, cu, codeSnippet, offset);
if (proposalCollector != null) {
@@ -388,7 +416,6 @@ public class JETEditorHelper {
break;
}
}
-
sortedJavaProposals.add(index, unsortedJavaProposal);
}
@@ -400,15 +427,22 @@ public class JETEditorHelper {
}
}
- public static void adjustResults(IJavaCompletionProposal results[], int offset) {
+ /**
+ * @param results
+ * @param offset
+ */
+ 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);
}
-
}
+ /**
+ * @param name
+ * @return
+ */
public static String makeJavaClassName(String name) {
StringBuffer result = new StringBuffer("_jet_");
for (int i = 0; i < name.length(); i++) {
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETSourceViewer.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETSourceViewer.java
index 58be6ef..0101961 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETSourceViewer.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETSourceViewer.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor;
import org.eclipse.jface.preference.IPreferenceStore;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETTextEditor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETTextEditor.java
index 646315d..4a554a0 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETTextEditor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETTextEditor.java
@@ -1,6 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor;
-import java.io.ByteArrayInputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@@ -10,28 +19,25 @@ import java.util.Iterator;
import java.util.Map;
import java.util.ResourceBundle;
-import org.eclipse.core.resources.IEncodedStorage;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jet.JET2Platform;
-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.core.parser.ast.Comment;
+import org.eclipse.jet.core.parser.ast.JETASTElement;
+import org.eclipse.jet.core.parser.ast.JETASTVisitor;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
+import org.eclipse.jet.core.parser.ast.JETDirective;
+import org.eclipse.jet.core.parser.ast.JavaDeclaration;
+import org.eclipse.jet.core.parser.ast.JavaExpression;
+import org.eclipse.jet.core.parser.ast.JavaScriptlet;
+import org.eclipse.jet.core.parser.ast.TextElement;
+import org.eclipse.jet.core.parser.ast.XMLBodyElement;
+import org.eclipse.jet.core.parser.ast.XMLBodyElementEnd;
+import org.eclipse.jet.core.parser.ast.XMLEmptyElement;
+import org.eclipse.jet.internal.compiler.CompilationHelper;
import org.eclipse.jet.internal.editor.configuration.JETDocumentProvider;
import org.eclipse.jet.internal.editor.configuration.JETEditorPreferenceConstants;
import org.eclipse.jet.internal.editor.configuration.JETSourceViewerConfiguration;
@@ -39,11 +45,6 @@ import org.eclipse.jet.internal.editor.configuration.JETTokenStyleManager;
import org.eclipse.jet.internal.editor.configuration.delegates.IJETDefaultTextColorerDelegate;
import org.eclipse.jet.internal.editor.outline.JETOutlinePage;
import org.eclipse.jet.internal.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.action.IMenuManager;
import org.eclipse.jface.internal.text.html.HTMLTextPresenter;
@@ -68,7 +69,6 @@ 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.IStorageEditorInput;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.editors.text.IEncodingSupport;
import org.eclipse.ui.editors.text.TextEditor;
@@ -76,6 +76,10 @@ import org.eclipse.ui.texteditor.ContentAssistAction;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.osgi.framework.Bundle;
+/**
+ * The editor for JET templates files
+ * @author Joel
+ */
public class JETTextEditor extends TextEditor {
private JETTokenStyleManager tokenStyleManager;
@@ -88,20 +92,21 @@ public class JETTextEditor extends TextEditor {
private IContentOutlinePage outlinePage;
- private JET2CompilationUnit cUnit;
+ private JETCompilationUnit cUnit;
- private IJavaProject javaProject;
+ private IProject project;
private Map positions;
- private Map registeredPrefixMap;
-
private boolean cUnitInvalidated;
private ArrayList defaultContentColorerDelegates;
- private IJETDefaultTextColorerDelegate currentDelegate;
+ private IJETDefaultTextColorerDelegate currentDelegate;
+ /**
+ * Creates a new JET editor
+ */
public JETTextEditor() {
positions = Collections.EMPTY_MAP;
IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
@@ -113,41 +118,62 @@ public class JETTextEditor extends TextEditor {
setDocumentProvider(new JETDocumentProvider(this));
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.editors.text.TextEditor#dispose()
+ */
public void dispose() {
tokenStyleManager.dispose();
super.dispose();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+ */
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ if (input instanceof IFileEditorInput)
+ project = ((IFileEditorInput) input).getFile().getProject();
super.init(site, input);
- if (input instanceof IFileEditorInput) {
- IFile jetTemplateFile = ((IFileEditorInput) input).getFile();
- javaProject = JavaCore.create(jetTemplateFile.getProject());
- }
initDefaultContentColorerDelegetes();
if (!defaultContentColorerDelegates.isEmpty())
currentDelegate = (IJETDefaultTextColorerDelegate) defaultContentColorerDelegates.get(0);
}
+ /**
+ * Set the content colorer delegate (used for syntax coloring of non JET text) to use.
+ * @param delegate
+ */
public void setCurrentColorerDelegate(IJETDefaultTextColorerDelegate delegate) {
currentDelegate = delegate;
+ // notify the damager repairers so that they recompute the partitions and the tokens to colorize
partitionScanner.updateJETTextContentDamagerRepairer();
- if (isDirty())
+ // reset the text display
+ if (isDirty())
getSourceViewer().getDocument().set(getSourceViewer().getDocument().get());
else
setInput(getEditorInput());
}
+ /**
+ * Returns the content colorer delegate (used for syntax coloring of non JET text) in use.
+ * @return the content colorer delegate
+ */
public IJETDefaultTextColorerDelegate getCurrentColorerDelegate() {
return currentDelegate;
}
+ /**
+ * Returns the list of all the available (registered) content colorer delegates.
+ * @return
+ */
public IJETDefaultTextColorerDelegate[] getColorerDelegates() {
IJETDefaultTextColorerDelegate results[] = new IJETDefaultTextColorerDelegate[defaultContentColorerDelegates.size()];
defaultContentColorerDelegates.toArray(results);
return results;
}
+ /**
+ * Compute the list of the registered content colorer delegates.
+ */
private void initDefaultContentColorerDelegetes() {
defaultContentColorerDelegates = new ArrayList();
IExtensionRegistry registry = Platform.getExtensionRegistry();
@@ -165,9 +191,9 @@ public class JETTextEditor extends TextEditor {
try {
ctorWithTextEditor = clazz.getConstructor(argTypes);
} catch (SecurityException e) {
- e.printStackTrace();
+ Activator.log(e);
} catch (NoSuchMethodException e) {
- e.printStackTrace();
+ Activator.log(e);
}
if (ctorWithTextEditor != null)
delegate = (IJETDefaultTextColorerDelegate) ctorWithTextEditor.newInstance(new Object[] { this });
@@ -175,20 +201,23 @@ public class JETTextEditor extends TextEditor {
delegate = (IJETDefaultTextColorerDelegate) clazz.newInstance();
defaultContentColorerDelegates.add(delegate);
} catch (ClassNotFoundException e) {
- e.printStackTrace();
+ Activator.log(e);
} catch (InstantiationException e) {
- e.printStackTrace();
+ Activator.log(e);
} catch (IllegalAccessException e) {
- e.printStackTrace();
+ Activator.log(e);
} catch (IllegalArgumentException e) {
- e.printStackTrace();
+ Activator.log(e);
} catch (InvocationTargetException e) {
- e.printStackTrace();
+ Activator.log(e);
}
}
}
+ /* (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());
@@ -207,10 +236,18 @@ public class JETTextEditor extends TextEditor {
return sourceViewer;
}
+ /**
+ * Return the editor's source viewer. This method exist to make this viewer accessible to other classes.
+ * @return the editor's source viewer
+ */
public ISourceViewer getEditorSourceViewer() {
return sourceViewer;
}
+ /**
+ * Returns the editor's preference store. This method exist to make the preference store accessible to other classes.
+ * @return the editor's preference store
+ */
public IPreferenceStore getEditorPreferenceStore() {
return super.getPreferenceStore();
}
@@ -223,6 +260,9 @@ public class JETTextEditor extends TextEditor {
return tokenStyleManager;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.texteditor.StatusTextEditor#handleEditorInputChanged()
+ */
protected void handleEditorInputChanged() {
super.handleEditorInputChanged();
handleDocumentChange(null);
@@ -237,40 +277,27 @@ public class JETTextEditor extends TextEditor {
public boolean isCUnitInvalidated() {
return cUnitInvalidated;
}
+
+ public CompilationHelper compilationHelper() {
+ CompilationHelper jetCompilationHelper = new CompilationHelper(project);
+ return jetCompilationHelper;
+ }
- public JET2CompilationUnit requestCompilationUnit() {
+ /**
+ * Compute and retrun the compilation unit of this document
+ * @return the computed (or recomputed) compilation unit for this template
+ */
+ public JETCompilationUnit requestCompilationUnit() {
if (cUnit == null || cUnitInvalidated) {
IEditorInput editorInput = getEditorInput();
- String charset = "UTF-8";
- java.io.InputStream is = null;
- if (sourceViewer == null) {
- if (editorInput instanceof IStorageEditorInput)
- try {
- IStorage storage = ((IStorageEditorInput) editorInput).getStorage();
- is = storage.getContents();
- if (storage instanceof IEncodedStorage)
- charset = ((IEncodedStorage) storage).getCharset();
- } catch (CoreException e) {
- e.printStackTrace();
- }
+ if (sourceViewer == null) { // sourceViewer is null ... we can parse from the file directly
+ String templatePath = editorInput.getName();
+ if (editorInput instanceof IFileEditorInput)
+ templatePath = ((IFileEditorInput)editorInput).getFile().getProjectRelativePath().toString();
+ cUnit = compilationHelper().getAST(templatePath);
} else {
- is = new ByteArrayInputStream(sourceViewer.getDocument().get().getBytes());
- }
- if (is == null)
- is = new ByteArrayInputStream("".getBytes());
- if (cUnit == null) {
- 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 ? Collections.EMPTY_MAP : getPredefinedPrefixMap(descriptor));
- }
- cUnit.setPredefinedTagLibraries(predefinedLibraryMap);
+ cUnit = compilationHelper().getASTFromSource(sourceViewer.getDocument().get());
}
- cUnit.parse(is, charset);
PositionsCollector collector = new PositionsCollector();
cUnit.accept(collector);
positions = collector.getPositions();
@@ -279,47 +306,22 @@ public class JETTextEditor extends TextEditor {
return cUnit;
}
- public JET2ASTElement getASTElement(int offset) {
+ public JETASTElement getASTElement(int offset) {
requestCompilationUnit();
return getCachedASTElement(offset);
}
- public JET2ASTElement getCachedASTElement(int offset) {
+ public JETASTElement getCachedASTElement(int offset) {
for (Iterator iterator = positions.keySet().iterator(); iterator.hasNext();) {
Position pos = (Position) iterator.next();
if (pos.offset <= offset && pos.length + pos.offset > offset)
- return (JET2ASTElement) positions.get(pos);
+ return (JETASTElement) positions.get(pos);
}
-
return null;
}
- public IJavaProject getJETJavaProject() {
- return javaProject;
- }
-
- private Map getRegisteredPrefixMap() {
- if (registeredPrefixMap == null) {
- String tagLibIds[] = TagLibraryManager.getInstance().getKnownLibraryIds();
- registeredPrefixMap = new HashMap(tagLibIds.length);
- for (int i = 0; i < tagLibIds.length; i++) {
- String id = tagLibIds[i];
- TagLibrary tagLib = TagLibraryManager.getInstance().getTagLibrary(id, true);
- registeredPrefixMap.put(tagLib.getDefaultPrefix(), tagLib.getLibraryId());
- }
-
- }
- return registeredPrefixMap;
- }
-
- private Map getPredefinedPrefixMap(IJETBundleDescriptor descriptor) {
- TagLibraryReference tlRefs[] = descriptor.getTagLibraryReferences();
- 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;
+ public IJavaProject getJavaProject() {
+ return JavaCore.create(project);
}
protected void createActions() {
@@ -371,8 +373,8 @@ public class JETTextEditor extends TextEditor {
protected void handleContentOutlineSelection(ISelection selection) {
IStructuredSelection ssel = (IStructuredSelection) selection;
Object firstElement = ssel.getFirstElement();
- if (firstElement instanceof JET2ASTElement) {
- JET2ASTElement astElement = (JET2ASTElement) firstElement;
+ if (firstElement instanceof JETASTElement) {
+ JETASTElement astElement = (JETASTElement) firstElement;
int start = astElement.getStart();
int end = astElement.getEnd();
int length = end - start;
@@ -388,14 +390,7 @@ public class JETTextEditor extends TextEditor {
}
}
- public void createContextMenuFor(TreeViewer treeviewer) {
- }
-
- public boolean isActive(IJETDefaultTextColorerDelegate candidate) {
- return true;
- }
-
- private static class PositionsCollector extends DefaultJET2ASTVisitor {
+ private static class PositionsCollector extends JETASTVisitor {
private Map positions;
private PositionsCollector() {
@@ -406,43 +401,44 @@ public class JETTextEditor extends TextEditor {
return positions;
}
- public void visit(JET2Declaration declaration) {
- matchOffset(declaration);
+ public boolean visit(JavaDeclaration declaration) {
+ return matchOffset(declaration);
}
- public void visit(JET2Directive directive) {
- matchOffset(directive);
+ public boolean visit(JETDirective directive) {
+ return matchOffset(directive);
}
- public void visit(JET2Expression expression) {
- matchOffset(expression);
+ public boolean visit(JavaExpression expression) {
+ return matchOffset(expression);
}
- public void visit(JET2Scriptlet scriptlet) {
- matchOffset(scriptlet);
+ public boolean visit(JavaScriptlet scriptlet) {
+ return matchOffset(scriptlet);
}
- public void visit(XMLEmptyElement xmlEmptyElement) {
- matchOffset(xmlEmptyElement);
+ public boolean visit(XMLEmptyElement xmlEmptyElement) {
+ return matchOffset(xmlEmptyElement);
}
- public void visit(XMLBodyElement xmlBodyElement) {
- matchOffset(xmlBodyElement);
+ public boolean visit(XMLBodyElement xmlBodyElement) {
+ return matchOffset(xmlBodyElement);
}
- public void visit(XMLBodyElementEnd xmlBodyElementEnd) {
- matchOffset(xmlBodyElementEnd);
+ public boolean visit(XMLBodyElementEnd xmlBodyElementEnd) {
+ return matchOffset(xmlBodyElementEnd);
}
- public void visit(Comment comment) {
- matchOffset(comment);
+ public boolean visit(Comment comment) {
+ return matchOffset(comment);
}
- public void matchOffset(JET2ASTElement astElement) {
+ public boolean matchOffset(JETASTElement astElement) {
int start = astElement.getStart();
int end = astElement.getEnd();
int length = end - start;
positions.put(new Position(start, length), astElement);
+ return true;
}
}
}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETTextPreviewViewer.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETTextPreviewViewer.java
index c056d4d..b36e0d5 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETTextPreviewViewer.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETTextPreviewViewer.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor;
import java.util.ArrayList;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/actions/SetContentColorerAction.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/actions/SetContentColorerAction.java
index 5a1cbd4..45f0470 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/actions/SetContentColorerAction.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/actions/SetContentColorerAction.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.actions;
import org.eclipse.jet.internal.editor.JETTextEditor;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETAnnotationHover.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETAnnotationHover.java
index 7c01be6..8980eb3 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETAnnotationHover.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETAnnotationHover.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.annotations;
import java.util.*;
@@ -6,9 +16,6 @@ import org.eclipse.jface.text.source.*;
public class JETAnnotationHover implements IAnnotationHover {
- public JETAnnotationHover() {
- }
-
/**
* Returns the distance to the ruler line.
* @param position Position
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETAnnotationModel.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETAnnotationModel.java
index 228eb83..b7f347a 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETAnnotationModel.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETAnnotationModel.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.annotations;
import org.eclipse.core.resources.IMarker;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETProblemAnnotation.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETProblemAnnotation.java
index 4a2c4ba..0f7ad2a 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETProblemAnnotation.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/annotations/JETProblemAnnotation.java
@@ -1,22 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.annotations;
-import org.eclipse.jet.compiler.Problem;
-import org.eclipse.jet.internal.parser.ParseProblemSeverity;
+import org.eclipse.jet.core.parser.ProblemSeverity;
+import org.eclipse.jet.core.parser.ast.Problem;
import org.eclipse.jface.text.source.Annotation;
public class JETProblemAnnotation extends Annotation {
- public static final String ERROR_ANNOTATION_TYPE = "org.eclipse.jet.internal.editor.error";
+ public static final String ERROR_ANNOTATION_TYPE = "org.eclipse.jet.editor.error";
- public static final String WARNING_ANNOTATION_TYPE = "org.eclipse.jet.internal.editor.warning";
+ public static final String WARNING_ANNOTATION_TYPE = "org.eclipse.jet.editor.warning";
- public static final String INFO_ANNOTATION_TYPE = "org.eclipse.jet.internal.editor.info";
+ public static final String INFO_ANNOTATION_TYPE = "org.eclipse.jet.editor.info";
public JETProblemAnnotation(Problem problem) {
- if (problem.getSeverity() == ParseProblemSeverity.ERROR)
- setType("org.eclipse.jet.internal.editor.error");
- else if (problem.getSeverity() == ParseProblemSeverity.WARNING)
- setType("org.eclipse.jet.internal.editor.warning");
+ if (problem.getProblemSeverity() == ProblemSeverity.ERROR)
+ setType(ERROR_ANNOTATION_TYPE);
+ else if (problem.getProblemSeverity() == ProblemSeverity.WARNING)
+ setType(WARNING_ANNOTATION_TYPE);
setText(problem.getMessage());
}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/autoedit/JETTemplateAutoEditStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/autoedit/JETTemplateAutoEditStrategy.java
index cf53e35..427471c 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/autoedit/JETTemplateAutoEditStrategy.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/autoedit/JETTemplateAutoEditStrategy.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.autoedit;
import org.eclipse.jface.text.*;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/DoubleClickStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/DoubleClickStrategy.java
index 18bb666..dd46718 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/DoubleClickStrategy.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/DoubleClickStrategy.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.configuration;
import org.eclipse.jface.text.*;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/IJETColorConstants.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/IJETColorConstants.java
index ceff69e..ab8f041 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/IJETColorConstants.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/IJETColorConstants.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.configuration;
import org.eclipse.swt.graphics.RGB;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETDocumentProvider.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETDocumentProvider.java
index d98880c..86a7053 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETDocumentProvider.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETDocumentProvider.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.configuration;
import org.eclipse.core.runtime.CoreException;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETReconcilingStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETReconcilingStrategy.java
index c0beb71..4b6b503 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETReconcilingStrategy.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETReconcilingStrategy.java
@@ -1,10 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.configuration;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jet.compiler.JET2CompilationUnit;
-import org.eclipse.jet.compiler.Problem;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
+import org.eclipse.jet.core.parser.ast.Problem;
import org.eclipse.jet.internal.editor.JETEditorHelper;
import org.eclipse.jet.internal.editor.JETTextEditor;
import org.eclipse.jet.internal.editor.annotations.JETAnnotationModel;
@@ -42,10 +52,9 @@ public class JETReconcilingStrategy implements IReconcilingStrategy, IReconcilin
}
private void internalReconcile() {
- JET2CompilationUnit cUnit = jetEditor.requestCompilationUnit();
+ JETCompilationUnit cUnit = jetEditor.requestCompilationUnit();
List cUnitProblems = cUnit.getProblems();
- List javaContentProblems = JETEditorHelper.evaluateProblems(jetEditor.getJETJavaProject(), cUnit, sourceViewer
- .getDocument());
+ List javaContentProblems = JETEditorHelper.evaluateProblems(jetEditor, sourceViewer.getDocument());
JETAnnotationModel annotationModel = (JETAnnotationModel) sourceViewer.getAnnotationModel();
if (annotationModel != null) {
annotationModel.setFireChanges(false);
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETSourceViewerConfiguration.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETSourceViewerConfiguration.java
index e751e00..95ee783 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETSourceViewerConfiguration.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETSourceViewerConfiguration.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.configuration;
import org.eclipse.core.runtime.NullProgressMonitor;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETTokenStyleManager.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETTokenStyleManager.java
index d404490..2f7f579 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETTokenStyleManager.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETTokenStyleManager.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.configuration;
import java.util.HashMap;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETWhitespaceDetector.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETWhitespaceDetector.java
index c3a2f79..a5bd04a 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETWhitespaceDetector.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/JETWhitespaceDetector.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.configuration;
import org.eclipse.jface.text.rules.IWhitespaceDetector;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/NonRuleBasedDamagerRepairer.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/NonRuleBasedDamagerRepairer.java
index ed3f136..019c755 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/NonRuleBasedDamagerRepairer.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/NonRuleBasedDamagerRepairer.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.configuration;
import org.eclipse.core.runtime.Assert;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/IJETDefaultTextColorerDelegate.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/IJETDefaultTextColorerDelegate.java
index 2ac871d..a463706 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/IJETDefaultTextColorerDelegate.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/IJETDefaultTextColorerDelegate.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.configuration.delegates;
import org.eclipse.jet.internal.editor.partition.ITokenScannerProvider;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/java/JavaContentPartitionConfigurationDelegate.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/java/JavaContentPartitionConfigurationDelegate.java
index 62b974f..807bb0f 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/java/JavaContentPartitionConfigurationDelegate.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/java/JavaContentPartitionConfigurationDelegate.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.configuration.delegates.java;
import java.util.ArrayList;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/xml/XMLContentPartitionConfigurationDelegate.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/xml/XMLContentPartitionConfigurationDelegate.java
index 63c2291..bb0c6af 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/xml/XMLContentPartitionConfigurationDelegate.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/configuration/delegates/xml/XMLContentPartitionConfigurationDelegate.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.configuration.delegates.xml;
import org.eclipse.jdt.ui.text.IColorManager;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/AbstractJETAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/AbstractJETAssistProcessor.java
index c7968c3..969069e 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/AbstractJETAssistProcessor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/AbstractJETAssistProcessor.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.contentassist;
import org.eclipse.jet.internal.editor.JETTextEditor;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/AbstractXMLTagsBasedAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/AbstractXMLTagsBasedAssistProcessor.java
index 32e9001..85951e4 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/AbstractXMLTagsBasedAssistProcessor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/AbstractXMLTagsBasedAssistProcessor.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.contentassist;
import java.util.*;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETCustomTagAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETCustomTagAssistProcessor.java
index 461afba..869dc5a 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETCustomTagAssistProcessor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETCustomTagAssistProcessor.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.contentassist;
import java.util.*;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETDirectiveAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETDirectiveAssistProcessor.java
index 64830f1..3b48a71 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETDirectiveAssistProcessor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETDirectiveAssistProcessor.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.contentassist;
import org.eclipse.jet.internal.editor.JETTextEditor;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaDeclarationAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaDeclarationAssistProcessor.java
index 68e09d4..31d8a11 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaDeclarationAssistProcessor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaDeclarationAssistProcessor.java
@@ -1,11 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.contentassist;
-import org.eclipse.jet.compiler.JET2Declaration;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
+import org.eclipse.jet.core.parser.ast.JavaDeclaration;
import org.eclipse.jet.internal.editor.JETEditorHelper;
import org.eclipse.jet.internal.editor.JETTextEditor;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.*;
+import org.eclipse.jface.text.Position;
+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[];
@@ -17,15 +35,28 @@ public class JETJavaDeclarationAssistProcessor extends AbstractJETAssistProcesso
}
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
- org.eclipse.jet.compiler.JET2CompilationUnit cu = editor.requestCompilationUnit();
- JET2Declaration declaration = (JET2Declaration) editor.getASTElement(offset);
- int jetStart = declaration.getStart() + 3;
- org.eclipse.jdt.core.IJavaProject javaProject = editor.getJETJavaProject();
+ JETCompilationUnit cu = editor.requestCompilationUnit();
+ JavaDeclaration declaration = (JavaDeclaration) editor.getASTElement(offset);
+
+ // locate the java content first offset start in the JET document.
+ // a java element is of the form <% {java content} %>
+ // in order to have an exact matching between the completion offset in the JET document and the
+ // completion offset of the java content, we should perform the offset matching with the java content start
+ // not with the element offset start (the "<%" char offset start)
+ int javaContentStart = declaration.getJavaStart();
+
+ IJavaProject javaProject = editor.getJavaProject();
if (javaProject != null) {
- int javaOffset = offset - jetStart;
- String javaContent = declaration.getJavaContent();
- org.eclipse.jdt.ui.text.java.IJavaCompletionProposal javaCompletionProposals[] = JETEditorHelper
- .getJavaCompletionProposal(javaProject, cu, javaContent, viewer, javaOffset);
+ Map mappingPositions = new HashMap();
+ String javaSource = editor.compilationHelper().getJavaCode(cu, mappingPositions);
+ int javaStartOffset = ((Position)mappingPositions.get(declaration)).offset;
+ int javaOffset = javaStartOffset + (offset - javaContentStart);
+
+ // check that the positions matches
+ JETEditorHelper.checkOffsetPositions(javaSource, viewer.getDocument().get(), offset, javaOffset, 15);
+
+ IJavaCompletionProposal javaCompletionProposals[] = JETEditorHelper
+ .getJavaCompletionProposal(javaProject, cu, javaSource, viewer, javaOffset);
JETEditorHelper.adjustResults(javaCompletionProposals, offset);
return javaCompletionProposals;
} else {
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaExpressionAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaExpressionAssistProcessor.java
index 37d7087..6735803 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaExpressionAssistProcessor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaExpressionAssistProcessor.java
@@ -1,48 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.contentassist;
-import org.eclipse.jet.compiler.JET2Expression;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
+import org.eclipse.jet.core.parser.ast.JavaExpression;
import org.eclipse.jet.internal.editor.JETEditorHelper;
import org.eclipse.jet.internal.editor.JETTextEditor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.*;
-import org.eclipse.jface.text.contentassist.*;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+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[];
+ /**
+ * @param editor
+ */
public JETJavaExpressionAssistProcessor(JETTextEditor editor) {
super(editor);
completionProposalAutoActivationCharacters = editor.getEditorPreferenceStore().getString(
"content_assist_autoactivation_triggers_java").toCharArray();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
+ */
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
- org.eclipse.jet.compiler.JET2CompilationUnit cu = editor.requestCompilationUnit();
- JET2Expression expression = (JET2Expression) editor.getASTElement(offset);
- int jetStart = expression.getStart();
- 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) {
- e.printStackTrace();
- }
- org.eclipse.jdt.core.IJavaProject javaProject = editor.getJETJavaProject();
+ JETCompilationUnit cu = editor.requestCompilationUnit();
+ JavaExpression expression = (JavaExpression) editor.getASTElement(offset);
+
+ // locate the java content first offset start in the JET document.
+ // a java element is of the form <% {java content} %>
+ // in order to have an exact matching between the completion offset in the JET document and the
+ // completion offset of the java content, we should perform the offset matching with the java content start
+ // not with the element offset start (the "<%" char offset start)
+ int javaContentStart = expression.getJavaStart();
+
+ IJavaProject javaProject = editor.getJavaProject();
if (javaProject != null) {
- 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 = (new StringBuilder(String.valueOf(writeStr))).append(expression.getJavaContent().trim()).append(
- ");").toString();
- String javaContent = (new StringBuilder(String.valueOf(declarationsSource))).append(bodyMethodDecl).append(
- previousJavaBodyContent).append(expBody).toString();
- int javaOffset = (offset - jetStart) + declarationsSource.length() + bodyMethodDecl.length()
- + previousJavaBodyContent.length() + writeStr.length();
- org.eclipse.jdt.ui.text.java.IJavaCompletionProposal javaCompletionProposals[] = JETEditorHelper
- .getJavaCompletionProposal(javaProject, cu, javaContent, viewer, javaOffset);
+ // fetch the java content generated for all the AST elements till the current expression
+ Map mappingPositions = new HashMap();
+ String javaSource = editor.compilationHelper().getJavaCode(cu, mappingPositions);
+ int javaStartOffset = ((Position)mappingPositions.get(expression)).offset;
+ int javaOffset = javaStartOffset + (offset - javaContentStart);
+
+ // check that the positions matches
+ JETEditorHelper.checkOffsetPositions(javaSource, viewer.getDocument().get(), offset, javaOffset, 15);
+
+ IJavaCompletionProposal javaCompletionProposals[] = JETEditorHelper
+ .getJavaCompletionProposal(javaProject, cu, javaSource, viewer, javaOffset);
JETEditorHelper.adjustResults(javaCompletionProposals, offset);
return javaCompletionProposals;
} else {
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaScriptletAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaScriptletAssistProcessor.java
index dbc7652..b939083 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaScriptletAssistProcessor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaScriptletAssistProcessor.java
@@ -1,11 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.contentassist;
-import org.eclipse.jet.compiler.JET2Scriptlet;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
+import org.eclipse.jet.core.parser.ast.JavaScriptlet;
import org.eclipse.jet.internal.editor.JETEditorHelper;
import org.eclipse.jet.internal.editor.JETTextEditor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.*;
-import org.eclipse.jface.text.contentassist.*;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+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[];
@@ -17,29 +35,29 @@ public class JETJavaScriptletAssistProcessor extends AbstractJETAssistProcessor
}
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
- org.eclipse.jet.compiler.JET2CompilationUnit cu = editor.requestCompilationUnit();
- JET2Scriptlet scriptlet = (JET2Scriptlet) editor.getASTElement(offset);
- int jetStart = scriptlet.getStart();
- 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) {
- e.printStackTrace();
- }
- org.eclipse.jdt.core.IJavaProject javaProject = editor.getJETJavaProject();
+ JETCompilationUnit cu = editor.requestCompilationUnit();
+ JavaScriptlet scriptlet = (JavaScriptlet) editor.getASTElement(offset);
+
+ // locate the java content first offset start in the JET document.
+ // a java element is of the form <% {java content} %>
+ // in order to have an exact matching between the completion offset in the JET document and the
+ // completion offset of the java content, we should perform the offset matching with the java content start
+ // not with the element offset start (the "<%" char offset start)
+ int javaContentStart = scriptlet.getJavaStart();
+
+ IJavaProject javaProject = editor.getJavaProject();
if (javaProject != null) {
- 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 = (new StringBuilder(String.valueOf(declarationsSource))).append(bodyMethodDecl).append(
- previousJavaBodyContent).append(scriptletBody).toString();
- int javaOffset = (offset - jetStart) + declarationsSource.length() + bodyMethodDecl.length()
- + previousJavaBodyContent.length();
- org.eclipse.jdt.ui.text.java.IJavaCompletionProposal javaCompletionProposals[] = JETEditorHelper
- .getJavaCompletionProposal(javaProject, cu, javaContent, viewer, javaOffset);
+ // fetch the java content generated for all the AST elements till the current expression
+ Map mappingPositions = new HashMap();
+ String javaSource = editor.compilationHelper().getJavaCode(cu, mappingPositions);
+ int javaStartOffset = ((Position)mappingPositions.get(scriptlet)).offset;
+ int javaOffset = javaStartOffset + (offset - javaContentStart);
+
+ // check that the positions matches
+ JETEditorHelper.checkOffsetPositions(javaSource, viewer.getDocument().get(), offset, javaOffset, 15);
+
+ IJavaCompletionProposal javaCompletionProposals[] = JETEditorHelper
+ .getJavaCompletionProposal(javaProject, cu, javaSource, viewer, javaOffset);
JETEditorHelper.adjustResults(javaCompletionProposals, offset);
return javaCompletionProposals;
} else {
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETTagAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETTagAssistProcessor.java
index 238427c..4c12527 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETTagAssistProcessor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETTagAssistProcessor.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.contentassist;
import org.eclipse.jet.internal.editor.JETTextEditor;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETCustomTagFormattingStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETCustomTagFormattingStrategy.java
index c4d1c1c..4f41e0d 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETCustomTagFormattingStrategy.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETCustomTagFormattingStrategy.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.formatter;
import org.eclipse.jface.text.formatter.IFormattingContext;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETDirectiveFormattingStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETDirectiveFormattingStrategy.java
index 156a12a..05df61a 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETDirectiveFormattingStrategy.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETDirectiveFormattingStrategy.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.formatter;
import org.eclipse.jface.text.formatter.IFormattingContext;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaDeclarationFormattingStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaDeclarationFormattingStrategy.java
index 09d10cf..6bb8011 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaDeclarationFormattingStrategy.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaDeclarationFormattingStrategy.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.formatter;
import org.eclipse.jface.text.formatter.IFormattingContext;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaExpressionFormattingStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaExpressionFormattingStrategy.java
index d79e0d4..7f7a128 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaExpressionFormattingStrategy.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaExpressionFormattingStrategy.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.formatter;
import org.eclipse.jface.text.formatter.IFormattingContext;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaScriptletFormattingStrategy.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaScriptletFormattingStrategy.java
index a7d72dc..81ef27b 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaScriptletFormattingStrategy.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/formatter/JETJavaScriptletFormattingStrategy.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.formatter;
import org.eclipse.jface.text.formatter.IFormattingContext;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/gen/JETEditorJET2JavaGenerator.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/gen/JETEditorJET2JavaGenerator.java
deleted file mode 100644
index 75bd649..0000000
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/gen/JETEditorJET2JavaGenerator.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.eclipse.jet.internal.editor.gen;
-
-import java.util.*;
-import org.eclipse.jet.*;
-import org.eclipse.jet.compiler.*;
-import org.eclipse.jet.taglib.*;
-import org.eclipse.jet.transform.TransformContextExtender;
-import org.eclipse.jface.text.Position;
-
-public class JETEditorJET2JavaGenerator implements JET2Template {
-
- private XMLElement[] getAllXMLTags(JET2CompilationUnit cu) {
- final List result = new ArrayList();
- cu.accept(new DefaultJET2ASTVisitor() {
- public void visit(XMLBodyElement element) {
- result.add(element);
- }
- public void visit(XMLEmptyElement element) {
- result.add(element);
- }
- });
- return (XMLElement[]) result.toArray(new XMLElement[result.size()]);
- }
-
- private 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()]);
- }
-
- private void adjustGeneratedBodyPositions(Map mappingPositions, int generatedBodyOffsetStart) {
- for (Iterator iterator = mappingPositions.keySet().iterator(); iterator.hasNext();) {
- Object element = iterator.next();
- if (!(element instanceof JET2Declaration)) {
- Position position = (Position) mappingPositions.get(element);
- position.offset += generatedBodyOffsetStart;
- }
- }
-
- }
-
- public JETEditorJET2JavaGenerator() {
- }
-
- public void generate(JET2Context context, JET2Writer out) {
- TagInfo _jettd_c_include_100_4 = new TagInfo("c:include", 100, 4, new String[] { "template" },
- new String[] { "templates/tagDataDeclarations.jet" });
- JET2CompilationUnit cu = (JET2CompilationUnit) context.getVariable("cu");
- JET2Declaration allMemberDeclarations[] = getAllJavaDeclarations(cu);
- XMLElement allXMLElements[] = getAllXMLTags(cu);
- TagLibraryReference tlRefs[] = cu.getTagLibraryReferences();
- Map generatedBodyMappingPositions = new HashMap();
- Map mappingPositions = (Map) context.getVariable("org.eclipse.jet.storeJavaMappingPositions");
- org.eclipse.jet.internal.editor.JETEditorHelper.JETEditorMethodBodyCreator generatedBody = new org.eclipse.jet.internal.editor.JETEditorHelper.JETEditorMethodBodyCreator(
- TransformContextExtender.getInstance(context).getLoader(), generatedBodyMappingPositions);
- cu.accept(generatedBody);
- out.write("package ");
- out.write(cu.getOutputJavaPackage());
- out
- .write(";\r\n\r\nimport org.eclipse.jet.JET2Context;\r\nimport org.eclipse.jet.JET2Template;\r\nimport org.eclipse.jet.JET2Writer;\r\n");
- if (allXMLElements.length > 0)
- out.write("import org.eclipse.jet.taglib.RuntimeTagElement;\r\nimport org.eclipse.jet.taglib.TagInfo;\r\n");
- for (Iterator i = cu.getImports().iterator(); i.hasNext(); out.write(";\r\n")) {
- String importName = (String) i.next();
- out.write("import ");
- out.write(importName);
- }
-
- out.write("\r\npublic class ");
- out.write(cu.getOutputJavaClassName());
- out.write(" implements JET2Template {\r\n");
- if (allXMLElements.length > 0) {
- for (int i = 0; i < tlRefs.length; i++) {
- out.write(" public static final String _jetns_");
- out.write(tlRefs[i].getPrefix());
- out.write(" = \"");
- out.write(tlRefs[i].getTagLibraryId());
- out.write("\"; //$NON-NLS-1$\r\n");
- }
-
- }
- for (int i = 0; i < allMemberDeclarations.length; i++) {
- Position position = new Position(out.getLength());
- mappingPositions.put(allMemberDeclarations[i], position);
- out.write(allMemberDeclarations[i].getJavaContent());
- out.write("\r\n");
- position.setLength(out.getLength() - position.offset);
- }
-
- out.write("\r\n\tpublic ");
- out.write(cu.getOutputJavaClassName());
- out
- .write("() {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic void generate(final JET2Context context, JET2Writer out) {\r\n");
- for (int i = 0; i < allXMLElements.length; i++) {
- context.setVariable("element", allXMLElements[i]);
- RuntimeTagElement _jettag_c_include_100_4 = context.getTagFactory().createRuntimeTag(
- "org.eclipse.jet.controlTags", "include", "c:include", _jettd_c_include_100_4);
- _jettag_c_include_100_4.setRuntimeParent(null);
- _jettag_c_include_100_4.setTagInfo(_jettd_c_include_100_4);
- _jettag_c_include_100_4.doStart(context, out);
- _jettag_c_include_100_4.doEnd();
- }
-
- adjustGeneratedBodyPositions(generatedBodyMappingPositions, out.getLength());
- mappingPositions.putAll(generatedBodyMappingPositions);
- out.write(generatedBody.getBuffer());
- out.write("\r\n\t}\r\n\r\n}\r\n");
- }
-
- public static final String _jetns_c = "org.eclipse.jet.controlTags";
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlineContentProvider.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlineContentProvider.java
index 0971605..08e62cd 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlineContentProvider.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlineContentProvider.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.outline;
import java.util.ArrayList;
@@ -5,10 +15,10 @@ 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.jet.core.parser.ast.JETASTElement;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
+import org.eclipse.jet.core.parser.ast.TextElement;
+import org.eclipse.jet.core.parser.ast.XMLBodyElement;
import org.eclipse.jet.internal.editor.JETTextEditor;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
@@ -17,59 +27,49 @@ public class JETOutlineContentProvider implements ITreeContentProvider {
private ImportsContainerInput importContainerInput;
private CompilationUnitContainerInput astContainerInput;
private OutputPackageInput outputPackageInput;
- private JET2CompilationUnit cu;
+ private JETCompilationUnit cu;
private OutputClassInput outputClassInput;
private JETTextEditor editor;
public class OutputClassInput {
- private JET2CompilationUnit compilationUnit;
-
- public OutputClassInput(JET2CompilationUnit cu) {
+ private JETCompilationUnit compilationUnit;
+ public OutputClassInput(JETCompilationUnit cu) {
this.compilationUnit = cu;
}
-
- public JET2CompilationUnit getCompilationUnit() {
+ public JETCompilationUnit getCompilationUnit() {
return compilationUnit;
}
}
public class OutputPackageInput {
- private JET2CompilationUnit compilationUnit;
-
- public OutputPackageInput(JET2CompilationUnit cu) {
+ private JETCompilationUnit compilationUnit;
+ public OutputPackageInput(JETCompilationUnit cu) {
this.compilationUnit = cu;
}
-
- public JET2CompilationUnit getCompilationUnit() {
+ public JETCompilationUnit 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 JETCompilationUnit compilationUnit;
private Collection importInputs;
-
- public ImportsContainerInput(JET2CompilationUnit cu) {
+ public ImportsContainerInput(JETCompilationUnit cu) {
this.compilationUnit = cu;
importInputs = new ArrayList();
for (Iterator iterator = cu.getImports().iterator(); iterator.hasNext();) {
@@ -77,11 +77,9 @@ public class JETOutlineContentProvider implements ITreeContentProvider {
importInputs.add(new ImportInput(this, imp));
}
}
-
- public JET2CompilationUnit getCompilationUnit() {
+ public JETCompilationUnit getCompilationUnit() {
return compilationUnit;
}
-
public Collection getImportImputs() {
return importInputs;
}
@@ -90,13 +88,13 @@ public class JETOutlineContentProvider implements ITreeContentProvider {
public class CompilationUnitContainerInput {
private Collection bodyElements;
- private JET2CompilationUnit compilationUnit;
+ private JETCompilationUnit compilationUnit;
- public CompilationUnitContainerInput(JET2CompilationUnit cu) {
+ public CompilationUnitContainerInput(JETCompilationUnit cu) {
this.bodyElements = new ArrayList();
this.compilationUnit = cu;
for (Iterator iterator = cu.getBodyElements().iterator(); iterator.hasNext();) {
- JET2ASTElement elt = (JET2ASTElement) iterator.next();
+ JETASTElement elt = (JETASTElement) iterator.next();
if (isFiltered(elt))
continue;
bodyElements.add(elt);
@@ -107,11 +105,11 @@ public class JETOutlineContentProvider implements ITreeContentProvider {
return bodyElements;
}
- public JET2CompilationUnit getCompilationUnit() {
+ public JETCompilationUnit getCompilationUnit() {
return compilationUnit;
}
- private boolean isFiltered(JET2ASTElement elt) {
+ private boolean isFiltered(JETASTElement elt) {
if (elt instanceof TextElement) {
String text = new String(((TextElement) elt).getText());
text = text.replace('\r', ' ');
@@ -120,12 +118,6 @@ public class JETOutlineContentProvider implements ITreeContentProvider {
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;
}
}
@@ -139,13 +131,13 @@ public class JETOutlineContentProvider implements ITreeContentProvider {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- cu = (JET2CompilationUnit) newInput;
+ cu = (JETCompilationUnit) newInput;
}
public Object[] getElements(Object inputElement) {
Collection results = new ArrayList();
- if (inputElement instanceof JET2CompilationUnit) {
- JET2CompilationUnit cu = (JET2CompilationUnit) inputElement;
+ if (inputElement instanceof JETCompilationUnit) {
+ JETCompilationUnit cu = (JETCompilationUnit) inputElement;
results.add(outputPackageInput = new OutputPackageInput(cu));
results.add(importContainerInput = new ImportsContainerInput(cu));
results.add(astContainerInput = new CompilationUnitContainerInput(cu));
@@ -178,10 +170,10 @@ public class JETOutlineContentProvider implements ITreeContentProvider {
return outputPackageInput;
if (element instanceof ImportInput)
return ((ImportInput) element).getImportsContainerInput();
- if (element instanceof JET2ASTElement) {
- if (((JET2ASTElement) element).getParent() == cu)
+ if (element instanceof JETASTElement) {
+ if (((JETASTElement) element).getParent() == cu)
return astContainerInput;
- return ((JET2ASTElement) element).getParent();
+ return ((JETASTElement) element).getParent();
}
if (importContainerInput.getCompilationUnit().getImports().contains(element))
return importContainerInput;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlineLabelProvider.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlineLabelProvider.java
index b67d41b..bd9b7d8 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlineLabelProvider.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlineLabelProvider.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.outline;
import java.util.Iterator;
@@ -5,15 +15,15 @@ import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.ui.JavaUI;
-import org.eclipse.jet.compiler.Comment;
import org.eclipse.jet.compiler.CompileOptionsManager;
-import org.eclipse.jet.compiler.JET2Compiler;
-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.core.compiler.JETCompilerOptions;
+import org.eclipse.jet.core.parser.ast.Comment;
+import org.eclipse.jet.core.parser.ast.JETDirective;
+import org.eclipse.jet.core.parser.ast.JavaDeclaration;
+import org.eclipse.jet.core.parser.ast.JavaExpression;
+import org.eclipse.jet.core.parser.ast.JavaScriptlet;
+import org.eclipse.jet.core.parser.ast.TextElement;
+import org.eclipse.jet.core.parser.ast.XMLElement;
import org.eclipse.jet.internal.editor.Activator;
import org.eclipse.jet.internal.editor.JETEditorHelper;
import org.eclipse.jet.internal.editor.JETTextEditor;
@@ -33,13 +43,13 @@ 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) {
+ } else if (element instanceof JavaDeclaration) {
return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PUBLIC);
- } else if (element instanceof JET2Expression) {
+ } else if (element instanceof JavaExpression) {
return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_DEFAULT);
- } else if (element instanceof JET2Scriptlet) {
+ } else if (element instanceof JavaScriptlet) {
return JavaUI.getSharedImages().getImage(org.eclipse.jdt.ui.ISharedImages.IMG_OBJS_PUBLIC);
- } else if (element instanceof JET2Directive) {
+ } else if (element instanceof JETDirective) {
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);
@@ -64,18 +74,18 @@ public class JETOutlineLabelProvider extends LabelProvider {
public String getText(Object element) {
if (element instanceof Comment)
return getShortText(((Comment) element).getCommentText());
- if (element instanceof JET2Declaration)
- return (new StringBuilder("<%!")).append(getShortText(((JET2Declaration) element).getJavaContent())).append("%>")
+ if (element instanceof JavaDeclaration)
+ return (new StringBuilder("<%!")).append(getShortText(((JavaDeclaration) element).getJavaContent())).append("%>")
.toString();
- if (element instanceof JET2Expression)
- return (new StringBuilder("<%=")).append(getShortText(((JET2Expression) element).getJavaContent())).append("%>")
+ if (element instanceof JavaExpression)
+ return (new StringBuilder("<%=")).append(getShortText(((JavaExpression) element).getJavaContent())).append("%>")
.toString();
- if (element instanceof JET2Scriptlet)
- return (new StringBuilder("<%")).append(getShortText(((JET2Scriptlet) element).getJavaContent())).append("%>")
+ if (element instanceof JavaScriptlet)
+ return (new StringBuilder("<%")).append(getShortText(((JavaScriptlet) element).getJavaContent())).append("%>")
.toString();
- if (element instanceof JET2Directive)
- return (new StringBuilder("<%@")).append(((JET2Directive) element).getName()).append(" ").append(
- getAttributesText((JET2Directive) element)).append("%>").toString();
+ if (element instanceof JETDirective)
+ return (new StringBuilder("<%@")).append(((JETDirective) element).getName()).append(" ").append(
+ getAttributesText((JETDirective) element)).append("%>").toString();
if (element instanceof TextElement)
return getShortText(new String(((TextElement) element).getText()));
if (element instanceof XMLElement)
@@ -89,9 +99,9 @@ public class JETOutlineLabelProvider extends LabelProvider {
String packageName = ((JETOutlineContentProvider.OutputPackageInput) element).getCompilationUnit()
.getOutputJavaPackage();
if (packageName == null) {
- Map options = CompileOptionsManager.getOptions(editor.getJETJavaProject().getProject());
+ Map options = CompileOptionsManager.getOptions(editor.getJavaProject().getProject());
if (options.isEmpty())
- options = JET2Compiler.getDefaultCompilerOptions();
+ options = JETCompilerOptions.getDefaultCompilerOptions();
packageName = (String) options.get("org.eclipse.jet.compiledTemplatePackage");
}
return packageName;
@@ -131,7 +141,7 @@ public class JETOutlineLabelProvider extends LabelProvider {
return textBuffer.toString();
}
- private String getAttributesText(JET2Directive directive) {
+ private String getAttributesText(JETDirective directive) {
Map attributes = directive.getAttributes();
StringBuffer textBuffer = new StringBuffer(attributes.size() * 5);
for (Iterator iterator = attributes.keySet().iterator(); iterator.hasNext();) {
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlinePage.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlinePage.java
index 02a7194..d46ee26 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlinePage.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/outline/JETOutlinePage.java
@@ -1,49 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.outline;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jet.compiler.JET2CompilationUnit;
+import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
import org.eclipse.jet.internal.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 {
+public class JETOutlinePage extends ContentOutlinePage implements IAdaptable {
private JETTextEditor editor;
- private TreeViewer contentOutlineViewer;
- public JETOutlinePage(JETTextEditor editor)
- {
- this.editor = editor;
- }
- public void createControl(Composite parent)
- {
- super.createControl(parent);
- contentOutlineViewer = getTreeViewer();
- contentOutlineViewer.addSelectionChangedListener(this);
- contentOutlineViewer.setContentProvider(new JETOutlineContentProvider(editor));
- contentOutlineViewer.setLabelProvider(new JETOutlineLabelProvider(editor));
- setInput();
- editor.createContextMenuFor(contentOutlineViewer);
- }
+ private TreeViewer contentOutlineViewer;
- public void setInput()
- {
- org.eclipse.jet.compiler.JET2CompilationUnit cu = editor.requestCompilationUnit();
- contentOutlineViewer.setInput(cu);
+ public JETOutlinePage(JETTextEditor editor) {
+ this.editor = editor;
}
- public Object getAdapter(Class adapter)
- {
- return null;
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ contentOutlineViewer = getTreeViewer();
+ contentOutlineViewer.addSelectionChangedListener(this);
+ contentOutlineViewer.setContentProvider(new JETOutlineContentProvider(editor));
+ contentOutlineViewer.setLabelProvider(new JETOutlineLabelProvider(editor));
+ setInput();
}
- public void addPostSelectionChangedListener(ISelectionChangedListener iselectionchangedlistener)
- {
+ public void setInput() {
+ JETCompilationUnit cu = editor.requestCompilationUnit();
+ contentOutlineViewer.setInput(cu);
+ contentOutlineViewer.refresh();
}
- public void removePostSelectionChangedListener(ISelectionChangedListener iselectionchangedlistener)
- {
+ public Object getAdapter(Class adapter) {
+ return null;
}
}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/ITokenScannerProvider.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/ITokenScannerProvider.java
index 7970c93..d4a7430 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/ITokenScannerProvider.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/ITokenScannerProvider.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.partition;
import org.eclipse.jface.text.rules.ITokenScanner;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/JETDocumentPartitionScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/JETDocumentPartitionScanner.java
index 1061687..6a58e72 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/JETDocumentPartitionScanner.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/JETDocumentPartitionScanner.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.partition;
import java.util.*;
@@ -353,11 +363,11 @@ public class JETDocumentPartitionScanner extends RuleBasedPartitionScanner {
result = (new IAutoEditStrategy[] { new JETTemplateAutoEditStrategy() });
else if ("__jet_java_scriptlet".equals(contentType))
result = (new IAutoEditStrategy[] {
- new JavaAutoIndentStrategy("__dftl_partitioning", editor.getJETJavaProject()),
+ new JavaAutoIndentStrategy("__dftl_partitioning", editor.getJavaProject()),
new JETTemplateAutoEditStrategy() });
else if ("__jet_java_declaration".equals(contentType))
result = (new IAutoEditStrategy[] {
- new JavaAutoIndentStrategy("__dftl_partitioning", editor.getJETJavaProject()),
+ new JavaAutoIndentStrategy("__dftl_partitioning", editor.getJavaProject()),
new JETTemplateAutoEditStrategy() });
return result;
}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/PartitionScannerBasedDamagerRepairer.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/PartitionScannerBasedDamagerRepairer.java
index 36fd8ae..a02e101 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/PartitionScannerBasedDamagerRepairer.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/partition/PartitionScannerBasedDamagerRepairer.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.partition;
import org.eclipse.core.runtime.Assert;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTElementScannerRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTElementScannerRule.java
index 462005a..aa40ef1 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTElementScannerRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTElementScannerRule.java
@@ -1,6 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
-import org.eclipse.jet.compiler.JET2ASTElement;
+import org.eclipse.jet.core.parser.ast.JETASTElement;
import org.eclipse.jet.internal.editor.JETTextEditor;
import org.eclipse.jet.internal.editor.partition.JETDocumentPartitionScanner;
import org.eclipse.jface.text.rules.*;
@@ -26,7 +36,7 @@ public abstract class ASTElementScannerRule implements IPredicateRule {
public IToken evaluate(ICharacterScanner scanner, boolean resume) {
JETDocumentPartitionScanner jetScanner = (JETDocumentPartitionScanner) scanner;
int offset = jetScanner.getNextCharacterOffset();
- JET2ASTElement element = editor.getASTElement(offset);
+ JETASTElement element = editor.getASTElement(offset);
if (element != null && isAcceptedElement(element)) {
int length = element.getEnd() - offset;
for (int i = 0; i < length; i++)
@@ -38,5 +48,5 @@ public abstract class ASTElementScannerRule implements IPredicateRule {
}
}
- protected abstract boolean isAcceptedElement(JET2ASTElement jet2astelement);
+ protected abstract boolean isAcceptedElement(JETASTElement jet2astelement);
}
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETCommentRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETCommentRule.java
index b709de7..94ac578 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETCommentRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETCommentRule.java
@@ -1,7 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
-import org.eclipse.jet.compiler.Comment;
-import org.eclipse.jet.compiler.JET2ASTElement;
+import org.eclipse.jet.core.parser.ast.Comment;
+import org.eclipse.jet.core.parser.ast.JETASTElement;
import org.eclipse.jet.internal.editor.JETTextEditor;
import org.eclipse.jface.text.rules.IToken;
@@ -11,7 +21,7 @@ public class ASTJETCommentRule extends ASTElementScannerRule {
super(editor, token);
}
- protected boolean isAcceptedElement(JET2ASTElement element) {
+ protected boolean isAcceptedElement(JETASTElement element) {
return element instanceof Comment;
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETCustomTagRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETCustomTagRule.java
index 85b3965..d415f94 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETCustomTagRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETCustomTagRule.java
@@ -1,6 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
-import org.eclipse.jet.compiler.*;
+import org.eclipse.jet.core.parser.ast.JETASTElement;
+import org.eclipse.jet.core.parser.ast.XMLBodyElementEnd;
+import org.eclipse.jet.core.parser.ast.XMLElement;
import org.eclipse.jet.internal.editor.JETTextEditor;
import org.eclipse.jface.text.rules.IToken;
@@ -10,7 +22,7 @@ public class ASTJETCustomTagRule extends ASTElementScannerRule {
super(editor, token);
}
- protected boolean isAcceptedElement(JET2ASTElement element) {
+ protected boolean isAcceptedElement(JETASTElement element) {
return (element instanceof XMLElement) || (element instanceof XMLBodyElementEnd);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETDirectiveRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETDirectiveRule.java
index 601bd0a..92fab86 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETDirectiveRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETDirectiveRule.java
@@ -1,7 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
-import org.eclipse.jet.compiler.JET2ASTElement;
-import org.eclipse.jet.compiler.JET2Directive;
+import org.eclipse.jet.core.parser.ast.JETDirective;
+import org.eclipse.jet.core.parser.ast.JETASTElement;
import org.eclipse.jet.internal.editor.JETTextEditor;
import org.eclipse.jface.text.rules.IToken;
@@ -11,7 +21,7 @@ public class ASTJETDirectiveRule extends ASTElementScannerRule {
super(editor, token);
}
- protected boolean isAcceptedElement(JET2ASTElement element) {
- return element instanceof JET2Directive;
+ protected boolean isAcceptedElement(JETASTElement element) {
+ return element instanceof JETDirective;
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaDeclarationRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaDeclarationRule.java
index f2f785c..ffa27dc 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaDeclarationRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaDeclarationRule.java
@@ -1,7 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
-import org.eclipse.jet.compiler.JET2ASTElement;
-import org.eclipse.jet.compiler.JET2Declaration;
+import org.eclipse.jet.core.parser.ast.JETASTElement;
+import org.eclipse.jet.core.parser.ast.JavaDeclaration;
import org.eclipse.jet.internal.editor.JETTextEditor;
import org.eclipse.jface.text.rules.IToken;
@@ -11,7 +21,7 @@ public class ASTJETJavaDeclarationRule extends ASTElementScannerRule {
super(editor, token);
}
- protected boolean isAcceptedElement(JET2ASTElement element) {
- return element instanceof JET2Declaration;
+ protected boolean isAcceptedElement(JETASTElement element) {
+ return element instanceof JavaDeclaration;
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaExpressionRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaExpressionRule.java
index bdca1a7..255c929 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaExpressionRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaExpressionRule.java
@@ -1,7 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
-import org.eclipse.jet.compiler.JET2ASTElement;
-import org.eclipse.jet.compiler.JET2Expression;
+import org.eclipse.jet.core.parser.ast.JETASTElement;
+import org.eclipse.jet.core.parser.ast.JavaExpression;
import org.eclipse.jet.internal.editor.JETTextEditor;
import org.eclipse.jface.text.rules.IToken;
@@ -11,7 +21,7 @@ public class ASTJETJavaExpressionRule extends ASTElementScannerRule {
super(editor, token);
}
- protected boolean isAcceptedElement(JET2ASTElement element) {
- return element instanceof JET2Expression;
+ protected boolean isAcceptedElement(JETASTElement element) {
+ return element instanceof JavaExpression;
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaScriptletRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaScriptletRule.java
index cff5acf..36bd08a 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaScriptletRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/ASTJETJavaScriptletRule.java
@@ -1,7 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
-import org.eclipse.jet.compiler.JET2ASTElement;
-import org.eclipse.jet.compiler.JET2Scriptlet;
+import org.eclipse.jet.core.parser.ast.JETASTElement;
+import org.eclipse.jet.core.parser.ast.JavaScriptlet;
import org.eclipse.jet.internal.editor.JETTextEditor;
import org.eclipse.jface.text.rules.IToken;
@@ -11,7 +21,7 @@ public class ASTJETJavaScriptletRule extends ASTElementScannerRule {
super(editor, token);
}
- protected boolean isAcceptedElement(JET2ASTElement element) {
- return element instanceof JET2Scriptlet;
+ protected boolean isAcceptedElement(JETASTElement element) {
+ return element instanceof JavaScriptlet;
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETBracketRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETBracketRule.java
index b8ebbad..68d18ef 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETBracketRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETBracketRule.java
@@ -8,7 +8,6 @@
* Contributors:
* Joel Cheuoua - initial API and implementation
*******************************************************************************/
-
package org.eclipse.jet.internal.editor.rules;
import org.eclipse.jface.text.rules.ICharacterScanner;
@@ -18,7 +17,7 @@ import org.eclipse.jface.text.rules.Token;
/**
* @author jcheuoua
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class JETBracketRule extends MultiLineRule {
protected IToken token;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETCommentRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETCommentRule.java
index e259b14..2f1ee7f 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETCommentRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETCommentRule.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
import org.eclipse.jface.text.rules.*;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETCustomTagRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETCustomTagRule.java
index 889ffca..fed5476 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETCustomTagRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETCustomTagRule.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
import java.util.HashSet;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETDirectiveRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETDirectiveRule.java
index 1ab6c87..2745f87 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETDirectiveRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETDirectiveRule.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
import org.eclipse.jface.text.rules.*;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaDeclarationRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaDeclarationRule.java
index 42dec6a..79595da 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaDeclarationRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaDeclarationRule.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
import org.eclipse.jface.text.rules.*;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaExpressionRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaExpressionRule.java
index 0243dca..47c9d9d 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaExpressionRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaExpressionRule.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
import org.eclipse.jface.text.rules.*;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaScriptletRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaScriptletRule.java
index 4ffddba..e10ecb8 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaScriptletRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/JETJavaScriptletRule.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
import org.eclipse.jface.text.rules.*;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/WordListDetectorRule.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/WordListDetectorRule.java
index d06ed7b..ef740f8 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/WordListDetectorRule.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/rules/WordListDetectorRule.java
@@ -1,6 +1,13 @@
-/**
- *
- */
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.rules;
import java.util.Collection;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETCommentScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETCommentScanner.java
index 104c330..72ca195 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETCommentScanner.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETCommentScanner.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.scanners;
import org.eclipse.jet.internal.editor.configuration.JETEditorPreferenceConstants;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETCustomTagScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETCustomTagScanner.java
index 17f47c2..1db0a3b 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETCustomTagScanner.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETCustomTagScanner.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.scanners;
import java.util.ArrayList;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETDefaultContentScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETDefaultContentScanner.java
index a3efb8c..c79d6cd 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETDefaultContentScanner.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETDefaultContentScanner.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.scanners;
import org.eclipse.jet.internal.editor.configuration.JETTokenStyleManager;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETDirectiveScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETDirectiveScanner.java
index 964c8ce..996b0cd 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETDirectiveScanner.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETDirectiveScanner.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.scanners;
import org.eclipse.jdt.ui.PreferenceConstants;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaCodeScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaCodeScanner.java
index d56a402..b424cdd 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaCodeScanner.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaCodeScanner.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.scanners;
import java.util.ArrayList;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaDeclarationScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaDeclarationScanner.java
index 351d4e5..af23128 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaDeclarationScanner.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaDeclarationScanner.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.scanners;
import java.util.ArrayList;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaExpressionScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaExpressionScanner.java
index d43ecd7..d9b0369 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaExpressionScanner.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaExpressionScanner.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.scanners;
import java.util.ArrayList;
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaScriptletScanner.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaScriptletScanner.java
index 59142ac..7f711f2 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaScriptletScanner.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/scanners/JETJavaScriptletScanner.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 ILOG and 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.internal.editor.scanners;
import java.util.ArrayList;
diff --git a/plugins/org.eclipse.jet.editor/templates/jet2java.jet b/plugins/org.eclipse.jet.editor/templates/jet2java.jet
deleted file mode 100644
index b69d331..0000000
--- a/plugins/org.eclipse.jet.editor/templates/jet2java.jet
+++ /dev/null
@@ -1,94 +0,0 @@
-<%@jet package="org.eclipse.jet.internal.compiler.templates"
- class="JET2JavaGenerator"
- %>
-<%@jet imports="org.eclipse.jet.internal.compiler.*"%>
-<%@jet imports="org.eclipse.jet.compiler.*"%>
-<%@jet imports="org.eclipse.jet.transform.TransformContextExtender"%>
-<%@jet imports="org.eclipse.jet.taglib.TagLibraryReference"%>
-<%@jet imports="java.util.*"%>
-<%@jet imports="org.eclipse.jface.text.Position"%>
-<%!
- private XMLElement[] getAllXMLTags(JET2CompilationUnit cu) {
- final List result = new ArrayList();
- cu.accept(new DefaultJET2ASTVisitor() {
- public void visit(XMLBodyElement element) {
- result.add(element);
- }
-
- public void visit(XMLEmptyElement element) {
- result.add(element);
- }
- });
- return (XMLElement[])result.toArray(new XMLElement[result.size()]);
- }
-
- private 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()]);
- }
-
- private void adjustGeneratedBodyPositions(Map mappingPositions, int generatedBodyOffsetStart) {
- for (Iterator iterator = mappingPositions.keySet().iterator(); iterator.hasNext();) {
- Object element = iterator.next();
- if (!(element instanceof JET2Declaration)) {
- Position position = (Position) mappingPositions.get(element);
- position.offset += generatedBodyOffsetStart;
- }
- }
- }
-%>
-<%
- JET2CompilationUnit cu = (JET2CompilationUnit) context.getVariable("cu");
- JET2Declaration allMemberDeclarations[] = getAllJavaDeclarations(cu);
- XMLElement allXMLElements[] = getAllXMLTags(cu);
- TagLibraryReference tlRefs[] = cu.getTagLibraryReferences();
- Map generatedBodyMappingPositions = new HashMap();
- Map mappingPositions = (Map) context.getVariable("org.eclipse.jet.storeJavaMappingPositions");
- org.eclipse.jet.internal.editor.JETEditorHelper.JETEditorMethodBodyCreator generatedBody = new org.eclipse.jet.internal.editor.JETEditorHelper.JETEditorMethodBodyCreator(
- TransformContextExtender.getInstance(context).getLoader(), generatedBodyMappingPositions);
- cu.accept(generatedBody);
-%>
-package <%= cu.getOutputJavaPackage() %>;
-
-import org.eclipse.jet.JET2Context;
-import org.eclipse.jet.JET2Template;
-import org.eclipse.jet.JET2Writer;
-<% if( allXMLElements.length > 0) { %>
-import org.eclipse.jet.taglib.RuntimeTagElement;
-import org.eclipse.jet.taglib.TagInfo;
-<% } %>
-<% for(Iterator i=cu.getImports().iterator();i.hasNext();) {
- String importName = (String)i.next();%>
-import <%=importName%>;
-<% } %>
-
-public class <%= cu.getOutputJavaClassName() %> implements JET2Template {
-<% if( allXMLElements.length > 0) { %>
-<% for(int i = 0; i < tlRefs.length; i++ ) { %>
- public static final String _jetns_<%= tlRefs[i].getPrefix() %> = "<%= tlRefs[i].getTagLibraryId() %>"; //$NON-NLS-1$
-<% } %>
-<% } %>
-<% for(int i = 0; i < allMemberDeclarations.length; i++) { %>
-
-<%= allMemberDeclarations[i].getJavaContent() %>
-<% } %>
-
- public <%= cu.getOutputJavaClassName() %>() {
- super();
- }
-
- public void generate(final JET2Context context, JET2Writer out) {
-<% for(int i = 0; i < allXMLElements.length; i++) {
- context.setVariable("element", allXMLElements[i]); //$NON-NLS-1$
-%>
- <c:include template="templates/tagDataDeclarations.jet"/>
-<% } %>
-<%= generatedBody.getBuffer() %>
- }
-
-}