forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jedi 0.11 parser + test fixes (#777)
* Basic tokenizer * Fixed property names * Tests, round I * Tests, round II * tokenizer test * Remove temorary change * Fix merge issue * Merge conflict * Merge conflict * Completion test * Fix last line * Fix javascript math * Make test await for results * Add license headers * Rename definitions to types * License headers * Fix typo in completion details (typo) * Fix hover test * Russian translations * Update to better translation * Fix typo * #70 How to get all parameter info when filling in a function param list * Fix #70 How to get all parameter info when filling in a function param list * Clean up * Clean imports * CR feedback * Trim whitespace for test stability * More tests * Better handle no-parameters documentation * Better handle ellipsis and Python3 * #385 Auto-Indentation doesn't work after comment * #141 Auto indentation broken when return keyword involved * Undo changes * #627 Docstrings for builtin methods are not parsed correctly * reStructuredText converter * Fix: period is not an operator * Minor fixes * Restructure * Tests * Tests * Code heuristics * Baselines * HTML handling * Lists * State machine * Baselines * Squash * no message * Whitespace difference * Update Jedi to 0.11.1 * Enable Travis * Test fixes * Undo change * Jedi 0.11 with parser * Undo changes * Undo changes * Test fixes * More tests * Tests
- Loading branch information
Mikhail Arkhipov
authored
Feb 15, 2018
1 parent
1c8b1a5
commit 5ccb9cd
Showing
168 changed files
with
6,662 additions
and
18,207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0
pythonFiles/release/jedi/__init__.py → pythonFiles/jedi/__init__.py
100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
0
pythonFiles/release/jedi/cache.py → pythonFiles/jedi/cache.py
100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
0
pythonFiles/release/jedi/debug.py → pythonFiles/jedi/debug.py
100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
0
pythonFiles/release/jedi/settings.py → pythonFiles/jedi/settings.py
100755 → 100644
File renamed without changes.
0
pythonFiles/release/jedi/utils.py → pythonFiles/jedi/utils.py
100755 → 100644
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
r""" | ||
Parso is a Python parser that supports error recovery and round-trip parsing | ||
for different Python versions (in multiple Python versions). Parso is also able | ||
to list multiple syntax errors in your python file. | ||
Parso has been battle-tested by jedi_. It was pulled out of jedi to be useful | ||
for other projects as well. | ||
Parso consists of a small API to parse Python and analyse the syntax tree. | ||
.. _jedi: https://github.com/davidhalter/jedi | ||
A simple example: | ||
>>> import parso | ||
>>> module = parso.parse('hello + 1', version="3.6") | ||
>>> expr = module.children[0] | ||
>>> expr | ||
PythonNode(arith_expr, [<Name: hello@1,0>, <Operator: +>, <Number: 1>]) | ||
>>> print(expr.get_code()) | ||
hello + 1 | ||
>>> name = expr.children[0] | ||
>>> name | ||
<Name: hello@1,0> | ||
>>> name.end_pos | ||
(1, 5) | ||
>>> expr.end_pos | ||
(1, 9) | ||
To list multiple issues: | ||
>>> grammar = parso.load_grammar() | ||
>>> module = grammar.parse('foo +\nbar\ncontinue') | ||
>>> error1, error2 = grammar.iter_errors(module) | ||
>>> error1.message | ||
'SyntaxError: invalid syntax' | ||
>>> error2.message | ||
"SyntaxError: 'continue' not properly in loop" | ||
""" | ||
|
||
from parso.parser import ParserSyntaxError | ||
from parso.grammar import Grammar, load_grammar | ||
from parso.utils import split_lines, python_bytes_to_unicode | ||
|
||
|
||
__version__ = '0.1.1' | ||
|
||
|
||
def parse(code=None, **kwargs): | ||
""" | ||
A utility function to avoid loading grammars. | ||
Params are documented in :py:meth:`parso.Grammar.parse`. | ||
:param str version: The version used by :py:func:`parso.load_grammar`. | ||
""" | ||
version = kwargs.pop('version', None) | ||
grammar = load_grammar(version=version) | ||
return grammar.parse(code, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
""" | ||
To ensure compatibility from Python ``2.6`` - ``3.3``, a module has been | ||
created. Clearly there is huge need to use conforming syntax. | ||
""" | ||
import sys | ||
import platform | ||
|
||
# Cannot use sys.version.major and minor names, because in Python 2.6 it's not | ||
# a namedtuple. | ||
py_version = int(str(sys.version_info[0]) + str(sys.version_info[1])) | ||
|
||
# unicode function | ||
try: | ||
unicode = unicode | ||
except NameError: | ||
unicode = str | ||
|
||
is_pypy = platform.python_implementation() == 'PyPy' | ||
|
||
|
||
def use_metaclass(meta, *bases): | ||
""" Create a class with a metaclass. """ | ||
if not bases: | ||
bases = (object,) | ||
return meta("HackClass", bases, {}) | ||
|
||
|
||
try: | ||
encoding = sys.stdout.encoding | ||
if encoding is None: | ||
encoding = 'utf-8' | ||
except AttributeError: | ||
encoding = 'ascii' | ||
|
||
|
||
def u(string): | ||
"""Cast to unicode DAMMIT! | ||
Written because Python2 repr always implicitly casts to a string, so we | ||
have to cast back to a unicode (and we now that we always deal with valid | ||
unicode, because we check that in the beginning). | ||
""" | ||
if py_version >= 30: | ||
return str(string) | ||
|
||
if not isinstance(string, unicode): | ||
return unicode(str(string), 'UTF-8') | ||
return string | ||
|
||
|
||
try: | ||
FileNotFoundError = FileNotFoundError | ||
except NameError: | ||
FileNotFoundError = IOError | ||
|
||
|
||
def utf8_repr(func): | ||
""" | ||
``__repr__`` methods in Python 2 don't allow unicode objects to be | ||
returned. Therefore cast them to utf-8 bytes in this decorator. | ||
""" | ||
def wrapper(self): | ||
result = func(self) | ||
if isinstance(result, unicode): | ||
return result.encode('utf-8') | ||
else: | ||
return result | ||
|
||
if py_version >= 30: | ||
return func | ||
else: | ||
return wrapper | ||
|
||
|
||
try: | ||
from functools import total_ordering | ||
except ImportError: | ||
# Python 2.6 | ||
def total_ordering(cls): | ||
"""Class decorator that fills in missing ordering methods""" | ||
convert = { | ||
'__lt__': [('__gt__', lambda self, other: not (self < other or self == other)), | ||
('__le__', lambda self, other: self < other or self == other), | ||
('__ge__', lambda self, other: not self < other)], | ||
'__le__': [('__ge__', lambda self, other: not self <= other or self == other), | ||
('__lt__', lambda self, other: self <= other and not self == other), | ||
('__gt__', lambda self, other: not self <= other)], | ||
'__gt__': [('__lt__', lambda self, other: not (self > other or self == other)), | ||
('__ge__', lambda self, other: self > other or self == other), | ||
('__le__', lambda self, other: not self > other)], | ||
'__ge__': [('__le__', lambda self, other: (not self >= other) or self == other), | ||
('__gt__', lambda self, other: self >= other and not self == other), | ||
('__lt__', lambda self, other: not self >= other)] | ||
} | ||
roots = set(dir(cls)) & set(convert) | ||
if not roots: | ||
raise ValueError('must define at least one ordering operation: < > <= >=') | ||
root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__ | ||
for opname, opfunc in convert[root]: | ||
if opname not in roots: | ||
opfunc.__name__ = opname | ||
opfunc.__doc__ = getattr(int, opname).__doc__ | ||
setattr(cls, opname, opfunc) | ||
return cls |
Oops, something went wrong.