Class SourceLanguageCapabilities
Published to the frontend so an action that cannot succeed is disabled before the user tries it. Copilot previously accepted every action and refused once the user had already dragged a component or typed a value, which reads as a bug rather than a limitation.
The command set here is the contract, not a description:
JavaRewriteHandler is verified against it by
SourceLanguageCapabilitiesTest, so a command cannot be registered
without being declared, nor declared without being handled.
-
Field Summary
FieldsModifier and TypeFieldDescriptionEvery source-rewriting command, matching the handlers registered byJavaRewriteHandler.Every command any language could support.Route-editing commands, registered byRouteHandler. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic booleanisSupported(SourceLanguage language, String command) static Set<SourceLanguage> The languages this project has sources in, derived from its source folders.supportedCommands(SourceLanguage language)
-
Field Details
-
ALL_COMMANDS
Every source-rewriting command, matching the handlers registered byJavaRewriteHandler. -
ROUTE_COMMANDS
Route-editing commands, registered byRouteHandler.Declared separately from
ALL_COMMANDSbecause the drift guard for that set checksJavaRewriteHandler's registry, which these are not part of: they rewrite a view's annotations rather than its component tree. Without them the Routes panel offered Save on a Kotlin view and threw when it was clicked. -
EVERY_COMMAND
Every command any language could support.
-
-
Method Details
-
isSupported
- Parameters:
language- the language of the source to be rewrittencommand- the wire command name- Returns:
- true if Copilot can perform this command on this language
-
supportedCommands
- Parameters:
language- the language of the source to be rewritten- Returns:
- the commands supported for it, possibly empty
-
projectLanguages
The languages this project has sources in, derived from its source folders.A project can have both, and often does: a Kotlin project created from a Java archetype keeps an empty
src/main/java. So this is a set rather than a single "project language", and per-component language is what actually decides whether an operation can run.- Returns:
- the languages, never empty — Java is assumed when nothing is detected
-
hasKotlinSources
public static boolean hasKotlinSources()- Returns:
- true if the project has Kotlin sources
-