diff --git a/grammars/javascript.cson b/grammars/javascript.cson index dbb51a42..dd882819 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -430,6 +430,10 @@ 'match': '(?<=\\.)(s(hape|ystemId|c(heme|ope|rolling)|ta(ndby|rt)|ize|ummary|pecified|e(ctionRowIndex|lected(Index)?)|rc)|h(space|t(tpEquiv|mlFor)|e(ight|aders)|ref(lang)?)|n(o(Resize|tation(s|Name)|Shade|Href|de(Name|Type|Value)|Wrap)|extSibling|ame)|c(h(ildNodes|Off|ecked|arset)?|ite|o(ntent|o(kie|rds)|de(Base|Type)?|l(s|Span|or)|mpact)|ell(s|Spacing|Padding)|l(ear|assName)|aption)|t(ype|Bodies|itle|Head|ext|a(rget|gName)|Foot)|i(sMap|ndex|d|m(plementation|ages))|o(ptions|wnerDocument|bject)|d(i(sabled|r)|o(c(type|umentElement)|main)|e(clare|f(er|ault(Selected|Checked|Value)))|at(eTime|a))|useMap|p(ublicId|arentNode|r(o(file|fileEnd|mpt)|eviousSibling))|e(n(ctype|tities)|vent|lements)|v(space|ersion|alue(Type)?|Link|Align)|URL|f(irstChild|orm(s)?|ace|rame(Border)?)|width|l(ink(s)?|o(ngDesc|wSrc)|a(stChild|ng|bel))|a(nchors|c(ce(ssKey|pt(Charset)?)|tion)|ttributes|pplets|l(t|ign)|r(chive|eas)|xis|Link|bbr)|r(ow(s|Span|Index)|ules|e(v|ferrer|l|adOnly))|m(ultiple|e(thod|dia)|a(rgin(Height|Width)|xLength))|b(o(dy|rder)|ackground|gColor))\\b' 'name': 'support.constant.dom.js' } + { + 'match': '(?<=(?:[a-zA-Z_$0-9]\\.))([a-zA-Z_$][a-zA-Z_$0-9]*)' + 'name': 'entity.name.property.js' + } { 'match': '\\b(ELEMENT_NODE|ATTRIBUTE_NODE|TEXT_NODE|CDATA_SECTION_NODE|ENTITY_REFERENCE_NODE|ENTITY_NODE|PROCESSING_INSTRUCTION_NODE|COMMENT_NODE|DOCUMENT_NODE|DOCUMENT_TYPE_NODE|DOCUMENT_FRAGMENT_NODE|NOTATION_NODE|INDEX_SIZE_ERR|DOMSTRING_SIZE_ERR|HIERARCHY_REQUEST_ERR|WRONG_DOCUMENT_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR|NOT_SUPPORTED_ERR|INUSE_ATTRIBUTE_ERR)\\b' 'name': 'support.constant.dom.js' @@ -573,7 +577,7 @@ 'name': 'meta.method.js' 'comment': 'match regular function like: function myFunc(arg) { … }' - 'begin': '\\b((?!(?:break|case|catch|continue|do|else|finally|for|function|if|export|import|package|return|switch|throw|try|while|with)[\\s\\(])(?:[a-zA-Z_$][a-zA-Z_$0-9]*))\\s*(\\()(?=(?:[^\\(\\)]*)?\\)\\s*\\{)' + 'begin': '\\b((?!(?:break|case|catch|continue|do|else|finally|for|function|if|export|import|package|return|switch|throw|try|while|with)[\\s\\(])(?:[a-zA-Z_$][a-zA-Z_$0-9]*))\\s*(\\()(?![^a-zA-Z_$\\.\\)])(?=(?:[^\\(\\)]*)?\\)\\s*\\{)' 'beginCaptures': '1': 'name': 'entity.name.function.js' diff --git a/spec/javascript-spec.coffee b/spec/javascript-spec.coffee index 34e1e9fe..a0d8db95 100644 --- a/spec/javascript-spec.coffee +++ b/spec/javascript-spec.coffee @@ -186,6 +186,13 @@ describe "Javascript grammar", -> expect(tokens[6]).toEqual value: '42', scopes: ['source.js', 'constant.numeric.js'] expect(tokens[7]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js'] + describe "Properties", -> + it "tokenizes properties", -> + {tokens} = grammar.tokenizeLine('obj.prop1.prop2.prop3') + expect(tokens[2]).toEqual value: 'prop1', scopes: ['source.js', 'entity.name.property.js'] + expect(tokens[4]).toEqual value: 'prop2', scopes: ['source.js', 'entity.name.property.js'] + expect(tokens[6]).toEqual value: 'prop3', scopes: ['source.js', 'entity.name.property.js'] + describe "ES6 string templates", -> it "tokenizes them as strings", -> {tokens} = grammar.tokenizeLine('`hey ${name}`')