コード例 #1
0
ファイル: unused.py プロジェクト: lacygoill/vim-pythonx
    def _is_just_assigned(buffer, identifier):
        if DefaultCompleter._is_assigned(buffer, identifier):
            return True

        if DefaultCompleter._is_func_argument(buffer, identifier):
            return True

        return False
コード例 #2
0
ファイル: unused.py プロジェクト: lacygoill/vim-pythonx
    def _default_identifier_extractor(line_number, line):
        buffer = px.buffer.get()

        identifiers = DefaultCompleter._default_identifier_extractor(
            line_number, line)

        try:
            for identifier in identifiers:
                seen = identifier.name in UnusedIdentifierCompleter._seen
                if not seen and UnusedIdentifierCompleter._is_just_assigned(
                        buffer, identifier):
                    yield identifier
                else:
                    UnusedIdentifierCompleter._seen[identifier.name] = True
        except:
            pass
コード例 #3
0
ファイル: __init__.py プロジェクト: lacygoill/vim-pythonx
import px.common
import px.cursor
import px.identifiers
import px.buffer
import px.syntax

from px.langs.go.autoimport import Autoimporter
from px.langs.go.completion import DefaultCompleter
from px.langs.go.completion.unused import UnusedIdentifierCompleter


GOROOT = subprocess.check_output(['go', 'env', 'GOROOT']).strip()
GOPATH = subprocess.check_output(['go', 'env', 'GOPATH']).strip()

_DefaultAutoimporter = Autoimporter()
_DefaultCompleter = DefaultCompleter()

_UnusedIdentifierCompleter = UnusedIdentifierCompleter()


def extract_prev_method_binding(buffer, cursor):
    search_space = px.buffer.get_before_cursor(buffer, cursor)

    def extract_from_type_definition():
        matches = re.findall(r'(?m)^type (\w+) ', search_space)

        if matches != []:
            type_name = matches[-1]
            object_name = re.findall(
                r'(\w[^A-Z]+|[A-Z_-]+)',
                type_name