001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.web.core.syntax.deprecated;
043:
044: import org.netbeans.modules.web.core.syntax.deprecated.JspMultiSyntax;
045: import org.netbeans.modules.web.core.syntax.*;
046: import org.netbeans.editor.Syntax;
047: import org.netbeans.modules.web.core.syntax.spi.JSPColoringData;
048:
049: /** Handles syntax coloring for JSP 1.1. This involves handling custom tags.
050: * This class relies on an external source of data, which provides information
051: * about tag libraries. The information necessary is:
052: * <ul>
053: * <li>Prefixes of tag libraries imported by the page (and its included pages !)</li>
054: * <li>For individual tags inside the tag libraries, it's <code>bodyContent</code> property</li>
055: * </ul>
056: * This class is able to deal with cases when this information is incomplete,
057: * i.e. if the information for individual tags is missing (for example in the case when the
058: * .tld descriptor of the library was not found). In such a case the tags for which the information
059: * is missing are treated as if they had bodycontent set to JSP.
060: *
061: * // PENDING - handle TAG_DEPENDENT tags correctly, change JspMultiSyntax and JspTagSyntax accordingly
062: *
063: * @author petr.jiricka@netbeans.com
064: * @deprecated Use {@link JspLexer} instead.
065: *
066: */
067: public class Jsp11Syntax extends JspMultiSyntax {
068:
069: /** Creates new Jsp11Syntax */
070: public Jsp11Syntax() {
071: super ();
072: }
073:
074: public Jsp11Syntax(Syntax contentSyntax, Syntax scriptingSyntax) {
075: super (contentSyntax, scriptingSyntax);
076: }
077:
078: /** Only keep reference to listener which listens on the JSP DataObject so
079: * it's not garbage collected. */
080: public Object listenerReference;
081:
082: /** Data providing the information about tag libraries. */
083: public JSPColoringData data;
084:
085: protected boolean isJspTag(String tagName) {
086: // not calling super() for performance reasons
087: if (tagName.startsWith("jsp:")) { // NOI18N
088: // standard JSP tag
089: return true;
090: }
091: if (data == null)
092: return false;
093:
094: int colonIndex = tagName.indexOf(':');
095: if (colonIndex == -1) {
096: // not a JSP tag
097: return false;
098: }
099:
100: // return true if there is information for a library with our prefix
101: return data
102: .isTagLibRegistered(tagName.substring(0, colonIndex));
103: }
104:
105: /** Determines whether any EL expressions should be colored as expressions,
106: * or ignored. Returna the correct value per section JSP.3.3.2
107: * of the specification.
108: * @param whether this expression is inside the JSP tag value, or just in template text
109: * @return true if the expression should be ignored, false if it should be treated as an expression
110: */
111: protected boolean isELIgnored(boolean inJspTag) {
112: if (data == null) {
113: return false;
114: }
115: // PENDING: what we could do is the following:
116: // for a 2.3 application, see if the page uses a tag library that hacks
117: // EL support (JSTL or JSF) and if it does, enable EL expressions inside
118: // JSP tag attribute values for this page.
119: if (inJspTag) {
120: return false;
121: }
122: return data.isELIgnored();
123: }
124:
125: protected boolean isXMLSyntax() {
126: if (data == null) {
127: return false;
128: }
129: return data.isXMLSyntax();
130: }
131: }
|