-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
36 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
default_language_version: | ||
python: python | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.0.1 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: debug-statements | ||
stages: [commit] | ||
- id: end-of-file-fixer | ||
stages: [commit] | ||
- id: trailing-whitespace | ||
- repo: https://github.com/psf/black | ||
rev: 22.3.0 | ||
hooks: | ||
- id: black | ||
language_version: python3 | ||
exclude: 'mathicsscript/version.py' | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 3.9.2 | ||
hooks: | ||
- id: flake8 | ||
stages: [commit] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (C) 2021 Rocky Bernstein <[email protected]> | ||
|
||
# Copyright (C) 2021-2022 Rocky Bernstein <[email protected]> | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
|
@@ -17,7 +18,7 @@ | |
import os.path as osp | ||
import re | ||
|
||
from typing import Iterable, NamedTuple | ||
from typing import Iterable, List, NamedTuple, Tuple | ||
|
||
from mathics.core.symbols import strip_context | ||
from mathics_scanner import named_characters | ||
|
@@ -82,7 +83,7 @@ def __init__(self, definitions): | |
|
||
self.escape_sequences = aliased_characters.keys() | ||
|
||
def _is_space_before_cursor(self, document, text_before_cursor: bool) -> bool: | ||
def _is_space_before_cursor(self, document, text_before_cursor: str) -> bool: | ||
"""Space before or no text before cursor.""" | ||
return text_before_cursor == "" or text_before_cursor[-1:].isspace() | ||
|
||
|
@@ -121,7 +122,7 @@ def word_matches(word: str) -> bool: | |
display_meta=display_meta, | ||
) | ||
|
||
def get_word_before_cursor_with_kind(self, document: Document) -> WordToken: | ||
def get_word_before_cursor_with_kind(self, document: Document) -> Tuple[str, TokenKind]: | ||
""" | ||
Get the word before the cursor and clasify it into one of the kinds | ||
of tokens: NamedCharacter, AsciiOperator, Symbol, etc. | ||
|
@@ -164,7 +165,7 @@ def get_word_before_cursor_with_kind(self, document: Document) -> WordToken: | |
|
||
return word_before_cursor, TokenKind.Symbol | ||
|
||
def get_word_names(self: str): | ||
def get_word_names(self) -> List[str]: | ||
names = self.definitions.get_names() | ||
short_names = [strip_context(m) for m in names] | ||
return list(names) + short_names |
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
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