mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-12 22:14:54 +00:00
Java (eclipse_jdtls): don't hard-ignore packages named dist/lib/classes/out (#1645)
EclipseJDTLS.is_ignored_dirname hard-ignored directories named target/build/bin/out/classes/dist/lib. Several of these (dist, lib, classes, out) are valid Java package identifiers, so any source file whose package path contained one was dropped from directory traversal and became invisible to the symbol tools (find_symbol, get_symbols_overview, find_referencing_symbols) even when git check-ignore reported nothing. Per maintainer guidance in #1645, remove the override entirely: the base is_ignored_dirname already skips _ALWAYS_IGNORED_DIRS (VCS/venv/cache/IDE internals), and real build output is already excluded via .gitignore, so the hardcoded list was both redundant and harmful. Adds a regression test (no Java/JDTLS process required) that fails on main and asserts the formerly-hardcoded names are no longer ignored while _ALWAYS_IGNORED_DIRS still are.
This commit is contained in:
1 parent
f6b6efa65b
commit
e08dfc7133
3 files changed
+33
-18
No files matched your search
@@ -68,6 +68,10 @@ Status of the `main` branch. Changes prior to the next official version change w
|
||||
- `Java`: invalidate JDTLS workspace cache when Java import settings change #1576
|
||||
- `Java`: use `JAVA_HOME` for Gradle import when `use_system_java_home` is enabled and `gradle_java_home`
|
||||
is unset. #1657
|
||||
- `Java`: stop hard-ignoring directories named `target`/`build`/`bin`/`out`/`classes`/`dist`/`lib` in
|
||||
`EclipseJDTLS`. These are all valid Java package identifiers, so ignoring them by name hid legitimate
|
||||
source from the symbol tools even when they were not gitignored. Removed the hardcoded override; real
|
||||
build output is already excluded via `.gitignore`. #1645
|
||||
- Improve quoting of arguments in shell executions
|
||||
- Add **LaTeX** support (experimental) via [texlab](https://github.com/latex-lsp/texlab).
|
||||
- PHP: add support for PHPantom as alternative to the already supported PHP LS #1554.
|
||||
|
||||
@@ -254,24 +254,6 @@ class EclipseJDTLS(SolidLanguageServer):
|
||||
ls_resources_dir = self.ls_resources_dir(self._solidlsp_settings)
|
||||
return self.DependencyProvider(self._custom_settings, ls_resources_dir, self._solidlsp_settings, self.repository_root_path)
|
||||
|
||||
@override
|
||||
def is_ignored_dirname(self, dirname: str) -> bool:
|
||||
# Ignore common Java build directories from different build tools:
|
||||
# - Maven: target
|
||||
# - Gradle: build, .gradle
|
||||
# - Eclipse: bin, .settings
|
||||
# - IntelliJ IDEA: out, .idea
|
||||
# - General: classes, dist, lib
|
||||
return super().is_ignored_dirname(dirname) or dirname in [
|
||||
"target", # Maven
|
||||
"build", # Gradle
|
||||
"bin", # Eclipse
|
||||
"out", # IntelliJ IDEA
|
||||
"classes", # General
|
||||
"dist", # General
|
||||
"lib", # General
|
||||
]
|
||||
|
||||
class DependencyProvider(LanguageServerDependencyProvider):
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
@@ -615,3 +615,32 @@ class TestComputeWorkspaceHash:
|
||||
configured_hash = EclipseJDTLS.DependencyProvider._compute_workspace_hash(self.REPO, self.DEFAULT_LAUNCHER, settings)
|
||||
|
||||
assert configured_hash != legacy_hash
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# is_ignored_dirname (directory-traversal filter)
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestIsIgnoredDirname:
|
||||
"""Regression for #1645: the Java language server must not hard-ignore directories whose names
|
||||
collide with build-tool output (``lib``, ``dist``, ``classes``, ``out``, ...). Those are all
|
||||
valid Java package identifiers, so ignoring them by name hid legitimate source from the symbol
|
||||
tools even when ``git check-ignore`` reported nothing. Real build output is already filtered via
|
||||
``.gitignore``, so directory traversal should only skip the language-agnostic
|
||||
``_ALWAYS_IGNORED_DIRS`` (VCS/venv/cache/IDE internals) inherited from the base language server.
|
||||
"""
|
||||
|
||||
@pytest.fixture
|
||||
def jdtls(self) -> EclipseJDTLS:
|
||||
# is_ignored_dirname only reads the class-level _ALWAYS_IGNORED_DIRS, so an uninitialized
|
||||
# instance is sufficient here (no Java or JDTLS process required).
|
||||
return object.__new__(EclipseJDTLS)
|
||||
|
||||
@pytest.mark.parametrize("dirname", ["lib", "dist", "classes", "out", "target", "build", "bin"])
|
||||
def test_valid_package_dirnames_are_not_ignored(self, jdtls: EclipseJDTLS, dirname: str) -> None:
|
||||
assert jdtls.is_ignored_dirname(dirname) is False
|
||||
|
||||
@pytest.mark.parametrize("dirname", [".git", ".venv", ".idea", ".serena", ".mypy_cache"])
|
||||
def test_always_ignored_dirs_are_still_ignored(self, jdtls: EclipseJDTLS, dirname: str) -> None:
|
||||
assert jdtls.is_ignored_dirname(dirname) is True
|
||||
Reference in new issue
Block a user