Skip to content

Commit 9654c12

Browse files
committed
Renamed some internal only stuff
1 parent e4183c4 commit 9654c12

File tree

8 files changed

+41
-41
lines changed

8 files changed

+41
-41
lines changed

hdl_checker/base_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
WatchedFile = NamedTuple("WatchedFile", (("path", Path), ("last_read", float)))
8383

8484

85-
class HdlCodeCheckerBase(object): # pylint: disable=useless-object-inheritance
85+
class BaseServer(object): # pylint: disable=useless-object-inheritance
8686
"""
8787
HDL Checker project builder class
8888
"""

hdl_checker/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __str__(self):
7171
class HdlCheckerNotInitializedError(HdlCheckerBaseException):
7272
"""
7373
Exception thrown by the LSP server when the client asks for info that
74-
depends on having HdlCodeCheckerBase properly setup.
74+
depends on having BaseServer properly setup.
7575
"""
7676
def __str__(self):
7777
return "HDL Checker server needs a root URI to work correctly"

hdl_checker/handlers.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
from hdl_checker import __version__ as version
3030
from hdl_checker import types as t # pylint: disable=unused-import
31+
from hdl_checker.base_server import BaseServer
3132
from hdl_checker.builders.fallback import Fallback
32-
from hdl_checker.base_server import HdlCodeCheckerBase
3333
from hdl_checker.path import Path
3434
from hdl_checker.utils import terminateProcess
3535

@@ -38,15 +38,15 @@
3838
app = bottle.Bottle() # pylint: disable=invalid-name
3939

4040

41-
class HdlCodeCheckerServer(HdlCodeCheckerBase):
41+
class Server(BaseServer):
4242
"""
4343
HDL Checker project builder class
4444
"""
4545

4646
def __init__(self, *args, **kwargs):
4747
# type: (...) -> None
4848
self._msg_queue = Queue() # type: Queue[Tuple[str, str]]
49-
super(HdlCodeCheckerServer, self).__init__(*args, **kwargs)
49+
super(Server, self).__init__(*args, **kwargs)
5050

5151
def _handleUiInfo(self, message):
5252
# type: (...) -> Any
@@ -68,11 +68,10 @@ def getQueuedMessages(self):
6868

6969

7070
def _getServerByProjectFile(project_file):
71-
# type: (Optional[str]) -> HdlCodeCheckerServer
71+
# type: (Optional[str]) -> Server
7272
"""
73-
Returns the HdlCodeCheckerServer object that corresponds to the given
74-
project file. If the object doesn't exists yet it gets created and
75-
then returned
73+
Returns the Server object that corresponds to the given project file. If
74+
the object doesn't exists yet it gets created and then returned
7675
"""
7776
_logger.debug("project_file: %s", project_file)
7877
if isinstance(project_file, str) and project_file.lower() == "none":
@@ -87,13 +86,13 @@ def _getServerByProjectFile(project_file):
8786
if root_dir not in servers:
8887
_logger.info("Creating server for %s (root=%s)", project_file, root_dir)
8988
try:
90-
project = HdlCodeCheckerServer(root_dir=root_dir)
89+
project = Server(root_dir=root_dir)
9190
if project_file is not None:
9291
project.setConfig(project_file)
9392
_logger.debug("Created new project server for '%s'", project_file)
9493
except (IOError, OSError):
9594
_logger.info("Failed to create checker, reverting to fallback")
96-
project = HdlCodeCheckerServer(None)
95+
project = Server(None)
9796

9897
servers[root_dir] = project
9998
return servers[root_dir]
@@ -302,5 +301,5 @@ def getBuildSequence():
302301

303302

304303
# We'll store a dict to store differents hdl_checker objects
305-
servers = {} # type: Dict[Path, HdlCodeCheckerServer] # pylint: disable=invalid-name
304+
servers = {} # type: Dict[Path, Server] # pylint: disable=invalid-name
306305
setupSignalHandlers()

hdl_checker/lsp.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from tabulate import tabulate
3131

3232
from hdl_checker import DEFAULT_PROJECT_FILE
33-
from hdl_checker.base_server import HdlCodeCheckerBase
33+
from hdl_checker.base_server import BaseServer
3434
from hdl_checker.config_generators.simple_finder import SimpleFinder
3535
from hdl_checker.database import _DEFAULT_LIBRARY_NAME
3636
from hdl_checker.diagnostics import CheckerDiagnostic, DiagType
@@ -103,15 +103,15 @@ def checkerDiagToLspDict(diag):
103103
return result
104104

105105

