1
0
forked from VimPlug/jedi

Rename SubModule to Module, because that's a more fitting description. There were reasons for the name before the new fast parser, but those don't exist anymore.

This commit is contained in:
Dave Halter
2015-02-05 14:16:43 +01:00
parent c689573b0b
commit 0c1bbf78e2
4 changed files with 9 additions and 24 deletions

View File

@@ -156,10 +156,6 @@ def get_module_names(module, all_scopes):
return chain.from_iterable(dct.values())
class FakeSubModule():
line_offset = 0
class FakeImport(pr.Import):
def __init__(self, name, parent, level=0):
super(FakeImport, self).__init__([])

View File

@@ -90,7 +90,7 @@ class Parser(object):
'expr_stmt': pt.ExprStmt,
'classdef': pt.Class,
'funcdef': pt.Function,
'file_input': pt.SubModule,
'file_input': pt.Module,
'import_name': pt.ImportName,
'import_from': pt.ImportFrom,
'break_stmt': pt.KeywordStatement,

View File

@@ -10,7 +10,6 @@ from jedi._compatibility import use_metaclass, unicode
from jedi import settings
from jedi.parser import Parser
from jedi.parser import tree as pr
from jedi.parser import tokenize
from jedi import cache
from jedi import debug
from jedi.parser.tokenize import (source_tokens, NEWLINE,
@@ -19,7 +18,7 @@ from jedi.parser.tokenize import (source_tokens, NEWLINE,
FLOWS = ['if', 'else', 'elif', 'while', 'with', 'try', 'except', 'finally', 'for']
class FastModule(pr.SubModule):
class FastModule(pr.Module):
type = 'file_input'
def __init__(self, module_path):

View File

@@ -11,16 +11,16 @@ By using `get_code` on a module, you can get back the 1-to-1 representation of
the input given to the parser. This is important if you are using refactoring.
The easiest way to play with this module is to use :class:`parsing.Parser`.
:attr:`parsing.Parser.module` holds an instance of :class:`SubModule`:
:attr:`parsing.Parser.module` holds an instance of :class:`Module`:
>>> from jedi._compatibility import u
>>> from jedi.parser import Parser, load_grammar
>>> parser = Parser(load_grammar(), u('import os'), 'example.py')
>>> submodule = parser.module
>>> submodule
<SubModule: example.py@1-1>
<Module: example.py@1-1>
Any subclasses of :class:`Scope`, including :class:`SubModule` has an attribute
Any subclasses of :class:`Scope`, including :class:`Module` has an attribute
:attr:`imports <Scope.imports>`:
>>> submodule.imports
@@ -63,7 +63,7 @@ class DocstringMixin(object):
@property
def raw_doc(self):
""" Returns a cleaned version of the docstring token. """
if isinstance(self, SubModule):
if isinstance(self, Module):
stmt = self.children[0]
else:
stmt = self.children[self.children.index(':') + 1]
@@ -589,17 +589,7 @@ class Scope(Simple, DocstringMixin):
r = r.next
class Module(Base):
"""
For isinstance checks. fast_parser.Module also inherits from this.
"""
__slots__ = ()
def is_scope(self):
return True
class SubModule(Scope, Module):
class Module(Scope):
"""
The top scope, which is always a module.
Depending on the underlying parser this may be a full module or just a part
@@ -611,14 +601,14 @@ class SubModule(Scope, Module):
def __init__(self, children):
"""
Initialize :class:`SubModule`.
Initialize :class:`Module`.
:type path: str
:arg path: File path to this module.
.. todo:: Document `top_module`.
"""
super(SubModule, self).__init__(children)
super(Module, self).__init__(children)
self.path = None # Set later.
@property