DFreds / code-peek-atom

Atom package to peek functions in different files
MIT License
22 stars 10 forks source link

support Typescript class #27

Closed jonyeezs closed 7 years ago

jonyeezs commented 7 years ago

TS uses classes as JS uses function as constructor.

Here is the propose regex: class\s+REPLACE(\s+extends\s+[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*|)\s+{

This should cater for scenarios:

  1. class Replace {}
  2. class Replace extends Base {
  3. export class Replace {}
  4. export class Replace extends Base {}
DFreds commented 7 years ago

Haven't had a chance to test this out yet, but thanks for this! I'll try it out soon.

ghost commented 7 years ago

Tips: (and working with TypeScriptReact :D ) functions: (private|protected|public)? (static)? \s+ REPLACE \s ( interfaces: interface\s+REPLACE\s{

jonyeezs commented 7 years ago

@avernus88 is that specific to TypeScriptReact?

ghost commented 7 years ago

It works with both: 'TypeScript': regExp: ///

class

    class\s+REPLACE(\s+extends\s+[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*|)\s+{
      # or
      |
    # matches 'function REPLACE('
    function \s+ REPLACE \s* \(
      # or
      |
    # matches 'REPLACE = function (' or 'REPLACE: function ('
    REPLACE \s* (=|:) \s* function \s* \(
     |
    # function:
    (private|protected|public)? (static)? \s+ REPLACE \s* \(
    # interface:
     |
    interface\s+REPLACE\s*{
  ///
  isTabBased: false

'TypeScriptReact':
  regExp: ///
    # class
    class\s+REPLACE(\s+extends\s+[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*|)\s+{
      # or
      |
    # matches 'function REPLACE('
    function \s+ REPLACE \s* \(
      # or
      |
    # matches 'REPLACE = function (' or 'REPLACE: function ('
    REPLACE \s* (=|:) \s* function \s* \(
     |
    # function:
    (private|protected|public)? (static)? \s+ REPLACE \s* \(
    # interface:
     |
    interface\s+REPLACE\s*{
  ///
  isTabBased: false
DFreds commented 7 years ago

This is amazing guys. Works flawlessly. Thanks so much. Going to release it shortly.