106-
class HdlCodeCheckerServer(HdlCodeCheckerBase):
106+
class Server(BaseServer):
107107
"""
108108
HDL Checker project builder class
109109
"""
110110

111-
def __init__(self, workspace, root_path):
112-
# type: (Workspace, str) -> None
111+
def __init__(self, workspace, root_dir):
112+
# type: (Workspace, Path) -> None
113113
self._workspace = workspace
114-
super(HdlCodeCheckerServer, self).__init__(Path(root_path))
114+
super(Server, self).__init__(root_dir)
115115

116116
def _handleUiInfo(self, message):
117117
# type: (...) -> Any
@@ -141,7 +141,7 @@ class HdlCheckerLanguageServer(PythonLanguageServer):
141141

142142
def __init__(self, *args, **kwargs):
143143
# type: (...) -> None
144-
self._checker = None # type: Optional[HdlCodeCheckerServer]
144+
self._checker = None # type: Optional[Server]
145145
super(HdlCheckerLanguageServer, self).__init__(*args, **kwargs)
146146
# Default checker
147147
self._onConfigUpdate({"project_file": None})
@@ -233,8 +233,8 @@ def _onConfigUpdate(self, options):
233233
if not self.workspace or not self.workspace.root_uri:
234234
return
235235

236-
root_path = to_fs_path(self.workspace.root_uri)
237-
self._checker = HdlCodeCheckerServer(self.workspace, root_path=root_path)
236+
root_dir = to_fs_path(self.workspace.root_uri)
237+
self._checker = Server(self.workspace, root_dir=Path(root_dir))
238238

239239
_logger.debug("Updating from %s", options)
240240

hdl_checker/path.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def __str__(self):
9292
return self.name
9393

9494
def __repr__(self):
95-
return "Path({})".format(repr(self.name))
95+
# type: () -> str
96+
return "{}({})".format(self.__class__.__name__, repr(self.name))
9697

9798
@property
9899
def stat(self):

hdl_checker/tests/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from parameterized import parameterized_class # type: ignore
3333

3434
from hdl_checker import exceptions
35-
from hdl_checker.base_server import HdlCodeCheckerBase
35+
from hdl_checker.base_server import BaseServer
3636
from hdl_checker.builders.base_builder import BaseBuilder
3737
from hdl_checker.parsers.elements.dependency_spec import DependencySpec
3838
from hdl_checker.parsers.elements.identifier import Identifier
@@ -46,8 +46,8 @@
4646
MockDep = Union[Tuple[str], Tuple[str, str]]
4747

4848

49-
class StandaloneProjectBuilder(HdlCodeCheckerBase):
50-
"Class for testing HdlCodeCheckerBase"
49+
class DummyServer(BaseServer):
50+
"Class for testing BaseServer"
5151
_msg_queue = Queue() # type: Queue[Tuple[str, str]]
5252
_ui_handler = logging.getLogger("UI")
5353

hdl_checker/tests/test_base_server.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
MockBuilder,
4040
PatchBuilder,
4141
SourceMock,
42-
StandaloneProjectBuilder,
42+
DummyServer,
4343
assertCountEqual,
4444
assertSameFile,
4545
getTestTempPath,
@@ -136,7 +136,7 @@ def _assertMsgQueueIsEmpty(project):
136136
@it.should("warn when setup is taking too long")
137137
@patch("hdl_checker.base_server._HOW_LONG_IS_TOO_LONG", 0.1)
138138
@patch.object(
139-
hdl_checker.base_server.HdlCodeCheckerBase,
139+
hdl_checker.base_server.BaseServer,
140140
"configure",
141141
lambda *_: time.sleep(0.5),
142142
)
@@ -151,7 +151,7 @@ def test():
151151
open(config, "w").write("")
152152
open(source, "w").write("")
153153

154-
project = StandaloneProjectBuilder(_Path(path))
154+
project = DummyServer(_Path(path))
155155
project.setConfig(Path(config))
156156
# Get messages of anything to trigger reading the config
157157
project.getMessagesByPath(Path(source))
@@ -176,7 +176,7 @@ def test():
176176
open(config, "w").write("")
177177
open(source, "w").write("")
178178

179-
project = StandaloneProjectBuilder(_Path(path))
179+
project = DummyServer(_Path(path))
180180
project.setConfig(Path(config))
181181
# Get messages of anything to trigger reading the config
182182
project.getMessagesByPath(Path(source))
@@ -196,15 +196,15 @@ def setup():
196196

197197
@it.should("raise exception when trying to instantiate") # type: ignore
198198
def test():
199-
project = StandaloneProjectBuilder(_Path("nonexisting"))
199+
project = DummyServer(_Path("nonexisting"))
200200
with it.assertRaises(FileNotFoundError):
201201
project.setConfig(str(it.project_file))
202202

