Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2009-01-26 16:49:17 -0500
committerpelder2009-01-26 16:49:17 -0500
commitc3149e5839e8078f39a27807b59a32df65e40b03 (patch)
tree08d4741f9d7b8d1cf17bcb50b85acd11a4444ecb
parent4d470a8b67649d26acfcef7707ed4f9f62d00fa0 (diff)
downloadorg.eclipse.jet-c3149e5839e8078f39a27807b59a32df65e40b03.tar.gz
org.eclipse.jet-c3149e5839e8078f39a27807b59a32df65e40b03.tar.xz
org.eclipse.jet-c3149e5839e8078f39a27807b59a32df65e40b03.zip
[262419] JET 1 includes
-rw-r--r--plugins/org.eclipse.jet.core/META-INF/MANIFEST.MF11
-rw-r--r--plugins/org.eclipse.jet.core/src/org/eclipse/jet/core/parser/ast/JETASTParser.java13
-rw-r--r--plugins/org.eclipse.jet.core/src/org/eclipse/jet/internal/core/parser/IJETParser2.java36
-rw-r--r--plugins/org.eclipse.jet.core/src/org/eclipse/jet/internal/core/parser/InternalJET1Parser.java29
-rw-r--r--plugins/org.eclipse.jet.editor/.classpath4
-rw-r--r--plugins/org.eclipse.jet.editor/.settings/org.eclipse.jdt.core.prefs20
-rw-r--r--plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETTextEditor.java14
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/CompilationHelper.java89
9 files changed, 191 insertions, 29 deletions
diff --git a/plugins/org.eclipse.jet.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet.core/META-INF/MANIFEST.MF
index b0b3803..d871c9d 100644
--- a/plugins/org.eclipse.jet.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jet.core/META-INF/MANIFEST.MF
@@ -2,10 +2,11 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jet.core
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.1.100.qualifier
Bundle-Localization: plugin
Eclipse-LazyStart: true
Export-Package: org.eclipse.jet,
+ org.eclipse.jet.commands,
org.eclipse.jet.core.compiler,
org.eclipse.jet.core.parser,
org.eclipse.jet.core.parser.ast,
@@ -13,9 +14,15 @@ Export-Package: org.eclipse.jet,
org.eclipse.jet.internal.core.compiler;x-friends:="org.eclipse.jet,org.eclipse.jet.tests,org.eclipse.jet.tests.core",
org.eclipse.jet.internal.core.parser;x-friends:="org.eclipse.jet.tests.tools,org.eclipse.jet,org.eclipse.jet.tests.core",
org.eclipse.jet.internal.core.parser.jasper;x-friends:="org.eclipse.jet,org.eclipse.jet.tests,org.eclipse.jet.tests.core",
- org.eclipse.jet.internal.core.url;x-friends:="org.eclipse.jet,org.eclipse.jet.editor,org.eclipse.jet.tests,org.eclipse.jet.tests.core,org.eclipse.jet.ui",
+ org.eclipse.jet.internal.core.url;
+ x-friends:="org.eclipse.jet,
+ org.eclipse.jet.editor,
+ org.eclipse.jet.tests,
+ org.eclipse.jet.tests.core,
+ org.eclipse.jet.ui",
org.eclipse.jet.internal.taglib,
org.eclipse.jet.taglib
Require-Bundle: org.eclipse.text;bundle-version="[3.2.0,4.0.0)"
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
diff --git a/plugins/org.eclipse.jet.core/src/org/eclipse/jet/core/parser/ast/JETASTParser.java b/plugins/org.eclipse.jet.core/src/org/eclipse/jet/core/parser/ast/JETASTParser.java
index a34bbcb..e775543 100644
--- a/plugins/org.eclipse.jet.core/src/org/eclipse/jet/core/parser/ast/JETASTParser.java
+++ b/plugins/org.eclipse.jet.core/src/org/eclipse/jet/core/parser/ast/JETASTParser.java
@@ -12,7 +12,7 @@
*
* </copyright>
*
- * $Id: JETASTParser.java,v 1.1 2007/04/04 14:53:53 pelder Exp $
+ * $Id: JETASTParser.java,v 1.2 2009/01/26 21:49:15 pelder Exp $
*/
package org.eclipse.jet.core.parser.ast;
@@ -26,6 +26,7 @@ import org.eclipse.jet.core.parser.ITagLibraryResolver;
import org.eclipse.jet.core.parser.ITemplateInput;
import org.eclipse.jet.core.parser.ITemplateResolver;
import org.eclipse.jet.core.parser.RecursiveIncludeException;
+import org.eclipse.jet.internal.core.parser.IJETParser2;
import org.eclipse.jet.internal.core.parser.InternalJET1Parser;
import org.eclipse.jet.internal.core.parser.InternalJET2Parser;
import org.eclipse.jet.taglib.TagLibrary;
@@ -34,7 +35,7 @@ import org.eclipse.jet.taglib.TagLibrary;
* Parser for creating JET ASTs
* @since 0.8.0
*/
-public final class JETASTParser implements IJETParser {
+public final class JETASTParser implements IJETParser, IJETParser2 {
private static final class NullTagLibraryResolver implements
ITagLibraryResolver {
@@ -179,4 +180,12 @@ public final class JETASTParser implements IJETParser {
return parser.parse(template);
}
+ public Object parse(char[] template, String templatePath) {
+ if(parser instanceof IJETParser2) {
+ return ((IJETParser2) parser).parse(template, templatePath);
+ } else {
+ return parser.parse(template);
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.jet.core/src/org/eclipse/jet/internal/core/parser/IJETParser2.java b/plugins/org.eclipse.jet.core/src/org/eclipse/jet/internal/core/parser/IJETParser2.java
new file mode 100644
index 0000000..50a00d6
--- /dev/null
+++ b/plugins/org.eclipse.jet.core/src/org/eclipse/jet/internal/core/parser/IJETParser2.java
@@ -0,0 +1,36 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2009 IBM Corporation 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:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id: IJETParser2.java,v 1.2 2009/01/26 21:49:15 pelder Exp $
+ */
+package org.eclipse.jet.internal.core.parser;
+
+import org.eclipse.jet.core.parser.IJETParser;
+
+/**
+ * Extension interface to {@link IJETParser}
+ *
+ * NOTE: This should be public
+ */
+public interface IJETParser2 extends IJETParser
+{
+ /**
+ * Parse contents as a JET template
+ * @param template the template
+ * @param templatePath the templatePath corresponding to the content of <code>null</code> if unknown
+ * @return the root of the AST
+ */
+ public Object parse(char[] template, String templatePath);
+
+}
diff --git a/plugins/org.eclipse.jet.core/src/org/eclipse/jet/internal/core/parser/InternalJET1Parser.java b/plugins/org.eclipse.jet.core/src/org/eclipse/jet/internal/core/parser/InternalJET1Parser.java
index 4fbdabe..0d0b907 100644
--- a/plugins/org.eclipse.jet.core/src/org/eclipse/jet/internal/core/parser/InternalJET1Parser.java
+++ b/plugins/org.eclipse.jet.core/src/org/eclipse/jet/internal/core/parser/InternalJET1Parser.java
@@ -10,7 +10,7 @@
*
* </copyright>
*
- * $Id: InternalJET1Parser.java,v 1.2 2007/04/12 18:02:42 pelder Exp $
+ * $Id: InternalJET1Parser.java,v 1.3 2009/01/26 21:49:15 pelder Exp $
* /
*******************************************************************************/
@@ -58,7 +58,7 @@ import org.eclipse.jet.internal.l10n.JET2Messages;
* JET Parser Listener used by the JET1 Syntax
*
*/
-public class InternalJET1Parser implements JETParseEventListener2, IJETParser {
+public class InternalJET1Parser implements JETParseEventListener2, IJETParser, IJETParser2 {
/**
* Enumeratin of IncludeFailActions
@@ -567,13 +567,31 @@ public class InternalJET1Parser implements JETParseEventListener2, IJETParser {
}
public Object parse(char[] template) {
+ return parse(template, "");
+ }
+
+ public Object parse(char[] template, String templatePath) {
+ final ITemplateInput templateInput;
+ final URI baseLocation;
+ if(templatePath == null) {
+ templatePath = "";
+ }
+ if(templatePath.length() > 0) {
+ templateInput = templateResolver.getInput(templatePath);
+ templateInputs.push(templateInput);
+ baseLocation = templateInput.getBaseLocation();
+ } else {
+ templateInput = null;
+ baseLocation = null;
+ }
if (compilationUnit == null) {
compilationUnit = new JETAST()
- .newJETCompilationUnit(null, "", null); //$NON-NLS-1$
+ .newJETCompilationUnit(baseLocation, templatePath, null);
ast = compilationUnit.getAst();
}
try {
- reader = new JETReader(null, "", new CharArrayReader(template)); //$NON-NLS-1$
+ reader = new JETReader(baseLocation == null ? null : baseLocation
+ .toString(), templatePath, new CharArrayReader(template)); //$NON-NLS-1$
intermalParse();
} catch (JETException e) {
// create a minimal compilation unit with the exeception recorded as the error.
@@ -581,8 +599,9 @@ public class InternalJET1Parser implements JETParseEventListener2, IJETParser {
.getLocalizedMessage(), null, 0, 0, 1, 1);
}
return compilationUnit;
- }
+ }
+
/**
* @throws JETException
*/
diff --git a/plugins/org.eclipse.jet.editor/.classpath b/plugins/org.eclipse.jet.editor/.classpath
index 751c8f2..64c5e31 100644
--- a/plugins/org.eclipse.jet.editor/.classpath
+++ b/plugins/org.eclipse.jet.editor/.classpath
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/plugins/org.eclipse.jet.editor/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.jet.editor/.settings/org.eclipse.jdt.core.prefs
index e302ef5..e086c0a 100644
--- a/plugins/org.eclipse.jet.editor/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/org.eclipse.jet.editor/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,12 @@
-#Tue Jan 09 21:39:30 PST 2007
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+#Mon Jan 26 16:41:11 EST 2009
org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
diff --git a/plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF
index b71d14d..6fdefcb 100644
--- a/plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jet.editor/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jet.editor; singleton:=true
-Bundle-Version: 0.9.0.qualifier
+Bundle-Version: 0.9.100.qualifier
Bundle-Activator: org.eclipse.jet.internal.editor.Activator
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)",
@@ -29,3 +29,5 @@ Export-Package: org.eclipse.jet.internal.editor,
org.eclipse.jet.internal.editor.scanners
Bundle-Vendor: %providerName
Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
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 a64041e..d8c2b27 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
@@ -26,6 +26,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jet.core.parser.ast.Comment;
+import org.eclipse.jet.core.parser.ast.IncludedContent;
import org.eclipse.jet.core.parser.ast.JETASTElement;
import org.eclipse.jet.core.parser.ast.JETASTVisitor;
import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
@@ -289,13 +290,13 @@ public class JETTextEditor extends TextEditor {
public JETCompilationUnit requestCompilationUnit() {
if (cUnit == null || cUnitInvalidated) {
IEditorInput editorInput = getEditorInput();
+ String templatePath = editorInput.getName();
+ if (editorInput instanceof IFileEditorInput)
+ templatePath = ((IFileEditorInput)editorInput).getFile().getProjectRelativePath().toString();
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 {
- cUnit = compilationHelper().getASTFromSource(sourceViewer.getDocument().get());
+ cUnit = compilationHelper().getASTFromSource(sourceViewer.getDocument().get(), templatePath);
}
PositionsCollector collector = new PositionsCollector();
cUnit.accept(collector);
@@ -412,6 +413,11 @@ public class JETTextEditor extends TextEditor {
return matchOffset(expression);
}
+ public boolean visit(IncludedContent content) {
+ // don't process include content
+ return false;
+ }
+
public boolean visit(JavaScriptlet scriptlet) {
return matchOffset(scriptlet);
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/CompilationHelper.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/CompilationHelper.java
index 560d47d..92f7089 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/CompilationHelper.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/CompilationHelper.java
@@ -12,11 +12,13 @@
*
* </copyright>
*
- * $Id: CompilationHelper.java,v 1.1 2007/06/01 20:33:32 pelder Exp $
+ * $Id: CompilationHelper.java,v 1.2 2009/01/26 21:49:16 pelder Exp $
*/
package org.eclipse.jet.internal.compiler;
+import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -25,7 +27,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jet.JET2Platform;
import org.eclipse.jet.compiler.CompileOptionsManager;
import org.eclipse.jet.core.compiler.JETCompilerOptions;
@@ -36,10 +40,15 @@ import org.eclipse.jet.core.parser.ast.JETASTParser;
import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
import org.eclipse.jet.internal.InternalJET2Platform;
import org.eclipse.jet.internal.parser.resources.WorkspaceTemplateResolverBuilder;
+import org.eclipse.jet.internal.runtime.model.XMLDOMLoader;
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.xpath.XPath;
+import org.eclipse.jet.xpath.XPathException;
+import org.eclipse.jet.xpath.XPathFactory;
+import org.eclipse.jet.xpath.XPathRuntimeException;
/**
@@ -55,6 +64,10 @@ import org.eclipse.jet.transform.IJETBundleDescriptor;
*/
public class CompilationHelper
{
+ private static final String EMF_CODEGEN_JETPROPERTIES = ".jetproperties"; //$NON-NLS-1$
+
+ private static final String EMF_CODEGEN_JET_NATURE_ID = "org.eclipse.emf.codegen.jet.IJETNature"; //$NON-NLS-1$
+
private static final ITagLibraryResolver TAG_LIBRARY_RESOLVER = new ITagLibraryResolver()
{
@@ -131,9 +144,21 @@ public class CompilationHelper
* This method always returns an AST; use {@link JETCompilationUnit#getProblems()} to discover problems.
* @param source
* @return a {@link JETCompilationUnit}.
+ * @deprecated Use {@link #getASTFromSource(String,String)} instead
*/
public JETCompilationUnit getASTFromSource(String source) {
- return (JETCompilationUnit)getASTParser().parse(source.toCharArray());
+ return getASTFromSource(source, null);
+ }
+
+ /**
+ * Return the JET AST for the given template source.
+ * This method always returns an AST; use {@link JETCompilationUnit#getProblems()} to discover problems.
+ * @param source
+ * @param templatePath TODO
+ * @return a {@link JETCompilationUnit}.
+ */
+ public JETCompilationUnit getASTFromSource(String source, String templatePath) {
+ return (JETCompilationUnit)getASTParser().parse(source.toCharArray(),templatePath);
}
/**
@@ -192,11 +217,69 @@ public class CompilationHelper
public Map getOptions()
{
if(options == null) {
- options = CompileOptionsManager.getOptions(project);
+ if(isLegacyJET1Project(project)) {
+ options = getLegacyJETOptions(project);
+ } else {
+ options = CompileOptionsManager.getOptions(project);
+ }
+ }
+ return options;
+ }
+
+ private Map getLegacyJETOptions(IProject project)
+ {
+ final IFile jetProperties = project.getFile(EMF_CODEGEN_JETPROPERTIES);
+ final Map options = new HashMap();
+ options.put(JETCompilerOptions.OPTION_JET_SPECIFICATION_VERSION, new Integer(JETAST.JET_SPEC_V1));
+ options.put(JETCompilerOptions.OPTION_V1_BASE_TRANSFORMATION, JETCompilerOptions.DEFAULT_V1_BASE_TRANSFORMATION);
+ options.put(JETCompilerOptions.OPTION_V1_COMPILE_BASE_TEMPLATES, JETCompilerOptions.DEFAULT_V1_COMPILE_BASE_TEMPLATES);
+ if(jetProperties.exists()) {
+ loadLegacyJetProperties(jetProperties, options);
+ } else {
+ options.put(JETCompilerOptions.OPTION_V1_TEMPLATES_DIR, JETCompilerOptions.DEFAULT_V1_TEMPLATES_DIR);
+ options.put(JETCompilerOptions.OPTION_JAVA_OUTPUT_FOLDER, "src"); //$NON-NLS-1$
}
return options;
}
+ private void loadLegacyJetProperties(final IFile jetProperties, final Map options)
+ {
+ try
+ {
+ final Object doc = new XMLDOMLoader().load(jetProperties.getLocationURI().toURL());
+ final XPath xpath = XPathFactory.newInstance().newXPath(null);
+ final String templatePath = xpath.compile("/jet-settings/template-container").evaluateAsString(doc); //$NON-NLS-1$
+ final String outputPath = xpath.compile("/jet-settings/source-container").evaluateAsString(doc); //$NON-NLS-1$
+ options.put(JETCompilerOptions.OPTION_V1_TEMPLATES_DIR, templatePath);
+ options.put(JETCompilerOptions.OPTION_JAVA_OUTPUT_FOLDER, outputPath);
+ }
+ catch (MalformedURLException e)
+ {
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ catch (XPathException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private boolean isLegacyJET1Project(IProject project2)
+ {
+ try
+ {
+ return project.hasNature(EMF_CODEGEN_JET_NATURE_ID) || !project.hasNature(JET2Platform.JET2_NATURE_ID);
+ }
+ catch (CoreException e)
+ {
+ // only happens if project is closed - can't do much in that case, anyhow...
+ return false;
+ }
+ }
+
/**
* Create a map of tag library prefix to tag library id.
* @param tagLibraryReferences an array of tag library references

Back to the top