Edgewall Software

Ticket #2198: silvercity-java.patch

File silvercity-java.patch, 4.5 KB (added by dcreager@…, 6 years ago)

Patch for silvercity-0.9.5 to support lexing Java code

  • PySilverCity/SilverCity/Java.py

    diff -urN --exclude '*~' SilverCity-0.9.5/PySilverCity/SilverCity/Java.py SilverCity-0.9.5-java/PySilverCity/SilverCity/Java.py
    old new  
     1import HTMLGenerator 
     2import Keywords 
     3import Lexer 
     4from DispatchHandler import DispatchHandler 
     5from _SilverCity import find_lexer_module_by_id, PropertySet, WordList 
     6from ScintillaConstants import SCLEX_CPP 
     7import LanguageInfo 
     8 
     9class JavaLexer(Lexer.Lexer): 
     10    def __init__(self, properties = PropertySet()): 
     11        self._properties = properties 
     12        self._lexer = find_lexer_module_by_id(SCLEX_CPP) 
     13        self._keyword_lists = [ 
     14            WordList(Keywords.java_keywords), 
     15            WordList(), # User defined (important functions, constants, etc.) 
     16            WordList(Keywords.javadoc_keywords), 
     17            WordList(), # "Fold header keywords" - whatever that is 
     18            WordList(), # Global classes and typedefs 
     19                               ] 
     20             
     21class JavaHandler(DispatchHandler): 
     22    def __init__(self): 
     23        DispatchHandler.__init__(self, 'SCE_C') 
     24 
     25class JavaHTMLGenerator(HTMLGenerator.SimpleHTMLGenerator, JavaHandler): 
     26    name = 'java' 
     27    description = 'Java' 
     28 
     29    def __init__(self): 
     30        JavaHandler.__init__(self) 
     31        HTMLGenerator.SimpleHTMLGenerator.__init__(self, 'SCE_C') 
     32             
     33    def generate_html(self, file, buffer, lexer = JavaLexer()): 
     34        self._file = file 
     35         
     36        lexer.tokenize_by_style(buffer, self.event_handler) 
     37 
     38 
     39java_language_info = LanguageInfo.LanguageInfo( 
     40                'Java', 
     41                 ['java'], 
     42                 [], 
     43                 [JavaHTMLGenerator] 
     44            )  
     45 
     46LanguageInfo.register_language(java_language_info) 
  • PySilverCity/SilverCity/Keywords.py

    diff -urN --exclude '*~' SilverCity-0.9.5/PySilverCity/SilverCity/Keywords.py SilverCity-0.9.5-java/PySilverCity/SilverCity/Keywords.py
    old new  
    1818    "test throw todo typedef union until "\ 
    1919    "var verbatim verbinclude version warning weakgroup $ @ \ & < > # { }" 
    2020 
     21 
     22java_keywords = \ 
     23    "abstract assert boolean break byte case catch char class "\ 
     24    "const continue default do double else extends final finally float for future "\ 
     25    "generic goto if implements import inner instanceof int interface long "\ 
     26    "native new null outer package private protected public rest "\ 
     27    "return short static super switch synchronized this throw throws "\ 
     28    "transient try var void volatile while" 
     29 
     30javadoc_keywords = \ 
     31    "author code docRoot deprecated exception inheritDoc link linkplain "\ 
     32    "literal param return see serial serialData serialField since throws "\ 
     33    "value version" 
    2134 
    2235perl_keywords = \ 
    2336    "NULL __FILE__ __LINE__ __PACKAGE__ __DATA__ __END__ AUTOLOAD "\ 
     
    223236    "border-color border-style width height float clear " \ 
    224237    "display white-space list-style-type list-style-image list-style-position list-style" 
    225238 
    226 css_keywords_2 = "first-letter first-line active link visited" 
    227  No newline at end of file 
     239css_keywords_2 = "first-letter first-line active link visited" 
  • PySilverCity/SilverCity/LanguageInfo.py

    diff -urN --exclude '*~' SilverCity-0.9.5/PySilverCity/SilverCity/LanguageInfo.py SilverCity-0.9.5-java/PySilverCity/SilverCity/LanguageInfo.py
    old new  
    113113     
    114114def do_registration(): 
    115115    import CPP 
     116    import Java 
    116117    import CSS 
    117118    import HyperText 
    118119    import NULL 
  • SilverCity-0.9.

    Files SilverCity-0.9.5/scintilla/include/Face.pyc and SilverCity-0.9.5-java/scintilla/include/Face.pyc differ
    diff -urN --exclude '*~' SilverCity-0.9.5/setup.py SilverCity-0.9.5-java/setup.py
    old new  
    114114                     "SilverCity.Utils", 
    115115                     # Lexers 
    116116                     "SilverCity.CPP", 
     117                     "SilverCity.Java", 
    117118                     "SilverCity.CSS", 
    118119                     "SilverCity.HyperText", 
    119120                     "SilverCity.NULL",