Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Recognize function bodies #224

Closed
wants to merge 3 commits into from

Conversation

pchaigno
Copy link
Contributor

@pchaigno pchaigno commented Sep 9, 2015

With this pull request, function and method bodies will be recognized under the scopes meta.function.js and meta.method.js with the headers.
This is a necessary step to then recognize objects.

@pchaigno pchaigno force-pushed the recognize-function-bodies branch from c344651 to bd5b5d0 Compare September 10, 2015 10:35
@pchaigno
Copy link
Contributor Author

@50Wliu Travis build fixed!

@MaximSokolov
Copy link
Contributor

Hmm. All languages use meta.function scope only for function declaration. TextMate manual says that meta.function match function declaration:

... For example the entire line which declares a function would be meta.function...

I doubt we should change it.

I proposed meta.function-call and meta.method-call scopes expecting that meta.function would match functions' declarations. So if we merge this PR this code:

.meta.function {
  .entity.name.function {
      color: @color1;
  }
}

... would also highlight functions/methods calls:

function() {
  // `functionCall` would be highlighted
  // I assume `functionCall` is `entity.name.function`
  functionCall();
}

I suggest to add new scope under meta.* for functions' bodies.

@winstliu
Copy link
Contributor

Can we just make function-params also have the => part? Seems like a win-win. In addition, ( x => doesn't seem valid to me. x => or (x) => should be the only two that are valid, but I'm not exactly a Javascript expert.

@MaximSokolov
Copy link
Contributor

How about declaration sub-scope?

.function.declaration {
  .entity.name {
      color: @color1;
  }
}

.function-call, .method-call {
  .entity.name {
      color: @color2;
  }
}

'1':
'name': 'punctuation.definition.parameters.end.js'
'0':
'name': 'punctuation.definition.function.body.end.js'
'name': 'meta.function.prototype.js'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be updated, because the entire function block shouldn't be tokenized as a prototype.

@winstliu
Copy link
Contributor

@pchaigno A few comments:

  1. The names of each have to be updated I think. Maybe just move it to capture 0 of beginCaptures or give it a new name.
  2. Can function-params be included in function-body?
  3. There's conflicts :(

@MaximSokolov MaximSokolov mentioned this pull request Feb 6, 2016
@pchaigno pchaigno deleted the recognize-function-bodies branch March 2, 2016 20:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants