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-2007 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.lib.lexer;
043:
044: import java.util.Collection;
045: import java.util.Map;
046: import org.netbeans.api.lexer.LanguagePath;
047: import org.netbeans.api.lexer.InputAttributes;
048: import org.netbeans.api.lexer.Language;
049: import org.netbeans.api.lexer.Token;
050: import org.netbeans.api.lexer.TokenId;
051: import org.netbeans.spi.lexer.EmbeddingPresence;
052: import org.netbeans.spi.lexer.LanguageEmbedding;
053: import org.netbeans.spi.lexer.LanguageHierarchy;
054: import org.netbeans.spi.lexer.Lexer;
055: import org.netbeans.spi.lexer.LexerInput;
056: import org.netbeans.spi.lexer.LexerRestartInfo;
057: import org.netbeans.spi.lexer.MutableTextInput;
058: import org.netbeans.spi.lexer.TokenFactory;
059: import org.netbeans.spi.lexer.TokenValidator;
060:
061: /**
062: * Accessor for the package-private functionality in org.netbeans.api.editor.fold.
063: *
064: * @author Miloslav Metelka
065: * @version 1.00
066: */
067:
068: public abstract class LexerSpiPackageAccessor {
069:
070: private static LexerSpiPackageAccessor INSTANCE;
071:
072: public static LexerSpiPackageAccessor get() {
073: if (INSTANCE == null) {
074: // Cause spi accessor impl to get initialized
075: try {
076: Class.forName(LanguageHierarchy.class.getName(), true,
077: LexerSpiPackageAccessor.class.getClassLoader());
078: } catch (ClassNotFoundException e) {
079: // Should never happen
080: }
081: }
082: return INSTANCE;
083: }
084:
085: public static void register(LexerSpiPackageAccessor accessor) {
086: INSTANCE = accessor;
087: }
088:
089: public abstract <T extends TokenId> Collection<T> createTokenIds(
090: LanguageHierarchy<T> languageHierarchy);
091:
092: public abstract <T extends TokenId> Map<String, Collection<T>> createTokenCategories(
093: LanguageHierarchy<T> languageHierarchy);
094:
095: public abstract <T extends TokenId> Lexer<T> createLexer(
096: LanguageHierarchy<T> languageHierarchy,
097: LexerRestartInfo<T> info);
098:
099: public abstract <T extends TokenId> LexerRestartInfo<T> createLexerRestartInfo(
100: LexerInput input, TokenFactory<T> tokenFactory,
101: Object state, LanguagePath languagePath,
102: InputAttributes inputAttributes);
103:
104: public abstract String mimeType(
105: LanguageHierarchy<?> languageHierarchy);
106:
107: public abstract <T extends TokenId> LanguageEmbedding<?> embedding(
108: LanguageHierarchy<T> languageHierarchy, Token<T> token,
109: LanguagePath languagePath, InputAttributes inputAttributes);
110:
111: public abstract <T extends TokenId> EmbeddingPresence embeddingPresence(
112: LanguageHierarchy<T> languageHierarchy, T id);
113:
114: public abstract <T extends TokenId> TokenValidator<T> createTokenValidator(
115: LanguageHierarchy<T> languageHierarchy, T id);
116:
117: public abstract <T extends TokenId> boolean isRetainTokenText(
118: LanguageHierarchy<T> languageHierarchy, T id);
119:
120: public abstract LexerInput createLexerInput(
121: CharProvider charProvider);
122:
123: public abstract Language<?> language(MutableTextInput<?> mti);
124:
125: public abstract <T extends TokenId> LanguageEmbedding<T> createLanguageEmbedding(
126: Language<T> language, int startSkipLength,
127: int endSkipLength, boolean joinSections);
128:
129: public abstract CharSequence text(MutableTextInput<?> mti);
130:
131: public abstract InputAttributes inputAttributes(
132: MutableTextInput<?> mti);
133:
134: public abstract <I> I inputSource(MutableTextInput<I> mti);
135:
136: public abstract boolean isReadLocked(MutableTextInput<?> mti);
137:
138: public abstract boolean isWriteLocked(MutableTextInput<?> mti);
139:
140: public abstract <T extends TokenId> TokenFactory<T> createTokenFactory(
141: LexerInputOperation<T> lexerInputOperation);
142:
143: }
|