Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebased and merge of use of Java's ServiceLoader. #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,75 @@
*/
package org.fife.ui.rsyntaxtextarea;

import java.util.ServiceLoader;

/**
* The default implementation of <code>TokenMakerFactory</code>. This factory
* The default implementation of <code>TokenMakerFactory</code>. This factory
* can create {@link TokenMaker}s for all languages known to
* {@link RSyntaxTextArea}.
*
* @author Robert Futrell
* @version 1.0
*/
class DefaultTokenMakerFactory extends AbstractTokenMakerFactory
implements SyntaxConstants {
implements SyntaxConstants {


/**
* {@inheritDoc}
*/
@Override
protected void initTokenMakerMap() {
ServiceLoader<TokenMakerRegistration> s = ServiceLoader.load(TokenMakerRegistration.class);
for (TokenMakerRegistration l : s) {
putMapping(l.getLanguage(), l.getTokenMaker());
}
// String pkg = "org.fife.ui.rsyntaxtextarea.modes.";
//
// putMapping(SYNTAX_STYLE_NONE, pkg + "PlainTextTokenMaker");
// putMapping(SYNTAX_STYLE_ACTIONSCRIPT, pkg + "ActionScriptTokenMaker");
// putMapping(SYNTAX_STYLE_ASSEMBLER_X86, pkg + "AssemblerX86TokenMaker");
// putMapping(SYNTAX_STYLE_BBCODE, pkg + "BBCodeTokenMaker");
// putMapping(SYNTAX_STYLE_C, pkg + "CTokenMaker");
// putMapping(SYNTAX_STYLE_CLOJURE, pkg + "ClojureTokenMaker");
// putMapping(SYNTAX_STYLE_CPLUSPLUS, pkg + "CPlusPlusTokenMaker");
// putMapping(SYNTAX_STYLE_CSHARP, pkg + "CSharpTokenMaker");
// putMapping(SYNTAX_STYLE_CSS, pkg + "CSSTokenMaker");
// putMapping(SYNTAX_STYLE_D, pkg + "DTokenMaker");
// putMapping(SYNTAX_STYLE_DART, pkg + "DartTokenMaker");
// putMapping(SYNTAX_STYLE_DELPHI, pkg + "DelphiTokenMaker");
// putMapping(SYNTAX_STYLE_DTD, pkg + "DtdTokenMaker");
// putMapping(SYNTAX_STYLE_FORTRAN, pkg + "FortranTokenMaker");
// putMapping(SYNTAX_STYLE_GROOVY, pkg + "GroovyTokenMaker");
// putMapping(SYNTAX_STYLE_HTACCESS, pkg + "HtaccessTokenMaker");
// putMapping(SYNTAX_STYLE_HTML, pkg + "HTMLTokenMaker");
// putMapping(SYNTAX_STYLE_JAVA, pkg + "JavaTokenMaker");
// putMapping(SYNTAX_STYLE_BSH, pkg + "JavaTokenMaker");
// putMapping(SYNTAX_STYLE_JAVASCRIPT, pkg + "JavaScriptTokenMaker");
// putMapping(SYNTAX_STYLE_JSHINTRC, pkg + "JshintrcTokenMaker");
// putMapping(SYNTAX_STYLE_JSON, pkg + "JsonTokenMaker");
// putMapping(SYNTAX_STYLE_JSP, pkg + "JSPTokenMaker");
// putMapping(SYNTAX_STYLE_LATEX, pkg + "LatexTokenMaker");
// putMapping(SYNTAX_STYLE_LESS, pkg + "LessTokenMaker");
// putMapping(SYNTAX_STYLE_LISP, pkg + "LispTokenMaker");
// putMapping(SYNTAX_STYLE_LUA, pkg + "LuaTokenMaker");
// putMapping(SYNTAX_STYLE_MAKEFILE, pkg + "MakefileTokenMaker");
// putMapping(SYNTAX_STYLE_MXML, pkg + "MxmlTokenMaker");
// putMapping(SYNTAX_STYLE_NSIS, pkg + "NSISTokenMaker");
// putMapping(SYNTAX_STYLE_PERL, pkg + "PerlTokenMaker");
// putMapping(SYNTAX_STYLE_PHP, pkg + "PHPTokenMaker");
// putMapping(SYNTAX_STYLE_PROPERTIES_FILE,pkg + "PropertiesFileTokenMaker");
// putMapping(SYNTAX_STYLE_PYTHON, pkg + "PythonTokenMaker");
// putMapping(SYNTAX_STYLE_RUBY, pkg + "RubyTokenMaker");
// putMapping(SYNTAX_STYLE_SAS, pkg + "SASTokenMaker");
// putMapping(SYNTAX_STYLE_SCALA, pkg + "ScalaTokenMaker");
// putMapping(SYNTAX_STYLE_SQL, pkg + "SQLTokenMaker");
// putMapping(SYNTAX_STYLE_TCL, pkg + "TclTokenMaker");
// putMapping(SYNTAX_STYLE_UNIX_SHELL, pkg + "UnixShellTokenMaker");
// putMapping(SYNTAX_STYLE_VISUAL_BASIC, pkg + "VisualBasicTokenMaker");
// putMapping(SYNTAX_STYLE_WINDOWS_BATCH, pkg + "WindowsBatchTokenMaker");
// putMapping(SYNTAX_STYLE_XML, pkg + "XMLTokenMaker");

/**
* {@inheritDoc}
*/
@Override
protected void initTokenMakerMap() {
}

String pkg = "org.fife.ui.rsyntaxtextarea.modes.";

putMapping(SYNTAX_STYLE_NONE, pkg + "PlainTextTokenMaker");
putMapping(SYNTAX_STYLE_ACTIONSCRIPT, pkg + "ActionScriptTokenMaker");
putMapping(SYNTAX_STYLE_ASSEMBLER_X86, pkg + "AssemblerX86TokenMaker");
putMapping(SYNTAX_STYLE_BBCODE, pkg + "BBCodeTokenMaker");
putMapping(SYNTAX_STYLE_C, pkg + "CTokenMaker");
putMapping(SYNTAX_STYLE_CLOJURE, pkg + "ClojureTokenMaker");
putMapping(SYNTAX_STYLE_CPLUSPLUS, pkg + "CPlusPlusTokenMaker");
putMapping(SYNTAX_STYLE_CSHARP, pkg + "CSharpTokenMaker");
putMapping(SYNTAX_STYLE_CSS, pkg + "CSSTokenMaker");
putMapping(SYNTAX_STYLE_D, pkg + "DTokenMaker");
putMapping(SYNTAX_STYLE_DART, pkg + "DartTokenMaker");
putMapping(SYNTAX_STYLE_DELPHI, pkg + "DelphiTokenMaker");
putMapping(SYNTAX_STYLE_DOCKERFILE, pkg + "DockerTokenMaker");
putMapping(SYNTAX_STYLE_DTD, pkg + "DtdTokenMaker");
putMapping(SYNTAX_STYLE_FORTRAN, pkg + "FortranTokenMaker");
putMapping(SYNTAX_STYLE_GROOVY, pkg + "GroovyTokenMaker");
putMapping(SYNTAX_STYLE_HOSTS, pkg + "HostsTokenMaker");
putMapping(SYNTAX_STYLE_HTACCESS, pkg + "HtaccessTokenMaker");
putMapping(SYNTAX_STYLE_HTML, pkg + "HTMLTokenMaker");
putMapping(SYNTAX_STYLE_INI, pkg + "IniTokenMaker");
putMapping(SYNTAX_STYLE_JAVA, pkg + "JavaTokenMaker");
putMapping(SYNTAX_STYLE_JAVASCRIPT, pkg + "JavaScriptTokenMaker");
putMapping(SYNTAX_STYLE_JSON_WITH_COMMENTS, pkg + "JshintrcTokenMaker");
putMapping(SYNTAX_STYLE_JSON, pkg + "JsonTokenMaker");
putMapping(SYNTAX_STYLE_JSP, pkg + "JSPTokenMaker");
putMapping(SYNTAX_STYLE_LATEX, pkg + "LatexTokenMaker");
putMapping(SYNTAX_STYLE_LESS, pkg + "LessTokenMaker");
putMapping(SYNTAX_STYLE_LISP, pkg + "LispTokenMaker");
putMapping(SYNTAX_STYLE_LUA, pkg + "LuaTokenMaker");
putMapping(SYNTAX_STYLE_MAKEFILE, pkg + "MakefileTokenMaker");
putMapping(SYNTAX_STYLE_MXML, pkg + "MxmlTokenMaker");
putMapping(SYNTAX_STYLE_NSIS, pkg + "NSISTokenMaker");
putMapping(SYNTAX_STYLE_PERL, pkg + "PerlTokenMaker");
putMapping(SYNTAX_STYLE_PHP, pkg + "PHPTokenMaker");
putMapping(SYNTAX_STYLE_PROPERTIES_FILE,pkg + "PropertiesFileTokenMaker");
putMapping(SYNTAX_STYLE_PYTHON, pkg + "PythonTokenMaker");
putMapping(SYNTAX_STYLE_RUBY, pkg + "RubyTokenMaker");
putMapping(SYNTAX_STYLE_SAS, pkg + "SASTokenMaker");
putMapping(SYNTAX_STYLE_SCALA, pkg + "ScalaTokenMaker");
putMapping(SYNTAX_STYLE_SQL, pkg + "SQLTokenMaker");
putMapping(SYNTAX_STYLE_TCL, pkg + "TclTokenMaker");
putMapping(SYNTAX_STYLE_TYPESCRIPT, pkg + "TypeScriptTokenMaker");
putMapping(SYNTAX_STYLE_UNIX_SHELL, pkg + "UnixShellTokenMaker");
putMapping(SYNTAX_STYLE_VISUAL_BASIC, pkg + "VisualBasicTokenMaker");
putMapping(SYNTAX_STYLE_WINDOWS_BATCH, pkg + "WindowsBatchTokenMaker");
putMapping(SYNTAX_STYLE_XML, pkg + "XMLTokenMaker");
putMapping(SYNTAX_STYLE_YAML, pkg + "YamlTokenMaker");

}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.fife.ui.rsyntaxtextarea.folding.DefaultFoldManager;
import org.fife.ui.rsyntaxtextarea.folding.Fold;
import org.fife.ui.rsyntaxtextarea.folding.FoldManager;
import org.fife.ui.rsyntaxtextarea.modes.PlainTextTokenRegistration;
import org.fife.ui.rsyntaxtextarea.parser.Parser;
import org.fife.ui.rsyntaxtextarea.parser.ParserNotice;
import org.fife.ui.rsyntaxtextarea.parser.ToolTipInfo;
Expand Down Expand Up @@ -694,7 +695,7 @@ public void copyAsRtf() {
*/
@Override
protected Document createDefaultModel() {
return new RSyntaxDocument(SYNTAX_STYLE_NONE);
return new RSyntaxDocument(PlainTextTokenRegistration.SYNTAX_STYLE);
}


Expand Down Expand Up @@ -1928,7 +1929,7 @@ protected void init() {
}

// Set some RSyntaxTextArea default values.
syntaxStyleKey = SYNTAX_STYLE_NONE;
syntaxStyleKey = PlainTextTokenRegistration.SYNTAX_STYLE;
setMatchedBracketBGColor(getDefaultBracketMatchBGColor());
setMatchedBracketBorderColor(getDefaultBracketMatchBorderColor());
setBracketMatchingEnabled(true);
Expand Down Expand Up @@ -2901,7 +2902,7 @@ public void setShowMatchedBracketPopup(boolean show) {
*/
public void setSyntaxEditingStyle(String styleKey) {
if (styleKey==null) {
styleKey = SYNTAX_STYLE_NONE;
styleKey = PlainTextTokenRegistration.SYNTAX_STYLE;
}
if (!styleKey.equals(syntaxStyleKey)) {
String oldStyle = syntaxStyleKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.fife.ui.rsyntaxtextarea.folding.Fold;
import org.fife.ui.rsyntaxtextarea.folding.FoldCollapser;
import org.fife.ui.rsyntaxtextarea.folding.FoldManager;
import org.fife.ui.rsyntaxtextarea.modes.PlainTextTokenRegistration;
import org.fife.ui.rsyntaxtextarea.templates.CodeTemplate;
import org.fife.ui.rtextarea.IconRowHeader;
import org.fife.ui.rtextarea.RTextArea;
Expand Down Expand Up @@ -139,7 +140,7 @@ public RSyntaxTextAreaEditorKit() {
*/
@Override
public Document createDefaultDocument() {
return new RSyntaxDocument(SyntaxConstants.SYNTAX_STYLE_NONE);
return new RSyntaxDocument(PlainTextTokenRegistration.SYNTAX_STYLE);
}


Expand Down
Loading