Skip to content

Commit 8c459b3

Browse files
authored
improvement: Also add metals v2 methods to RawPresentationCompiler (#8289)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added fluent configuration methods for progress bars and semantic database file management. * Introduced an enhanced factory method supporting additional source path configuration during instance initialization. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 1fda10b commit 8c459b3

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

mtags-interfaces/src/main/java/scala/meta/pc/RawPresentationCompiler.java

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616

1717
import java.net.URI;
1818
import java.nio.file.Path;
19+
import java.util.function.Supplier;
1920
import java.util.List;
2021
import java.util.Optional;
2122

2223
/**
23-
* The raw public API of the presentation compiler that does not handle synchronisation.
24-
* Scala compiler can't run concurrent code at that point, so we need to enforce sequential, single threaded execution.
25-
* It has to be implemented by the consumer of this API.
24+
* The raw public API of the presentation compiler that does not handle
25+
* synchronisation. Scala compiler can't run concurrent code at that point, so
26+
* we need to enforce sequential, single threaded execution. It has to be
27+
* implemented by the consumer of this API.
2628
*
2729
* This API should remain binary compatible
2830
*/
@@ -103,7 +105,8 @@ public abstract class RawPresentationCompiler {
103105
public abstract List<DocumentHighlight> documentHighlight(OffsetParams params);
104106

105107
/**
106-
* Returns the references of the symbol under the current position in the target files.
108+
* Returns the references of the symbol under the current position in the target
109+
* files.
107110
*/
108111
public abstract List<ReferencesResult> references(ReferencesRequest params);
109112

@@ -114,7 +117,8 @@ public abstract <T> List<TextEdit> codeAction(OffsetParams params, String codeAc
114117
Optional<T> codeActionPayload);
115118

116119
/**
117-
* Returns the list of code actions supported by the current presentation compiler.
120+
* Returns the list of code actions supported by the current presentation
121+
* compiler.
118122
*/
119123
public abstract List<String> supportedCodeActions();
120124

@@ -127,8 +131,7 @@ public abstract <T> List<TextEdit> codeAction(OffsetParams params, String codeAc
127131
/**
128132
* Return the necessary imports for a symbol at the given position.
129133
*/
130-
public abstract List<AutoImportsResult> autoImports(String name, OffsetParams params,
131-
Boolean isExtension);
134+
public abstract List<AutoImportsResult> autoImports(String name, OffsetParams params, Boolean isExtension);
132135

133136
/**
134137
* Return the missing implements and imports for the symbol at the given
@@ -159,8 +162,7 @@ public abstract List<AutoImportsResult> autoImports(String name, OffsetParams pa
159162
* Return named arguments for the apply method that encloses the given position.
160163
* May fail with a DisplayableException.
161164
*/
162-
public abstract List<TextEdit> convertToNamedArguments(OffsetParams params,
163-
List<Integer> argIndices);
165+
public abstract List<TextEdit> convertToNamedArguments(OffsetParams params, List<Integer> argIndices);
164166

165167
/**
166168
* The text contents of the given file changed.
@@ -211,6 +213,10 @@ public abstract List<TextEdit> convertToNamedArguments(OffsetParams params,
211213
*/
212214
public abstract RawPresentationCompiler withBuildTargetName(String buildTargetName);
213215

216+
public RawPresentationCompiler withProgressBars(ProgressBars progressBars) {
217+
return this;
218+
}
219+
214220
/**
215221
* Provide a SymbolSearch to extract docstrings, java parameter names and Scala
216222
* default parameter values.
@@ -228,6 +234,10 @@ public abstract List<TextEdit> convertToNamedArguments(OffsetParams params,
228234
*/
229235
public abstract RawPresentationCompiler withWorkspace(Path workspace);
230236

237+
public RawPresentationCompiler withSemanticdbFileManager(SemanticdbFileManager semanticdbFileManager) {
238+
return this;
239+
}
240+
231241
/**
232242
* Provide CompletionItemPriority for additional sorting completion items.
233243
*/
@@ -254,6 +264,27 @@ public abstract List<TextEdit> convertToNamedArguments(OffsetParams params,
254264
public abstract RawPresentationCompiler newInstance(String buildTargetIdentifier, List<Path> classpath,
255265
List<String> options);
256266

267+
/**
268+
* Construct a new presentation compiler with the given parameters.
269+
*
270+
* @param buildTargetIdentifier the build target containing this source file.
271+
* This is needed for
272+
* {@link #completionItemResolve(CompletionItem, String)}.
273+
* @param classpath the classpath of this build target.
274+
* @param options the compiler flags for the new compiler.
275+
* Important, it is recommended to disable all
276+
* compiler plugins excluding
277+
* org.scalamacros:paradise, kind-projector and
278+
* better-monadic-for.
279+
* @param sourcePath A supplier that returns the source path for this
280+
* build target, used by the PC to locate types
281+
* that have not been built yet.
282+
*/
283+
public RawPresentationCompiler newInstance(String buildTargetIdentifier, List<Path> classpath, List<String> options,
284+
Supplier<List<Path>> sourcePath) {
285+
return newInstance(buildTargetIdentifier, classpath, options);
286+
}
287+
257288
/**
258289
* Scala version for the current presentation compiler
259290
*/

0 commit comments

Comments
 (0)