File: ThemeImporterJavaScript.cpp

package info (click to toggle)
codelite 17.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 136,204 kB
  • sloc: cpp: 491,547; ansic: 280,393; php: 10,259; sh: 8,930; lisp: 7,664; vhdl: 6,518; python: 6,020; lex: 4,920; yacc: 3,123; perl: 2,385; javascript: 1,715; cs: 1,193; xml: 1,110; makefile: 804; cobol: 741; sql: 709; ruby: 620; f90: 566; ada: 534; asm: 464; fortran: 350; objc: 289; tcl: 258; java: 157; erlang: 61; pascal: 51; ml: 49; awk: 44; haskell: 36
file content (94 lines) | stat: -rw-r--r-- 5,010 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "ThemeImporterJavaScript.hpp"

#include "cl_standard_paths.h"
#include "fileutils.h"
#include "globals.h"
#include "wx/dir.h"
#include "xmlutils.h"

#include <wx/stc/stc.h>

ThemeImporterJavaScript::ThemeImporterJavaScript()
{
    // Primary keywords and identifiers
    SetKeywords0("abstract arguments boolean break byte "
                 "case catch char class const "
                 "continue debugger default delete do "
                 "double else enum eval export "
                 "extends false final finally float "
                 "for function goto if implements "
                 "import in instanceof int interface "
                 "let long native new null "
                 "package private protected public return "
                 "short static super switch synchronized "
                 "this throw throws transient true "
                 "try typeof var void volatile "
                 "while with yield prototype undefined StringtoString NaN ");

    // Secondary keywords and identifiers
    SetKeywords1(
        "activeElement addEventListener adoptNode anchors applets "
        "baseURI body close cookie createAttribute createComment createDocumentFragment createElement createTextNode "
        "doctype documentElement documentMode documentURI domain "
        "domConfig embeds forms getElementById getElementsByClassName getElementsByName getElementsByTagName hasFocus "
        "head images implementation importNode inputEncoding lastModified links normalize normalizeDocument open "
        "querySelector"
        "querySelectorAll readyState referrer removeEventListener renameNode scripts strictErrorChecking title URL "
        "write writeln NaN name NumberObject valueOf");

    // Documentation comment keywords
    SetKeywords2("a addindex addtogroup anchor arg attention author b brief bug c callgraph callergraph category class "
                 "code "
                 "cond copybrief copydetails copydoc 	date def defgroup deprecated details dir  dontinclude dot "
                 "dotfile e else elseif em endcode endcond enddot endhtmlonly endif endlatexonly endlink endmanonly "
                 "endmsc "
                 "endverbatim 	endxmlonly  enum example exception extends  file fn headerfile hideinitializer "
                 "htmlinclude htmlonly if ifnot image implements include includelineno ingroup internal invariant "
                 "	"
                 "interface  latexonly li line link mainpage manonly memberof msc n name namespace nosubgrouping note "
                 "overload p package page par paragraph param post pre private privatesection property 	protected  "
                 "protectedsection protocol public publicsection ref relates relatesalso remarks return retval sa "
                 "section "
                 "see showinitializer since skip skipline struct 	subpage  subsection subsubsection test throw "
                 "todo "
                 "tparam typedef union until var verbatim verbinclude version warning weakgroup xmlonly xrefitem");

    // Used for wxSTC_C_GLOBALCLASS ("classes")
    SetKeywords3("Math Array Date document window NumberObject URL");

    // used for functions
    SetFunctionsWordSetIndex(1);

    // Global classes and typedefs, it already contains values, so be careful here
    // so when used, append the values
    SetClassWordSetIndex(3);
    SetFileExtensions("*.js;*.javascript;*.qml;*.json;*.ts");
}

ThemeImporterJavaScript::~ThemeImporterJavaScript() {}

LexerConf::Ptr_t ThemeImporterJavaScript::Import(const wxFileName& theme_file)
{
    LexerConf::Ptr_t lexer = InitializeImport(theme_file, "javascript", wxSTC_LEX_CPP);
    CHECK_PTR_RET_NULL(lexer);

    // Covnert to codelite's XML properties
    AddProperty(lexer, wxSTC_C_DEFAULT, "Default", m_editor);
    AddProperty(lexer, wxSTC_C_COMMENT, "Block comment", m_multiLineComment);
    AddProperty(lexer, wxSTC_C_COMMENTLINE, "Single line comment", m_singleLineComment);
    AddProperty(lexer, wxSTC_C_COMMENTDOC, "Javadoc block comment", m_javadoc);
    AddProperty(lexer, wxSTC_C_NUMBER, "Number", m_number);
    AddProperty(lexer, wxSTC_C_WORD, "JavaScript keyword", m_keyword);
    AddProperty(lexer, wxSTC_C_STRING, "String", m_string);
    AddProperty(lexer, wxSTC_C_CHARACTER, "Character", m_string);
    AddProperty(lexer, wxSTC_C_OPERATOR, "Operator", m_oper);
    AddProperty(lexer, wxSTC_C_IDENTIFIER, "Identifier", m_editor);
    AddProperty(lexer, wxSTC_C_STRINGEOL, "Open String", m_string);
    AddProperty(lexer, wxSTC_C_COMMENTLINEDOC, "Javadoc single line comment", m_javadoc);
    AddProperty(lexer, wxSTC_C_WORD2, "JavaScript functions", m_function);
    AddProperty(lexer, wxSTC_C_GLOBALCLASS, "JavaScript global classes", m_klass);
    AddProperty(lexer, wxSTC_C_COMMENTDOCKEYWORD, "Javadoc keyword", m_javadocKeyword);
    AddProperty(lexer, wxSTC_C_COMMENTDOCKEYWORDERROR, "Javadoc keyword error", m_javadocKeyword);
    FinalizeImport(lexer);
    return lexer;
}