|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.web.core.syntax; import java.util.*; import javax.swing.text.*; import org.netbeans.editor.ext.*; /** * * @author Petr Jiricka, Petr Nejedly * @version */ public abstract class SyntaxElement extends Object { private JspSyntaxSupport support; private SyntaxElement previous; private SyntaxElement next; int offset; int length; /** Creates new SyntaxElement */ public SyntaxElement( JspSyntaxSupport support, int from, int to ) { this.support = support; this.offset = from; this.length = to-from; } public abstract int getCompletionContext(); public int getElementOffset() { return offset; } public int getElementLength() { return length; } public SyntaxElement getPrevious() throws BadLocationException { if( previous == null ) { previous = support.getPreviousElement( offset ); if( previous != null ) previous.next = this; } return previous; } public String getImage() throws BadLocationException { return support.getDocument().getText(offset, length); } /* public SyntaxElement getPrevious() throws BadLocationException { if( previous == null ) { previous = support.getPreviousElement( offset ); if ( previous != null ) previous.next = this; } return previous; } public SyntaxElement getNext() throws BadLocationException { if ( next == null ) { next = support.getNextElement( offset+length ); if ( next != null ) next.previous = this; } return next; }*/ public String toString() { return "Element [" + offset + "," + (offset+length-1) + "]"; // NOI18N } public static class Comment extends SyntaxElement { public Comment( JspSyntaxSupport support, int from, int to ) { super( support, from, to ); } public int getCompletionContext() { return JspSyntaxSupport.COMMENT_COMPLETION_CONTEXT; } public String toString() { return "JSP Comment " + super.toString(); // NOI18N } } public static class Text extends SyntaxElement { public Text( JspSyntaxSupport support, int from, int to ) { super( support, from, to ); } public int getCompletionContext() { return JspSyntaxSupport.TEXT_COMPLETION_CONTEXT; } public String toString() { return "JSP Text " + super.toString(); // NOI18N } } public static class ContentL extends SyntaxElement { public ContentL( JspSyntaxSupport support, int from, int to ) { super( support, from, to ); } public int getCompletionContext() { return JspSyntaxSupport.CONTENTL_COMPLETION_CONTEXT; } public String toString() { return "JSP Content Language " + super.toString(); // NOI18N } } public static class ScriptingL extends SyntaxElement { public ScriptingL( JspSyntaxSupport support, int from, int to ) { super( support, from, to ); } public int getCompletionContext() { return JspSyntaxSupport.SCRIPTINGL_COMPLETION_CONTEXT; } public String toString() { return "JSP Scripting Language " + super.toString(); // NOI18N } } public static class Error extends SyntaxElement { public Error( JspSyntaxSupport support, int from, int to ) { super( support, from, to ); } public int getCompletionContext() { return JspSyntaxSupport.ERROR_COMPLETION_CONTEXT; } public String toString() { return "JSP Error " + super.toString(); // NOI18N } } public static abstract class TagLikeElement extends SyntaxElement { String name; public TagLikeElement(JspSyntaxSupport support, int from, int to, String name) { super( support, from,to ); this.name = name; } public String getName() { return name; } public String toString() { return super.toString() + " - '" + name + "'"; // NOI18N } } public static class EndTag extends TagLikeElement { public EndTag(JspSyntaxSupport support, int from, int to, String name) { super(support, from, to, name); } public int getCompletionContext() { return JspSyntaxSupport.ENDTAG_COMPLETION_CONTEXT; } public String toString() { return "JSP EndTag " + super.toString(); // NOI18N } } public static abstract class TagDirective extends TagLikeElement { Map attribs; public TagDirective( JspSyntaxSupport support, int from, int to, String name, Map attribs ) { super(support, from, to, name); this.attribs = attribs; } public Map getAttributes() { return attribs; } public String toString() { StringBuffer ret = new StringBuffer(super.toString() + " - {" ); // NOI18N for( Iterator i = attribs.keySet().iterator(); i.hasNext(); ) { Object next = i.next(); ret.append( next ). append( "='" ). // NOI18N append( attribs.get(next) ). append( "', " ); // NOI18N } ret.append( "}" ); // NOI18N return ret.toString(); } } public static class Tag extends TagDirective { /** is tag closed immediately (it has not a body and closing tag) */ private boolean isClosed; public Tag( JspSyntaxSupport support, int from, int to, String name, Map attribs, boolean isClosed) { super(support, from, to, name, attribs); this.isClosed = isClosed; } public Tag( JspSyntaxSupport support, int from, int to, String name, Map attribs ) { this(support, from, to, name, attribs, false); } public int getCompletionContext() { return JspSyntaxSupport.TAG_COMPLETION_CONTEXT; } public boolean isClosed () { return isClosed; } public String toString() { return "JSP Tag " + super.toString(); // NOI18N } } public static class Directive extends TagDirective { public Directive( JspSyntaxSupport support, int from, int to, String name, Map attribs ) { super(support, from, to, name, attribs); } public int getCompletionContext() { return JspSyntaxSupport.DIRECTIVE_COMPLETION_CONTEXT; } public String toString() { return "JSP Directive " + super.toString(); // NOI18N } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.