Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: third_party/closure_linter/closure_linter/javascriptstatetracker.py

Issue 2328693002: Updated linter with upstream release (2.3.19) (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2008 The Closure Linter Authors. All Rights Reserved. 2 # Copyright 2008 The Closure Linter Authors. All Rights Reserved.
3 # 3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License. 5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at 6 # You may obtain a copy of the License at
7 # 7 #
8 # http://www.apache.org/licenses/LICENSE-2.0 8 # http://www.apache.org/licenses/LICENSE-2.0
9 # 9 #
10 # Unless required by applicable law or agreed to in writing, software 10 # Unless required by applicable law or agreed to in writing, software
(...skipping 17 matching lines...) Expand all
28 class JsDocFlag(statetracker.DocFlag): 28 class JsDocFlag(statetracker.DocFlag):
29 """Javascript doc flag object. 29 """Javascript doc flag object.
30 30
31 Attribute: 31 Attribute:
32 flag_type: param, return, define, type, etc. 32 flag_type: param, return, define, type, etc.
33 flag_token: The flag token. 33 flag_token: The flag token.
34 type_start_token: The first token specifying the flag JS type, 34 type_start_token: The first token specifying the flag JS type,
35 including braces. 35 including braces.
36 type_end_token: The last token specifying the flag JS type, 36 type_end_token: The last token specifying the flag JS type,
37 including braces. 37 including braces.
38 type: The JavaScript type spec. 38 type: The type spec string.
39 jstype: The type spec, a TypeAnnotation instance.
39 name_token: The token specifying the flag name. 40 name_token: The token specifying the flag name.
40 name: The flag name 41 name: The flag name
41 description_start_token: The first token in the description. 42 description_start_token: The first token in the description.
42 description_end_token: The end token in the description. 43 description_end_token: The end token in the description.
43 description: The description. 44 description: The description.
44 """ 45 """
45 46
46 # Please keep these lists alphabetized. 47 # Please keep these lists alphabetized.
47 48
48 # Some projects use the following extensions to JsDoc. 49 # Some projects use the following extensions to JsDoc.
49 # TODO(robbyw): determine which of these, if any, should be illegal. 50 # TODO(robbyw): determine which of these, if any, should be illegal.
50 EXTENDED_DOC = frozenset([ 51 EXTENDED_DOC = frozenset([
51 'class', 'code', 'desc', 'final', 'hidden', 'inheritDoc', 'link', 52 'class', 'code', 'desc', 'final', 'hidden', 'inheritDoc', 'link',
52 'meaning', 'provideGoog', 'throws']) 53 'meaning', 'provideGoog', 'throws'])
53 54
54 LEGAL_DOC = EXTENDED_DOC | statetracker.DocFlag.LEGAL_DOC 55 LEGAL_DOC = EXTENDED_DOC | statetracker.DocFlag.LEGAL_DOC
55 56
56 def __init__(self, flag_token):
57 """Creates the JsDocFlag object and attaches it to the given start token.
58
59 Args:
60 flag_token: The starting token of the flag.
61 """
62 statetracker.DocFlag.__init__(self, flag_token)
63
64 57
65 class JavaScriptStateTracker(statetracker.StateTracker): 58 class JavaScriptStateTracker(statetracker.StateTracker):
66 """JavaScript state tracker. 59 """JavaScript state tracker.
67 60
68 Inherits from the core EcmaScript StateTracker adding extra state tracking 61 Inherits from the core EcmaScript StateTracker adding extra state tracking
69 functionality needed for JavaScript. 62 functionality needed for JavaScript.
70 """ 63 """
71 64
72 def __init__(self): 65 def __init__(self):
73 """Initializes a JavaScript token stream state tracker.""" 66 """Initializes a JavaScript token stream state tracker."""
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 if token.type == Type.START_BLOCK: 141 if token.type == Type.START_BLOCK:
149 self._block_stack.append(token) 142 self._block_stack.append(token)
150 if token.type == Type.IDENTIFIER and token.string == 'goog.scope': 143 if token.type == Type.IDENTIFIER and token.string == 'goog.scope':
151 self._scope_depth += 1 144 self._scope_depth += 1
152 if token.type == Type.END_BLOCK: 145 if token.type == Type.END_BLOCK:
153 start_token = self._block_stack.pop() 146 start_token = self._block_stack.pop()
154 if tokenutil.GoogScopeOrNoneFromStartBlock(start_token): 147 if tokenutil.GoogScopeOrNoneFromStartBlock(start_token):
155 self._scope_depth -= 1 148 self._scope_depth -= 1
156 super(JavaScriptStateTracker, self).HandleToken(token, 149 super(JavaScriptStateTracker, self).HandleToken(token,
157 last_non_space_token) 150 last_non_space_token)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698