summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-03-21 10:28:21 (EST)
committer pelder2006-03-21 10:28:21 (EST)
commite482ac503827d07564ea20ebf2d2fa6d6e85a6a6 (patch)
treeebfd803f354748c54507f7dc003e4a341bb3a685
parentdf822e3aadb0ca3cb46a8df766500d84345d84d0 (diff)
downloadorg.eclipse.jet-e482ac503827d07564ea20ebf2d2fa6d6e85a6a6.zip
org.eclipse.jet-e482ac503827d07564ea20ebf2d2fa6d6e85a6a6.tar.gz
org.eclipse.jet-e482ac503827d07564ea20ebf2d2fa6d6e85a6a6.tar.bz2
[131380] Implement better whitespace striping around tags.
-rw-r--r--plugins/org.eclipse.jet/schema/tagLibraries.exsd66
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/BodyContentWriter.java3
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/IWriterListener.java5
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Platform.java2
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Writer.java4
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/ASTCompilerParseListener.java17
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/BodyElements.java31
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/Comment.java5
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/DefaultJET2ASTVisitor.java8
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2AST.java15
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2ASTElement.java81
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2ASTVisitor.java6
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2CompilationUnit.java5
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Compiler.java2
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Declaration.java5
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Directive.java5
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Expression.java5
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Scriptlet.java5
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextElement.java67
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextRewritingVisitor.java210
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextTrimmingVisitor.java163
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLBodyElement.java56
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLBodyElementEnd.java90
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLElement.java4
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLEmptyElement.java5
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/parser/LineInfo.java5
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/TagDefinitionImpl.java27
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/AbstractCustomTag.java2
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/TagDefinition.java7
29 files changed, 643 insertions, 263 deletions
diff --git a/plugins/org.eclipse.jet/schema/tagLibraries.exsd b/plugins/org.eclipse.jet/schema/tagLibraries.exsd
index a6b699d..c395605 100644
--- a/plugins/org.eclipse.jet/schema/tagLibraries.exsd
+++ b/plugins/org.eclipse.jet/schema/tagLibraries.exsd
@@ -220,6 +220,22 @@
</restriction>
</simpleType>
</attribute>
+ <attribute name="whenContainingLineIsEmpty" use="default" value="remove">
+ <annotation>
+ <documentation>
+ Defines the compiler behavior when the tag occurs on an otherwise empty line. If &apos;remove&apos; is selected, the whitespace and trailing new line are not included in the templates output. In general, if a tag writes content, then this attribute should be set to &apos;preserve&apos;.
+&lt;p&gt;The default for iterating tags is &apos;remove&apos;.&lt;/p&gt;
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="preserve">
+ </enumeration>
+ <enumeration value="remove">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
</complexType>
</element>
@@ -273,6 +289,22 @@
</restriction>
</simpleType>
</attribute>
+ <attribute name="whenContainingLineIsEmpty" use="default" value="remove">
+ <annotation>
+ <documentation>
+ Defines the compiler behavior when the tag occurs on an otherwise empty line. If &apos;remove&apos; is selected, the whitespace and trailing new line are not included in the templates output. In general, if a tag writes content, then this attribute should be set to &apos;preserve&apos;.
+&lt;p&gt;The default for conditional tags is &apos;remove&apos;.&lt;/p&gt;
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="preserve">
+ </enumeration>
+ <enumeration value="remove">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
</complexType>
</element>
@@ -311,6 +343,24 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="whenContainingLineIsEmpty" use="default" value="preserve">
+ <annotation>
+ <documentation>
+ Defines the compiler behavior when the tag occurs on an otherwise empty line. If &apos;remove&apos; is selected, the whitespace and trailing new line are not included in the templates output. In general, if a tag writes content, then this attribute should be set to &apos;preserve&apos;.
+&lt;p&gt;
+The default for empty tags is &apos;preserve&apos;.
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="preserve">
+ </enumeration>
+ <enumeration value="remove">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
</complexType>
</element>
@@ -421,6 +471,22 @@ is permitted if &lt;code&gt;true&lt;/code&gt; is specified. If not specified, th
</documentation>
</annotation>
</attribute>
+ <attribute name="whenContainingLineIsEmpty" use="default" value="remove">
+ <annotation>
+ <documentation>
+ Defines the compiler behavior when the tag occurs on an otherwise empty line. If &apos;remove&apos; is selected, the whitespace and trailing new line are not included in the templates output. In general, if a tag writes content, then this attribute should be set to &apos;preserve&apos;.
+&lt;p&gt;The default for container tags is &apos;remove&apos;.&lt;/p&gt;
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="remove">
+ </enumeration>
+ <enumeration value="preserve">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
</complexType>
</element>
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/BodyContentWriter.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/BodyContentWriter.java
index 18e4f18..44bceba 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/BodyContentWriter.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/BodyContentWriter.java
@@ -24,6 +24,7 @@ import java.util.Iterator;
import java.util.Map;
import org.eclipse.jet.internal.InternalJET2Platform;
+import org.eclipse.jet.taglib.JET2TagException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.DefaultPositionUpdater;
@@ -172,7 +173,7 @@ public class BodyContentWriter implements JET2Writer
}
}
- public final void finalizeContent(Object file)
+ public final void finalizeContent(Object file) throws JET2TagException
{
for (Iterator i = listeners.values().iterator(); i.hasNext();)
{
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/IWriterListener.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/IWriterListener.java
index d4b3757..0b2a747 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/IWriterListener.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/IWriterListener.java
@@ -17,6 +17,8 @@
package org.eclipse.jet;
+import org.eclipse.jet.taglib.JET2TagException;
+
/**
* Callback interface allowing participation in the finalization of a {@link JET2Writer}'s content.
@@ -31,8 +33,9 @@ public interface IWriterListener
* @param file a handle to object to which the content will ultimately be written. The standard
* JET2 Workspace tags pass an org.eclipse.core.resources.IFile, but other tags may pass objects
* of other types.
+ * @throws JET2TagException
*/
- public abstract void finalizeContent(JET2Writer writer, Object file);
+ public abstract void finalizeContent(JET2Writer writer, Object file) throws JET2TagException;
/**
* Perform any post processing on the committed file based on content written.
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Platform.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Platform.java
index f82fc1d..61139b2 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Platform.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Platform.java
@@ -216,7 +216,7 @@ public class JET2Platform
public Diagnostic run(JET2TemplateLoader loader) throws JET2TagException
{
- XPathContextExtender xpe = new XPathContextExtender(context);
+ XPathContextExtender xpe = XPathContextExtender.getInstance(context);
// once the bundle is dynamically loaded, force the extension point managers
// to refresh extensions in the loaded bundle.
// OSGi asynchronously broadcasts registry updates, but this is not prompt enough,
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Writer.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Writer.java
index 21395f7..b8dcef6 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Writer.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/JET2Writer.java
@@ -18,6 +18,7 @@
package org.eclipse.jet;
+import org.eclipse.jet.taglib.JET2TagException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
@@ -124,9 +125,10 @@ public interface JET2Writer
* is finalized. The standard JET2 Workspace tags pass an org.eclipse.core.resources.IFile.
* </p>
* @param file the file object to which the finalized contents will be written.
+ * @throws JET2TagException if an error occurs
* @see #addEventListener(String, IWriterListener)
*/
- public abstract void finalizeContent(Object file);
+ public abstract void finalizeContent(Object file) throws JET2TagException;
/**
* Inform listeners that the content has been committed to some permanent store.
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/ASTCompilerParseListener.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/ASTCompilerParseListener.java
index b8d809e..209abd9 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/ASTCompilerParseListener.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/ASTCompilerParseListener.java
@@ -390,6 +390,8 @@ class ASTCompilerParseListener implements JETParseEventListener2
public void handleXMLEndTag(String tagName, JETMark start, JETMark stop)
{
int tagIndex = elementStack.findElementIndex(tagName);
+ XMLBodyElementEnd endTag = ast.createXMLBodyElementEnd(start.getLine(), start.getCol(),
+ start.getCursor(), stop.getCursor(), tagName);
if (tagIndex == -1)
{
compilationUnit.createProblem(
@@ -416,9 +418,20 @@ class ASTCompilerParseListener implements JETParseEventListener2
start.getLine(), start.getCol());
}
XMLBodyElement topElement = elementStack.pop();
- topElement.setEndTagStart(start.getCursor());
- topElement.setEndTagEnd((stop.getCursor()));
+ endTag.setStartTag(topElement);
+ topElement.setEndTag(endTag);
}
+ if (elementStack.isEmpty())
+ {
+ compilationUnit.getInternalBodyElements().addBodyElement(endTag);
+ }
+ else
+ {
+ XMLBodyElement topElement = (XMLBodyElement)elementStack.peek();
+
+ topElement.getInternalBodyElements().addBodyElement(endTag);
+ }
+
}
/**
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/BodyElements.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/BodyElements.java
index 66a2c06..5dbe5da 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/BodyElements.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/BodyElements.java
@@ -136,4 +136,35 @@ class BodyElements
return nextElement;
}
+ public void addBodyElement(XMLBodyElementEnd endTag)
+ {
+ bodyElements.add(endTag);
+ endTag.setParent(owner);
+ }
+
+ /**
+ *
+ * @param element
+ * @return
+ */
+ public JET2ASTElement elementBefore(JET2ASTElement element)
+ {
+ JET2ASTElement prevElement = null;
+ if (bodyElements == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ int index = bodyElements.indexOf(element);
+ if (index == -1)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ if (index > 0)
+ {
+ prevElement = (JET2ASTElement)bodyElements.get(index - 1);
+ }
+ return prevElement;
+ }
+
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/Comment.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/Comment.java
index 6dc512b..c37920c 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/Comment.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/Comment.java
@@ -83,4 +83,9 @@ public class Comment extends JET2ASTElement
return new String(comment);
}
+ public boolean removeLineWhenOtherwiseEmpty()
+ {
+ return true;
+ }
+
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/DefaultJET2ASTVisitor.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/DefaultJET2ASTVisitor.java
index af64346..5d09420 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/DefaultJET2ASTVisitor.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/DefaultJET2ASTVisitor.java
@@ -115,6 +115,14 @@ public abstract class DefaultJET2ASTVisitor implements JET2ASTVisitor
}
/**
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.XMLBodyElementEnd)
+ */
+ public void visit(XMLBodyElementEnd xmlBodyElementEnd)
+ {
+ // do nothing
+ }
+
+ /**
* @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.Comment)
*/
public void visit(Comment comment)
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2AST.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2AST.java
index 979b0d2..2a91973 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2AST.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2AST.java
@@ -158,4 +158,19 @@ class JET2AST
return new Comment(this, line, colOffset, start, end, commentStart, commentEnd, comment);
}
+ /**
+ * Create a new XML end element corresponding to the end of a XMLBodyElement.
+ * @param line
+ * @param col
+ * @param start
+ * @param end
+ * @param tagName
+ * @param startTag
+ * @return
+ */
+ XMLBodyElementEnd createXMLBodyElementEnd(int line, int col, int start, int end, String tagName)
+ {
+ return new XMLBodyElementEnd(this, line, col, start, end);
+ }
+
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2ASTElement.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2ASTElement.java
index 208030a..710a399 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2ASTElement.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2ASTElement.java
@@ -106,42 +106,103 @@ public abstract class JET2ASTElement
}
/**
- * Return the line the element starts on
- * @return the line
+ * Return the line (one-based) on which the element starts.
+ * @return the line number.
*/
public final int getLine()
{
return line;
}
+ /**
+ *
+ * @return
+ * @deprecated
+ */
public final JET2ASTElement getNextSibling()
{
JET2ASTElement next = null;
if (parent != null)
{
- BodyElements bodyElements = null;
- if (parent instanceof JET2CompilationUnit)
- {
- bodyElements = ((JET2CompilationUnit)parent).getInternalBodyElements();
- }
- else if (parent instanceof XMLBodyElement)
+ BodyElements bodyElements = getBodyElements(parent);
+ if (bodyElements != null)
{
- bodyElements = ((XMLBodyElement)parent).getInternalBodyElements();
+ next = bodyElements.elementAfter(this);
}
+ }
+ return next;
+ }
+
+ /**
+ * @param element The element for which body elements are sought
+ * @return the body elements object
+ */
+ private BodyElements getBodyElements(JET2ASTElement element)
+ {
+ BodyElements bodyElements = null;
+ if (parent instanceof JET2CompilationUnit)
+ {
+ bodyElements = ((JET2CompilationUnit)parent).getInternalBodyElements();
+ }
+ else if (parent instanceof XMLBodyElement)
+ {
+ bodyElements = ((XMLBodyElement)parent).getInternalBodyElements();
+ }
+ return bodyElements;
+ }
+
+ public JET2ASTElement getNextElement()
+ {
+ JET2ASTElement next = null;
+ if(parent != null)
+ {
+ BodyElements bodyElements = getBodyElements(parent);
if (bodyElements != null)
{
next = bodyElements.elementAfter(this);
}
+ else
+ {
+ next = parent.getNextElement();
+ }
+
}
return next;
}
+
+ public JET2ASTElement getPrevElement()
+ {
+ JET2ASTElement prev = null;
+ if(parent != null)
+ {
+ BodyElements bodyElements = getBodyElements(parent);
+ if (bodyElements != null)
+ {
+ prev = bodyElements.elementBefore(this);
+ }
+ else
+ {
+ prev = parent.getPrevElement();
+ }
+ }
+ return prev;
+ }
/**
- * @return Returns the column.
+ * Return the column number (one-based) at which the element starts.
+ * @return the column number.
*/
public final int getColumn()
{
return column;
}
+ /**
+ * Indicate whether the the surrounding whitespace, including the trailing new line
+ * should be removed from the template output. In general, elements that create
+ * output should return <code>false</code>,
+ * while element that do should should return <code>true</code>.
+ * @return <code>true</code> if the containing line should be removed if otherwise empty.
+ */
+ public abstract boolean removeLineWhenOtherwiseEmpty();
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2ASTVisitor.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2ASTVisitor.java
index 58d104b..f99d5af 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2ASTVisitor.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2ASTVisitor.java
@@ -86,6 +86,12 @@ public interface JET2ASTVisitor
public abstract void endVisit(XMLBodyElement xmlBodyElement);
/**
+ * Visit the end tag of an XMLBodyElement. Happens after {@link #endVisit(XMLBodyElement)}.
+ * @param xmlBodyElementEnd
+ */
+ public abstract void visit(XMLBodyElementEnd xmlBodyElementEnd);
+
+ /**
* Visit a Comment element.
* @param comment
*/
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2CompilationUnit.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2CompilationUnit.java
index b402649..1233ac7 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2CompilationUnit.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2CompilationUnit.java
@@ -295,4 +295,9 @@ public final class JET2CompilationUnit extends JET2ASTElement
{
this.outputJavaPackage = outputJavaPackage;
}
+
+ public boolean removeLineWhenOtherwiseEmpty()
+ {
+ return false;
+ }
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Compiler.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Compiler.java
index 34324ca..60c8071 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Compiler.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Compiler.java
@@ -218,7 +218,7 @@ public class JET2Compiler
if (!cu.hasErrors())
{
- cu.accept(new TextRewritingVisitor());
+ cu.accept(new TextTrimmingVisitor());
writeCompiledOutput(file, cu);
}
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Declaration.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Declaration.java
index 967b0a7..5edb5ae 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Declaration.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Declaration.java
@@ -49,4 +49,9 @@ public final class JET2Declaration extends JavaElement
visitor.visit(this);
}
+ public boolean removeLineWhenOtherwiseEmpty()
+ {
+ return true;
+ }
+
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Directive.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Directive.java
index 8409b16..4f55b6b 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Directive.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Directive.java
@@ -77,4 +77,9 @@ public final class JET2Directive extends JET2ASTElement
visitor.visit(this);
}
+ public boolean removeLineWhenOtherwiseEmpty()
+ {
+ return true;
+ }
+
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Expression.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Expression.java
index 129128e..084369b 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Expression.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Expression.java
@@ -50,4 +50,9 @@ public final class JET2Expression extends JavaElement
visitor.visit(this);
}
+ public boolean removeLineWhenOtherwiseEmpty()
+ {
+ return false;
+ }
+
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Scriptlet.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Scriptlet.java
index 2660768..4461503 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Scriptlet.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Scriptlet.java
@@ -49,4 +49,9 @@ public final class JET2Scriptlet extends JavaElement
visitor.visit(this);
}
+ public boolean removeLineWhenOtherwiseEmpty()
+ {
+ return true;
+ }
+
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextElement.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextElement.java
index 9f8930b..2dce261 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextElement.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextElement.java
@@ -16,6 +16,8 @@
*/
package org.eclipse.jet.compiler;
+import org.eclipse.jet.internal.parser.LineInfo;
+
/**
* Define a Text Element in the JET2 AST
@@ -28,6 +30,12 @@ public final class TextElement extends JET2ASTElement
private char[] text;
+ private boolean trimLastLine = false;
+
+ private boolean trimFirstLine = false;
+
+ private final LineInfo[] lines;
+
/**
* Create an instance
* @param jet2ast the AST
@@ -37,6 +45,7 @@ public final class TextElement extends JET2ASTElement
{
super(jet2ast, -1, -1, 0, 0);
this.text = handleEscapes(text);
+ this.lines = LineInfo.calculateLines(this.text);
}
/**
@@ -73,12 +82,70 @@ public final class TextElement extends JET2ASTElement
*/
public char[] getText()
{
+ char[] result = text;
+ if(lines.length > 0)
+ {
+ int start = isTrimFirstLine() && lines[0].hasDelimiter()
+ ? lines[0].getEnd() + lines[0].getDelimiter().length() : 0;
+ int end = isTrimLastLine() && !lines[lines.length -1].hasDelimiter()
+ ? lines[lines.length - 1].getStart() : text.length;
+ result = new String(text, start, end - start).toCharArray();
+ }
+ return result;
+ }
+
+ public char[] getRawText()
+ {
return text;
}
+ /**
+ *
+ * @param newText
+ * @deprecated
+ */
void setText(char[] newText)
{
text = newText;
}
+ public boolean removeLineWhenOtherwiseEmpty()
+ {
+ return false;
+ }
+
+ public void setTrimLastLine(boolean trim)
+ {
+ this.trimLastLine = trim;
+ }
+
+ /**
+ * @return Returns the trimLastLine.
+ */
+ public final boolean isTrimLastLine()
+ {
+ return trimLastLine;
+ }
+
+ public void setTrimFirstLine(boolean trim)
+ {
+ this.trimFirstLine = trim;
+ }
+
+ /**
+ * @return Returns the trimFirstLine.
+ */
+ public final boolean isTrimFirstLine()
+ {
+ return trimFirstLine;
+ }
+
+ /**
+ * @return Returns the lines.
+ */
+ public final LineInfo[] getLines()
+ {
+ return lines;
+ }
+
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextRewritingVisitor.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextRewritingVisitor.java
deleted file mode 100644
index 4140027..0000000
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextRewritingVisitor.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * <copyright>
- *
- * Copyright (c) 2005 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$
- */
-
-package org.eclipse.jet.compiler;
-
-
-import java.util.List;
-
-import org.eclipse.jet.taglib.CustomTagKind;
-
-
-/**
- * @author pelder
- *
- */
-class TextRewritingVisitor extends DefaultJET2ASTVisitor implements JET2ASTVisitor
-{
-
- private static final char[] NULL_CHAR_ARRAY = new char []{};
-
- private boolean firstText;
-
- /**
- *
- */
- public TextRewritingVisitor()
- {
- super();
- firstText = true;
- }
-
- /**
- * Re-write text elements immediately preceding the body element's close tag, in order to strip final lines, if necessary.
- * @param xmlBodyElement the XML body element being visited
- */
- public void endVisit(XMLBodyElement xmlBodyElement)
- {
- boolean needToStripLastNewLine = false;
- TextElement text = null;
-
- if (isTagRequiringStripping(xmlBodyElement))
- {
- needToStripLastNewLine = true;
- List bodyElements = xmlBodyElement.getBodyElements();
- if (bodyElements.size() > 0)
- {
- JET2ASTElement last = (JET2ASTElement)bodyElements.get(bodyElements.size() - 1);
- if (last instanceof TextElement)
- {
- text = (TextElement)last;
- }
- }
- }
-
- if (needToStripLastNewLine && text != null)
- {
- text.setText(stripLastNewLineWithBlanks(text.getText()));
- }
- }
-
- /**
- * Test whether this element is an XML tag for which preceding blanks and NL should be stripped.
- * @param xmlElement the element to test
- * @return <code>true</code> if the text should be stripped, <code>false</code> otherwise.
- */
- private final boolean isTagRequiringStripping(XMLElement xmlElement)
- {
- CustomTagKind kind = xmlElement.getTagDefinition().getKind();
- return kind == CustomTagKind.CONDITIONAL || kind == CustomTagKind.ITERATING || kind == CustomTagKind.CONTAINER;
- }
-
- /**
- * Strip off an initial new line
- * @param chars
- * @return the rewritten char array
- */
- private final char[] stripFirstNewLine(char[] chars)
- {
- if (chars.length >= 2 && (chars[0] == '\n' && chars[1] == '\r' || chars[0] == '\r' && chars[1] == '\n'))
- {
- chars = subarray(chars, 2);
-
- }
- else if (chars.length == 1 && (chars[0] == '\n' || chars[0] == '\r'))
- {
- chars = subarray(chars, 1);
- }
- return chars;
- }
-
- private final char[] stripLastNewLineWithBlanks(char[] chars)
- {
- int i = chars.length - 1;
- while (i > 0 && chars[i] == ' ')
- {
- --i;
- }
- if (i >= 0 && chars[i] == '\n')
- {
- if (i > 0 && chars[i - 1] == '\r')
- {
- --i;
- }
- if (i == 0)
- {
- return NULL_CHAR_ARRAY;
- }
- else
- {
- return subarray(chars, 0, i);
- }
- }
- else
- {
- return chars;
- }
- }
-
- /**
- * char[] equivalent of {@link String#substring(int)}.
- * @param chars the char array to subset
- * @param start the start index of the subset
- * @return a new char array containing the subset.
- * @throws NullPointerException if <code>chars</code> is <code>null</code>.
- * @throws IllegalArgumentException if start is negative, or if start
- * is larger than the size of chars.
- */
- private char[] subarray(char[] chars, int start)
- {
- return subarray(chars, start, chars.length - start);
- }
-
- /**
- * char[] equivalent of {@link String#substring(int,int)}.
- *
- * @param chars
- * the char array to subset
- * @param start
- * the start index of the subset
- * @param length
- * the length of the subset
- * @return a new char array containing the subset.
- * @throws NullPointerException
- * if <code>chars</code> is <code>null</code>.
- * @throws IllegalArgumentException
- * if start or length are negative, or if start+length is larger
- * than the size of chars.
- */
- private char[] subarray(char[] chars, int start, int length)
- {
- if (chars == null)
- {
- throw new NullPointerException();
- }
- if (start < 0 || length < 0 || start > chars.length || start + length > chars.length)
- {
- throw new IllegalArgumentException();
- }
- char[] newchars = new char [length];
- System.arraycopy(chars, start, newchars, 0, length);
- chars = newchars;
- return chars;
- }
-
- /**
- * Implement new line stripping rules on text elements.
- * @param a text element
- */
- public void visit(TextElement text)
- {
- if (firstText)
- {
- // first text processing
- text.setText(stripFirstNewLine(text.getText()));
- firstText = false;
- }
- JET2ASTElement next = text.getNextSibling();
- boolean needToStripLastNewLine = false;
-
- if (next instanceof JET2Declaration || next instanceof JET2Scriptlet || next instanceof JET2Directive)
- {
- needToStripLastNewLine = true;
- }
- else if (next instanceof XMLElement)
- {
- XMLElement nextXmlElement = (XMLElement)next;
-
- needToStripLastNewLine = isTagRequiringStripping(nextXmlElement);
- }
-
- if (needToStripLastNewLine)
- {
- text.setText(stripLastNewLineWithBlanks(text.getText()));
- }
- }
-}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextTrimmingVisitor.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextTrimmingVisitor.java
new file mode 100644
index 0000000..6c83df8
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/TextTrimmingVisitor.java
@@ -0,0 +1,163 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2005 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$
+ */
+
+package org.eclipse.jet.compiler;
+
+
+import org.eclipse.jet.internal.parser.LineInfo;
+
+
+/**
+ * A JET AST Visitor that strips whitespace and new-lines
+ *
+ */
+class TextTrimmingVisitor extends DefaultJET2ASTVisitor implements JET2ASTVisitor
+{
+ /**
+ *
+ */
+ public TextTrimmingVisitor()
+ {
+ super();
+ }
+
+ private void checkAndStrip(JET2ASTElement element)
+ {
+ if(element.removeLineWhenOtherwiseEmpty())
+ {
+ JET2ASTElement prev = element.getPrevElement();
+ JET2ASTElement next = element.getNextElement();
+ if(endsWithEmtpyLine(prev) && startsWithEmptyLine(next))
+ {
+ trimLastLine(prev);
+ trimFirstLine(next);
+ }
+ }
+ }
+
+ private void trimLastLine(JET2ASTElement element)
+ {
+ if(element instanceof TextElement)
+ {
+ TextElement text = (TextElement)element;
+ text.setTrimLastLine(true);
+ }
+ }
+
+ private void trimFirstLine(JET2ASTElement element)
+ {
+ if(element instanceof TextElement)
+ {
+ TextElement text = (TextElement)element;
+ text.setTrimFirstLine(true);
+ }
+ }
+
+ private boolean startsWithEmptyLine(JET2ASTElement element)
+ {
+ if(element instanceof TextElement)
+ {
+ TextElement text = (TextElement)element;
+ final LineInfo[] lines = text.getLines();
+ if(lines.length > 0 && lines[0].hasDelimiter())
+ {
+ LineInfo line = lines[0];
+ if(new String(text.getRawText(), line.getStart(), line.getEnd() - line.getStart()).trim().length() == 0)
+ {
+ // first line is all whitespace
+ return true;
+ }
+ }
+ }
+ else if(element == null)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean endsWithEmtpyLine(JET2ASTElement element)
+ {
+ if(element instanceof TextElement)
+ {
+ TextElement text = (TextElement)element;
+ final LineInfo[] lines = text.getLines();
+ if(lines.length > 0)
+ {
+ LineInfo line = lines[lines.length - 1];
+ if(line.hasDelimiter()) {
+ // last line has a delimiter => this element start on col # 1
+ return true;
+ }
+ else if(new String(text.getRawText(), line.getStart(), line.getEnd() - line.getStart()).trim().length() == 0)
+ {
+ // last line is all whitespace
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if(element == null)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public void visit(JET2Declaration declaration)
+ {
+ checkAndStrip(declaration);
+ }
+
+ public void visit(JET2Directive directive)
+ {
+ checkAndStrip(directive);
+ }
+
+ public void visit(JET2Expression expression)
+ {
+ checkAndStrip(expression);
+ }
+
+ public void visit(JET2Scriptlet scriptlet)
+ {
+ checkAndStrip(scriptlet);
+ }
+
+ public void visit(XMLEmptyElement xmlEmptyElement)
+ {
+ checkAndStrip(xmlEmptyElement);
+ }
+
+ public void visit(XMLBodyElement xmlBodyElement)
+ {
+ checkAndStrip(xmlBodyElement);
+ }
+
+ public void visit(XMLBodyElementEnd xmlBodyElementEnd)
+ {
+ checkAndStrip(xmlBodyElementEnd);
+ }
+
+ public void visit(Comment comment)
+ {
+// checkAndStrip(comment);
+ }
+}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLBodyElement.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLBodyElement.java
index 96b57e9..2088364 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLBodyElement.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLBodyElement.java
@@ -33,12 +33,10 @@ import org.eclipse.jet.taglib.TagDefinition;
public final class XMLBodyElement extends XMLElement
{
- private int endTagStart;
-
- private int endTagEnd;
-
private BodyElements bodyElements = null;
+ private XMLBodyElementEnd endTag = null;
+
/**
* Create an instance
* @param ast the owning AST
@@ -56,24 +54,6 @@ public final class XMLBodyElement extends XMLElement
}
/**
- * Return the start offset of the end tag (&lt;/<i>tag</i>&gt;)
- * @return a doc relative index
- */
- public final int getEndTagStart()
- {
- return endTagStart;
- }
-
- /**
- * Return the end offset of the end tag (&lt;/<i>tag</i>&gt;)
- * @return a doc relative index
- */
- public final int getEndTagEnd()
- {
- return endTagEnd;
- }
-
- /**
* Return a object that allows writable access to the JET2 elements contained by this element.
* @return a BodyElements instance
*/
@@ -117,22 +97,34 @@ public final class XMLBodyElement extends XMLElement
}
- /**
- * Set the start offset of the XML end tag (&lt;/...&gt;).
- * @param endTagEnd a doc relative offset
- */
- void setEndTagEnd(int endTagEnd)
+ void setEndTag(XMLBodyElementEnd endTag)
{
- this.endTagEnd = endTagEnd;
+ this.endTag = endTag;
}
/**
- * Set the end offset of the XML end tag (&lt;/...&gt;).
- * @param endTagStart a doc relative offset
+ * @return Returns the endTag.
*/
- void setEndTagStart(int endTagStart)
+ public final XMLBodyElementEnd getEndTag()
{
- this.endTagStart = endTagStart;
+ return endTag;
+ }
+
+ public String toString()
+ {
+ return "Line " + getLine() + ": <" + getName() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
+ public JET2ASTElement getNextElement()
+ {
+
+ if(getBodyElements().size() > 0)
+ {
+ return (JET2ASTElement)getBodyElements().get(0);
+ }
+ else
+ {
+ return super.getNextElement();
+ }
+ }
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLBodyElementEnd.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLBodyElementEnd.java
new file mode 100644
index 0000000..974e656
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLBodyElementEnd.java
@@ -0,0 +1,90 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.jet.compiler;
+
+import java.util.List;
+
+
+/**
+ * Represent the closing tag of an XML Tag with a body.
+ */
+public class XMLBodyElementEnd extends JET2ASTElement
+{
+
+ private XMLBodyElement startTag;
+
+ /**
+ *
+ * @param ast
+ * @param line
+ * @param colOffset
+ * @param start
+ * @param end
+ * @param startTag
+ */
+ XMLBodyElementEnd(JET2AST ast, int line, int colOffset, int start, int end)
+ {
+ super(ast, line, colOffset, start, end);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTElement#accept(org.eclipse.jet.compiler.JET2ASTVisitor)
+ */
+ public void accept(JET2ASTVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ /**
+ * @return Returns the startTag.
+ */
+ public final XMLBodyElement getStartTag()
+ {
+ return startTag;
+ }
+
+ public boolean removeLineWhenOtherwiseEmpty()
+ {
+ return startTag.removeLineWhenOtherwiseEmpty();
+ }
+
+ /**
+ * @param startTag The startTag to set.
+ */
+ public final void setStartTag(XMLBodyElement startTag)
+ {
+ this.startTag = startTag;
+ }
+
+ public JET2ASTElement getPrevElement()
+ {
+ final List bodyElements = startTag.getBodyElements();
+ if(bodyElements.size() > 0)
+ {
+ return (JET2ASTElement)bodyElements.get(bodyElements.size() - 1);
+ }
+ else
+ {
+ return startTag;
+ }
+ }
+
+ public String toString()
+ {
+ return "Line " + getLine() + ": </" + getStartTag().getName() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLElement.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLElement.java
index 6d8bea5..67c8a16 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLElement.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLElement.java
@@ -106,4 +106,8 @@ public abstract class XMLElement extends JET2ASTElement
return tagDefinition;
}
+ public final boolean removeLineWhenOtherwiseEmpty()
+ {
+ return tagDefinition.removeWhenContainingLineIsEmpty();
+ }
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLEmptyElement.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLEmptyElement.java
index 101c919..b240a1c 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLEmptyElement.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/XMLEmptyElement.java
@@ -54,4 +54,9 @@ public final class XMLEmptyElement extends XMLElement
visitor.visit(this);
}
+ public String toString()
+ {
+ return "Line " + getLine() + ": <" + getName() + "/>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/parser/LineInfo.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/parser/LineInfo.java
index 43286b7..f0f8dd9 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/parser/LineInfo.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/parser/LineInfo.java
@@ -140,6 +140,11 @@ public final class LineInfo {
}});
return (index >= 0 ? index : -index - 1) + 1;
}
+
+ public boolean hasDelimiter()
+ {
+ return getDelimiter().length() > 0;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/TagDefinitionImpl.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/TagDefinitionImpl.java
index 2624de6..6617834 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/TagDefinitionImpl.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/TagDefinitionImpl.java
@@ -58,12 +58,16 @@ final class TagDefinitionImpl implements TagDefinition
private static final String CONTENT_PROCESSING__VALUE__CUSTOM = "custom"; //$NON-NLS-1$
- private static final String CONTENT_PROCESSING__ATTR = "contentProcessing"; //$NON-NLS-1$
+ private static final String CONTENT_PROCESSING__ATTR = "processContents"; //$NON-NLS-1$
private static final String DEPRECATED__ATTR = "deprecated"; //$NON-NLS-1$
private static final String TYPE__ATTR = "type"; //$NON-NLS-1$
-
+
+ private static final String WHEN_CONTAINING_LINE_IS_EMPTY__ATTR = "whenContainingLineIsEmpty"; //$NON-NLS-1$
+
+ private static final String REMOVE = "remove"; //$NON-NLS-1$
+
private final String name;
private final CustomTagKind kind;
@@ -82,6 +86,8 @@ final class TagDefinitionImpl implements TagDefinition
private final String description;
+ private final boolean removeWhenContainingLineIsEmpty;
+
/**
*
* @param tagName the name of the tag
@@ -101,6 +107,17 @@ final class TagDefinitionImpl implements TagDefinition
customContentProcessing = CONTENT_PROCESSING__VALUE__CUSTOM.equals(configElement.getAttribute(CONTENT_PROCESSING__ATTR));
allowAsEmpty = Boolean.valueOf(configElement.getAttribute(ALLOW_AS_EMPTY__ATTR)).booleanValue();
+ String removeWhenEmpty = configElement.getAttribute(WHEN_CONTAINING_LINE_IS_EMPTY__ATTR);
+ if(removeWhenEmpty == null)
+ {
+ removeWhenContainingLineIsEmpty =
+ kind == CustomTagKind.EMPTY || kind == CustomTagKind.FUNCTION ? false : true;
+ }
+ else
+ {
+ removeWhenContainingLineIsEmpty = REMOVE.equals(removeWhenEmpty);
+ }
+
description = TagLibraryImpl.getDescription(configElement);
IConfigurationElement[] children = configElement.getChildren(ATTRIBUTE__ELEMENT);
@@ -223,5 +240,9 @@ final class TagDefinitionImpl implements TagDefinition
{
return description;
}
-
+
+ public boolean removeWhenContainingLineIsEmpty()
+ {
+ return removeWhenContainingLineIsEmpty;
+ }
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/AbstractCustomTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/AbstractCustomTag.java
index 2421c75..7aeb53e 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/AbstractCustomTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/AbstractCustomTag.java
@@ -94,7 +94,7 @@ public abstract class AbstractCustomTag implements CustomTag
String raw = getRawAttribute(name);
if (raw != null)
{
- XPathContextExtender xpathExtender = new XPathContextExtender(context);
+ XPathContextExtender xpathExtender = XPathContextExtender.getInstance(context);
return xpathExtender.resolveDynamic(raw);
}
return null;
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/TagDefinition.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/TagDefinition.java
index 8c8165e..e9e0480 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/TagDefinition.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/TagDefinition.java
@@ -120,4 +120,11 @@ public interface TagDefinition
* @return a TagLibrary instance.
*/
public abstract TagLibrary getTagLibrary();
+
+ /**
+ * Indicate whether the compiler should remove whitespace including the trailing
+ * new line from tags that occur on an otherwise empty line.
+ * @return <code>true</code> if such whitespace should be removed.
+ */
+ public abstract boolean removeWhenContainingLineIsEmpty();
}