Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Efxclipse/SmartCode"

(Basics)
Line 16: Line 16:
  
 
js {
 
js {
partitioning {
+
  partitioning {
partition __dftl_partition_content_type
+
    partition __dftl_partition_content_type
partition __js_single_line_comment
+
    partition __js_single_line_comment
partition __js_multi_line_comment
+
    partition __js_multi_line_comment
partition __js_string
+
    partition __js_string
partition __js_regex
+
    partition __js_regex
rule {
+
    rule {
single_line __js_single_line_comment "//" => ''
+
      single_line __js_single_line_comment "//" => ''
multi_line __js_multi_line_comment "/*" => "*/"
+
      multi_line __js_multi_line_comment   "/*" => "*/"
single_line __js_string "'" => "'" escaped by "\\"
+
      single_line __js_string               "'"   => "'" escaped by "\\"
single_line __js_string '"' => '"' escaped by "\\"
+
      single_line __js_string               '"'   => '"' escaped by "\\"
single_line __js_regex '/' => '/' escaped by "\\"
+
      single_line __js_regex               '/'   => '/' escaped by "\\"
}
+
    }
}
+
  }
lexical_highlighting {
+
  lexical_highlighting {
rule __dftl_partition_content_type whitespace javawhitespace {
+
    rule __dftl_partition_content_type whitespace javawhitespace {
default js_default
+
      default js_default
js_operator {
+
      js_operator {
character [ ';', '.', '=', '/', '\\', '+', '-', '*', '<', '>', ':', '?', '!', ',', '|', '&', '^', '%', '~' ]
+
        character [  
}
+
          ';', '.', '=', '/', '\\', '+', '-', '*',  
js_bracket {
+
          '<', '>', ':', '?', '!', ',', '|', '&', '^', '%', '~'  
character [ '(', ')', '{', '}', '[', ']' ]
+
        ]
}
+
      }
js_keyword {
+
      js_bracket {
keywords [ "break", "case", "catch", "continue",
+
        character [ '(', ')', '{', '}', '[', ']' ]
    "debugger", "default", "delete", "do",
+
      }
    "else", "finally", "for", "function",
+
      js_keyword {
    "if", "in", "instanceof", "new",
+
        keywords [
    "return", "switch", "this", "throw",
+
          "break", "case", "catch", "continue",
    "try", "typeof", "var", "void",
+
          "debugger","default", "delete", "do",
    "while", "with" ]
+
          "else", "finally", "for", "function",
}
+
          "if", "in", "instanceof", "new",
js_constant {
+
          "return", "switch", "this", "throw",
keywords [ "true", "false", "undefined" ]
+
          "try", "typeof", "var", "void",
}
+
          "while", "with"  
js_number {
+
        ]
pattern "\\d" containing "[\\d|\\.]"
+
      }
}
+
      js_constant {
}
+
        keywords [ "true", "false", "undefined" ]
rule __js_single_line_comment {
+
      }
default js_doc_default
+
      js_number {
}
+
        pattern "\\d" containing "[\\d|\\.]"
rule __js_multi_line_comment {
+
      }
default js_doc_default
+
    }
}
+
    rule __js_single_line_comment {
rule __js_string {
+
      default js_doc_default
default js_string
+
    }
}
+
    rule __js_multi_line_comment {
rule __js_regex {
+
      default js_doc_default
default js_string
+
    }
}
+
    rule __js_string {
token_def {
+
      default js_string
js_default "-source-editor-code";
+
    }
js_operator "-source-editor-operator";
+
    rule __js_regex {
js_bracket "-source-editor-bracket";
+
      default js_string
js_keyword "-source-editor-keyword" bold;
+
    }
js_doc_default "-source-editor-doc";
+
    token_def {
js_string "-source-editor-string";
+
      js_default "-source-editor-code";
js_constant "-source-editor-keyword" bold;
+
      js_operator "-source-editor-operator";
js_number "-source-editor-number";
+
      js_bracket "-source-editor-bracket";
}
+
      js_keyword "-source-editor-keyword" bold;
}
+
      js_doc_default "-source-editor-doc";
 +
      js_string "-source-editor-string";
 +
      js_constant "-source-editor-keyword" bold;
 +
      js_number "-source-editor-number";
 +
    }
 +
  }
 
}
 
}
 
</source>
 
</source>

Revision as of 07:48, 26 February 2016


e(fx)clipse provides a SmartCode-Editing Framework who can be embedded in fairly any application (not only OSGi)

Integration into OSGi

Basic Control with Syntax Highlighting

Basics

To make it easier to define syntax highlighting for any language the smart-code framework uses unlike the Eclipse IDE a declarative language named ldef.

The first step when integrating a syntax highlighting editor into your application is to create a file ending with .ldef (eg java.ldef, ...).

package org.eclipse.fx.code.editor.ldef.langs
 
js {
  partitioning {
    partition __dftl_partition_content_type
    partition __js_single_line_comment
    partition __js_multi_line_comment
    partition __js_string
    partition __js_regex
    rule {
      single_line __js_single_line_comment  "//"  => ''
      multi_line __js_multi_line_comment    "/*"  => "*/"
      single_line __js_string               "'"   => "'" escaped by "\\"
      single_line __js_string               '"'   => '"' escaped by "\\"
      single_line __js_regex                '/'   => '/' escaped by "\\"
    }
  }
  lexical_highlighting {
    rule __dftl_partition_content_type whitespace javawhitespace {
      default js_default
      js_operator {
        character [ 
          ';', '.', '=', '/', '\\', '+', '-', '*', 
          '<', '>', ':', '?', '!', ',', '|', '&', '^', '%', '~' 
        ]
      }
      js_bracket {
        character [ '(', ')', '{', '}', '[', ']' ]
      }
      js_keyword {
        keywords [
          "break", "case", "catch", "continue",
          "debugger","default",	"delete", "do",
          "else", "finally", "for", "function",
          "if", "in", "instanceof", "new",
          "return", "switch", "this", "throw",
          "try", "typeof", "var", "void",
          "while", "with" 
        ]
      }
      js_constant {
        keywords [ "true", "false", "undefined" ]
      }
      js_number {
        pattern "\\d" containing "[\\d|\\.]"
      }
    }
    rule __js_single_line_comment {
      default js_doc_default
    }
    rule __js_multi_line_comment {
      default js_doc_default
    }
    rule __js_string {
      default js_string
    }
    rule __js_regex {
      default js_string
    }
    token_def {
      js_default "-source-editor-code";
      js_operator "-source-editor-operator";
      js_bracket "-source-editor-bracket";
      js_keyword "-source-editor-keyword" bold;
      js_doc_default "-source-editor-doc";
      js_string "-source-editor-string";
      js_constant "-source-editor-keyword" bold;
      js_number "-source-editor-number";
    }
  }
}

Dependencies

Adding support for Autocomplete Features

Adding support for Error-Markers

Copyright © Eclipse Foundation, Inc. All Rights Reserved.