Skip to content

Commit acec7de

Browse files
gselzerclaude
andcommitted
code-lsp: rename languageId to outputLanguage and language
ScriptDialect.languageId is now outputLanguage, the LSP language its scripts become, next to supports(ScriptLanguage), the language they come from. ServerLauncher.languageId is now language, as are the parameters and fields naming an LSP language. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 193a06d commit acec7de

19 files changed

Lines changed: 58 additions & 60 deletions

File tree

‎scijava-code-lsp-groovy/src/test/java/org/scijava/code/lsp/groovy/GroovyLanguageServerTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ public boolean supports(final ScriptLanguage language) {
487487
}
488488

489489
@Override
490-
public String languageId() {
490+
public String outputLanguage() {
491491
return "test";
492492
}
493493

‎scijava-code-lsp-jython/src/test/java/org/scijava/code/lsp/jython/JythonLanguageServerTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public boolean supports(final ScriptLanguage language) {
233233
}
234234

235235
@Override
236-
public String languageId() {
236+
public String outputLanguage() {
237237
return "jython";
238238
}
239239

‎scijava-code-lsp-ty/src/main/java/org/scijava/code/lsp/ty/TyLauncher.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ final class TyLauncher implements ServerLauncher {
118118
}
119119

120120
@Override
121-
public String languageId() {
121+
public String language() {
122122
return "python";
123123
}
124124

‎scijava-code-lsp-ty/src/test/java/org/scijava/code/lsp/ty/TyLanguageServerIntegrationTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public boolean supports(final ScriptLanguage language) {
269269
}
270270

271271
@Override
272-
public String languageId() {
272+
public String outputLanguage() {
273273
return "python";
274274
}
275275

‎scijava-code-lsp-ty/src/test/java/org/scijava/code/lsp/ty/TyLauncherTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public class TyLauncherTest {
5555
* Tests that the plugin offers servers for {@code python} documents
5656
*/
5757
@Test
58-
public void testLanguageId() {
58+
public void testLanguage() {
5959
final TyLauncher plugin = new TyLauncher();
60-
assertEquals("python", plugin.languageId());
60+
assertEquals("python", plugin.language());
6161
}
6262

6363
/**

‎scijava-code-lsp/src/main/java/org/scijava/code/lsp/LanguageServerService.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public interface LanguageServerService extends SciJavaService {
6060
* {@code python}): i.e. whether {@link #launch} gives a server of that
6161
* language, rather than the fallback.
6262
*/
63-
boolean supports(String languageId);
63+
boolean supports(String language);
6464

6565
/**
6666
* Gets a new server for an LSP language (e.g. {@code groovy}, or
@@ -74,5 +74,5 @@ public interface LanguageServerService extends SciJavaService {
7474
*
7575
* @param environment Where the scripts run.
7676
*/
77-
LanguageServer launch(String languageId, Environment environment);
77+
LanguageServer launch(String language, Environment environment);
7878
}

‎scijava-code-lsp/src/main/java/org/scijava/code/lsp/ScriptDialect.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ public interface ScriptDialect extends SciJavaPlugin {
6767
* Gets the LSP language (e.g. {@code python}) of the code scripts become:
6868
* whose servers analyze them (see {@link LanguageServerService#launch}).
6969
*/
70-
// TODO: Consider whether this is necessary: could the script language name
71-
// it, or servers be found some other way (e.g. by the dialect's class)?
72-
String languageId();
70+
String outputLanguage();
7371

7472
/**
7573
* Gets where a script runs, as far as its text says (e.g. an Appose

‎scijava-code-lsp/src/main/java/org/scijava/code/lsp/ScriptDocument.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,21 @@ final class ScriptDocument {
6464

6565
private final String original;
6666
private final String text;
67-
private final String languageId;
67+
private final String language;
6868
/** Where the script runs, as its dialect says, given its file. */
6969
private final BiFunction<String, Optional<File>, Environment> where;
7070
/** Number of characters prepended. */
7171
private final int headerLength;
7272
private final Set<String> hiddenNames;
7373

7474
private ScriptDocument(final String original, final String text,
75-
final String languageId,
75+
final String language,
7676
final BiFunction<String, Optional<File>, Environment> where,
7777
final int headerLength, final Set<String> hiddenNames)
7878
{
7979
this.original = original;
8080
this.text = text;
81-
this.languageId = languageId;
81+
this.language = language;
8282
this.where = where;
8383
this.headerLength = headerLength;
8484
this.hiddenNames = Collections.unmodifiableSet(hiddenNames);
@@ -114,7 +114,7 @@ static ScriptDocument of(final String script,
114114
if (!mentions(script, name)) hidden.add(name);
115115
}
116116
return new ScriptDocument(script, header + blank(script, removedLines),
117-
dialect.languageId(), dialect::environment, header.length(),
117+
dialect.outputLanguage(), dialect::environment, header.length(),
118118
hidden);
119119
}
120120

@@ -136,8 +136,8 @@ String text() {
136136
* The LSP language of the {@link #text()} (e.g. {@code python}), as its
137137
* dialect says; or {@code plaintext}, for a script as it is.
138138
*/
139-
String languageId() {
140-
return languageId;
139+
String language() {
140+
return language;
141141
}
142142

143143
/**

‎scijava-code-lsp/src/main/java/org/scijava/code/lsp/ScriptSession.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,17 +352,17 @@ private static Function<Environment, LanguageServer> launcher(
352352
final LanguageServerService servers, final ScriptLanguage language,
353353
final Optional<ScriptContext> live)
354354
{
355-
String id;
355+
String output;
356356
try {
357-
id = servers.dialect(language).languageId();
357+
output = servers.dialect(language).outputLanguage();
358358
}
359359
catch (final IllegalArgumentException exc) {
360360
// NB: The language has no dialect.
361-
id = ScriptDocument.of("").languageId();
361+
output = ScriptDocument.of("").language();
362362
}
363-
final String languageId = id;
364-
return env -> servers.launch(languageId, live.map(env::withLive).orElse(
365-
env));
363+
final String outputLanguage = output;
364+
return env -> servers.launch(outputLanguage, live.map(env::withLive)
365+
.orElse(env));
366366
}
367367

368368
/**
@@ -376,7 +376,7 @@ private static Function<String, ScriptDocument> transformer(
376376
{
377377
try {
378378
final ScriptDialect dialect = servers.dialect(language);
379-
if (servers.supports(dialect.languageId())) {
379+
if (servers.supports(dialect.outputLanguage())) {
380380
final ScriptProcessing processing = new ScriptProcessing(
381381
servers::context);
382382
return text -> document(processing, text, dialect, live.map(
@@ -575,7 +575,7 @@ private void stop(final LanguageServer s) {
575575

576576
/** Opens the server's copy of the script. */
577577
private void open() {
578-
final TextDocumentItem item = new TextDocumentItem(uri, doc.languageId(),
578+
final TextDocumentItem item = new TextDocumentItem(uri, doc.language(),
579579
version, doc.text());
580580
tell(s -> s.getTextDocumentService().didOpen(
581581
new DidOpenTextDocumentParams(item)));

‎scijava-code-lsp/src/main/java/org/scijava/code/lsp/impl/DefaultLanguageServerService.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@ public class DefaultLanguageServerService extends AbstractService implements
7171
@Override
7272
public boolean supports(final ScriptLanguage language) {
7373
try {
74-
return supports(dialect(language).languageId());
74+
return supports(dialect(language).outputLanguage());
7575
}
7676
catch (final IllegalArgumentException exc) {
7777
return false;
7878
}
7979
}
8080

8181
@Override
82-
public boolean supports(final String languageId) {
82+
public boolean supports(final String language) {
8383
try {
84-
plugin(languageId);
84+
plugin(language);
8585
return true;
8686
}
8787
catch (final IllegalArgumentException exc) {
@@ -90,19 +90,19 @@ public boolean supports(final String languageId) {
9090
}
9191

9292
@Override
93-
public LanguageServer launch(final String languageId,
93+
public LanguageServer launch(final String language,
9494
final Environment environment)
9595
{
9696
final LanguageServerPlugin plugin;
9797
try {
98-
plugin = plugin(languageId);
98+
plugin = plugin(language);
9999
}
100100
catch (final IllegalArgumentException exc) {
101101
// NB: No plugin serves the language.
102102
return new BindingsLanguageServer(environment);
103103
}
104104
// NB: Not caught: a server failing to start is a problem to be seen.
105-
return plugin.create(languageId, environment);
105+
return plugin.create(language, environment);
106106
}
107107

108108
/**
@@ -138,15 +138,15 @@ public synchronized void dispose() {
138138
*
139139
* @throws IllegalArgumentException If no plugin serves the language.
140140
*/
141-
private synchronized LanguageServerPlugin plugin(final String languageId) {
141+
private synchronized LanguageServerPlugin plugin(final String language) {
142142
if (plugins == null) {
143143
plugins = pluginService.createInstancesOfType(
144144
LanguageServerPlugin.class);
145145
}
146146
for (var p : plugins) {
147-
if (p.supports(languageId)) return p;
147+
if (p.supports(language)) return p;
148148
}
149149
throw new IllegalArgumentException(
150-
"No LanguageServerPlugin serves language: " + languageId);
150+
"No LanguageServerPlugin serves language: " + language);
151151
}
152152
}

0 commit comments

Comments
 (0)