203203
with it.having("no project file at all"):
204204

205205
@it.has_setup
206206
def setup():
207-
it.project = StandaloneProjectBuilder(Path(TEST_PROJECT))
207+
it.project = DummyServer(Path(TEST_PROJECT))
208208

209209
@it.should("use fallback to Fallback builder") # type: ignore
210210
def test():
@@ -240,7 +240,7 @@ def test():
240240
def setup():
241241
setupTestSuport(TEST_TEMP_PATH)
242242

243-
it.project = StandaloneProjectBuilder(_Path(TEST_TEMP_PATH))
243+
it.project = DummyServer(_Path(TEST_TEMP_PATH))
244244

245245
it.config_file = _makeConfigFromDict(
246246
{
@@ -299,15 +299,15 @@ def test():
299299

300300
@it.should("recover from cache") # type: ignore
301301
@patchClassMap(MockBuilder=MockBuilder)
302-
@patch("hdl_checker.base_server.HdlCodeCheckerBase._setState")
302+
@patch("hdl_checker.base_server.BaseServer._setState")
303303
def test(set_state):
304304
source = _SourceMock(
305305
library="some_lib", design_units=[{"name": "target", "type": "entity"}]
306306
)
307307

308308
it.project.getMessagesByPath(source.filename)
309309

310-
_ = StandaloneProjectBuilder(_Path(TEST_TEMP_PATH))
310+
_ = DummyServer(_Path(TEST_TEMP_PATH))
311311

312312
set_state.assert_called_once()
313313

@@ -334,7 +334,7 @@ def test():
334334

335335
it.project.clean()
336336

337-
project = StandaloneProjectBuilder(_Path(TEST_TEMP_PATH))
337+
project = DummyServer(_Path(TEST_TEMP_PATH))
338338

339339
if not ON_WINDOWS:
340340
it.assertMsgQueueIsEmpty(project)
@@ -355,7 +355,7 @@ def test():
355355
open(cache_filename.name, "w").write("corrupted cache contents")
356356

357357
# Try to recreate
358-
project = StandaloneProjectBuilder(root_dir)
358+
project = DummyServer(root_dir)
359359

360360
if six.PY2:
361361
it.assertIn(
@@ -552,7 +552,7 @@ def setup():
552552
removeIfExists(p.join(TEST_TEMP_PATH, WORK_PATH, CACHE_NAME))
553553

554554
with PatchBuilder():
555-
it.project = StandaloneProjectBuilder(_Path(TEST_TEMP_PATH))
555+
it.project = DummyServer(_Path(TEST_TEMP_PATH))
556556
it.project.setConfig(Path(p.join(TEST_PROJECT, "vimhdl.prj")))
557557
it.project._updateConfigIfNeeded()
558558

hdl_checker/tests/test_lsp.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
VhdlDesignUnit,
5555
)
5656
from hdl_checker.parsers.elements.identifier import Identifier
57-
from hdl_checker.path import Path
57+
from hdl_checker.path import Path, TemporaryPath
5858
from hdl_checker.types import Location
5959

6060
from hdl_checker.tests import ( # isort:skip
@@ -157,8 +157,8 @@ def test_workspace_notify(self):
157157
# type: (...) -> Any
158158
workspace = MagicMock(spec=Workspace)
159159

160-
server = lsp.HdlCodeCheckerServer(
161-
workspace, root_path=mkdtemp(prefix="hdl_checker_")
160+
server = lsp.Server(
161+
workspace, root_path=TemporaryPath(mkdtemp(prefix="hdl_checker_"))
162162
)
163163

164164
server._handleUiInfo("some info") # pylint: disable=protected-access
@@ -613,7 +613,7 @@ def test_ReportBuildSequenceMarkdown(self):
613613
self.runTestBuildSequenceTable(tablefmt="github")
614614

615615
@patch.object(
616-
hdl_checker.base_server.HdlCodeCheckerBase,
616+
hdl_checker.base_server.BaseServer,
617617
"resolveDependencyToPath",
618618
lambda self, _: None,
619619
)
@@ -631,7 +631,7 @@ def test_DependencyInfoForPathNotFound(self):
631631
)
632632

633633
@patch.object(
634-
hdl_checker.base_server.HdlCodeCheckerBase,
634+
hdl_checker.base_server.BaseServer,
635635
"resolveDependencyToPath",
636636
lambda self, _: (Path("some_path"), Identifier("some_library")),
637637
)

0 commit comments

Comments
 (0)