gitnexus 1.6.6-rc.20 → 1.6.6-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -26,6 +26,40 @@ import { createVariableExtractor } from '../variable-extractors/generic.js';
|
|
|
26
26
|
import { javaVariableConfig } from '../variable-extractors/configs/jvm.js';
|
|
27
27
|
import { createHeritageExtractor } from '../heritage-extractors/generic.js';
|
|
28
28
|
import { emitJavaScopeCaptures, interpretJavaImport, interpretJavaTypeBinding, javaBindingScopeFor, javaImportOwningScope, javaMergeBindings, javaReceiverBinding, javaArityCompatibility, resolveJavaImportTarget, } from './java/index.js';
|
|
29
|
+
const orderJavaSameNameTypeCandidates = ({ callSiteFilePath, candidates, }) => {
|
|
30
|
+
if (!callSiteFilePath.endsWith('.java'))
|
|
31
|
+
return null;
|
|
32
|
+
if (candidates.length <= 1)
|
|
33
|
+
return null;
|
|
34
|
+
const callerDir = splitDirectorySegments(callSiteFilePath);
|
|
35
|
+
const scored = candidates.map((candidate, index) => ({
|
|
36
|
+
candidate,
|
|
37
|
+
index,
|
|
38
|
+
score: sharedPrefixLength(callerDir, splitDirectorySegments(candidate.filePath)),
|
|
39
|
+
}));
|
|
40
|
+
const bestScore = Math.max(...scored.map((entry) => entry.score));
|
|
41
|
+
// When all candidates tie, we have no structural signal to prefer one path.
|
|
42
|
+
// Returning null keeps downstream ambiguity handling conservative.
|
|
43
|
+
if (scored.every((entry) => entry.score === bestScore))
|
|
44
|
+
return null;
|
|
45
|
+
const ordered = [...scored]
|
|
46
|
+
.sort((a, b) => b.score - a.score || a.index - b.index)
|
|
47
|
+
.map((entry) => entry.candidate);
|
|
48
|
+
return ordered;
|
|
49
|
+
};
|
|
50
|
+
const splitDirectorySegments = (filePath) => {
|
|
51
|
+
const normalized = filePath.replace(/\\/g, '/');
|
|
52
|
+
// Remove empty segments from leading/trailing/multiple slashes, then drop filename.
|
|
53
|
+
const segments = normalized.split('/').filter(Boolean);
|
|
54
|
+
return segments.slice(0, -1);
|
|
55
|
+
};
|
|
56
|
+
const sharedPrefixLength = (left, right) => {
|
|
57
|
+
const max = Math.min(left.length, right.length);
|
|
58
|
+
let idx = 0;
|
|
59
|
+
while (idx < max && left[idx] === right[idx])
|
|
60
|
+
idx += 1;
|
|
61
|
+
return idx;
|
|
62
|
+
};
|
|
29
63
|
export const javaProvider = defineLanguage({
|
|
30
64
|
id: SupportedLanguages.Java,
|
|
31
65
|
extensions: ['.java'],
|
|
@@ -73,4 +107,5 @@ export const javaProvider = defineLanguage({
|
|
|
73
107
|
receiverBinding: javaReceiverBinding,
|
|
74
108
|
arityCompatibility: javaArityCompatibility,
|
|
75
109
|
resolveImportTarget: resolveJavaImportTarget,
|
|
110
|
+
orderSameNameTypeCandidates: orderJavaSameNameTypeCandidates,
|
|
76
111
|
});
|
package/package.json
CHANGED