Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

[feat] GO support #43

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft

[feat] GO support #43

wants to merge 35 commits into from

Conversation

maclick
Copy link

@maclick maclick commented Jan 24, 2024

  • [feature] create go build target |#BAZEL-784 Done
  • calculateAllGoSdkInfos done
  • added setSdk
  • go sdk mock works
  • changed home path to /usr/local/go
  • added isGoSupportEnabled = true for each module
  • extension point for Go SDK - not yet full working

@maclick maclick changed the title go support [feat] GO support Jan 24, 2024
@maclick maclick marked this pull request as draft January 24, 2024 00:28
maclick and others added 16 commits January 24, 2024 01:32
# Conflicts:
#	buildSrc/src/main/kotlin/versions.kt
#	protocol/src/main/kotlin/org/jetbrains/bsp/utils/Extractors.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/config/BspFeatureFlags.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/server/tasks/CollectProjectDetailsTask.kt
#	src/main/resources/META-INF/plugin.xml
#	src/main/resources/messages/BspPluginBundle.properties
# Conflicts:
#	buildSrc/src/main/kotlin/versions.kt
#	protocol/src/main/kotlin/org/jetbrains/bsp/protocol/utils/Extractors.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/TargetIdToModuleEntitiesMap.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/GoWorkspaceModelEntities.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/impl/WorkspaceModelUpdaterImpl.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/impl/updaters/GoModuleUpdater.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/impl/updaters/transformers/ModuleDetailsToGoModuleTransformer.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/impl/updaters/transformers/ProjectDetailsToModuleDetailsTransformer.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/server/tasks/CollectProjectDetailsTask.kt
#	src/main/resources/messages/BspPluginBundle.properties
* added isGoSupportEnabled = true for each module

* fixed imports and added toGoModule

---------

Co-authored-by: Maciej Bielik <[email protected]>
# Conflicts:
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/DefaultMagicMetaModelState.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/JavaWorkspaceModelEntities.kt
# Conflicts:
#	src/main/kotlin/org/jetbrains/plugins/bsp/server/tasks/CollectProjectDetailsTask.kt
Copy link
Member

@abrams27 abrams27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small thing

public fun goSdkExtensionExists(): Boolean = ep.extensionList.isNotEmpty()

public class GoSdkGetter: GoSdkGetterExtension {
private var goSdks: Set<GoSdk> = emptySet()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extension points shouldnt have state, so i'd be better to keep it in a service with state

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump (you can check DefaultConnectionDetailsProviderExtension for an inspiration)

# Conflicts:
#	buildSrc/src/main/kotlin/versions.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/MagicMetaModelImpl.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/TargetIdToModuleEntitiesMap.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/WorkspaceModelToModulesMapTransformer.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/magicmetamodel/impl/workspacemodel/impl/WorkspaceModelUpdaterImpl.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/server/tasks/CollectProjectDetailsTask.kt
#	src/main/kotlin/org/jetbrains/plugins/bsp/ui/gutters/BspJVMRunLineMarkerContributor.kt
#	src/main/resources/META-INF/plugin.xml
Copy link
Member

@abrams27 abrams27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks nice in general some comments / questions


public data class LibraryItem(
val id: BuildTargetIdentifier,
val dependencies: List<BuildTargetIdentifier>,
val ijars: List<String>,
val jars: List<String>,
val sourceJars: List<String>,
)
val goImportPath: String? = "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's nullable, why default is not null?


public data class LibraryItem(
val id: BuildTargetIdentifier,
val dependencies: List<BuildTargetIdentifier>,
val ijars: List<String>,
val jars: List<String>,
val sourceJars: List<String>,
)
val goImportPath: String? = "",
val goRoot: URI? = URI(""),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

public fun goSdkExtensionExists(): Boolean = ep.extensionList.isNotEmpty()

public class GoSdkGetter: GoSdkGetterExtension {
private var goSdks: Set<GoSdk> = emptySet()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump (you can check DefaultConnectionDetailsProviderExtension for an inspiration)

Comment on lines +56 to +57
val goImportPath: String? = "",
val goRoot: URI? = URI(""),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here - it can be null

(!isInsideJar() && getStrictParentOfType<PsiNameIdentifierOwner>()
?.isClassOrMethod() ?: false) || isGoTopLevelFunction()

private fun PsiElement.isGoTopLevelFunction() =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe that u need to create a separate class for go (to register it correctly in plugin.xml) but prob it'd be worth to create a base class and just 2 impls: jvm and go

Comment on lines +19 to +22
if (!goEntitiesExtensionExists()) {
error("Go entities extension does not exist.")
}
val goEntitiesExtension = goEntitiesExtension()!!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be done: goEntitiesExtension ?: error("Go entities extension does not exist.")

@@ -95,6 +96,7 @@ public object WorkspaceModelToModulesMapTransformer {
languageIds = entity.customImlData?.customModuleOptions.orEmpty(),
associates = entity.getKotlinSettings()?.getAssociates().orEmpty(),
)
// TODO: add support for GoModule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump

.asSequence()
.mapNotNull { targetsMap[it] }
.map { it.id.toBsp4JTargetIdentifier() }
.mapNotNull { buildTargetIdentifier -> projectDetails.targets.find { it.id == buildTargetIdentifier } }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'll be slow for big projects, maybe it's better to create an index before

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants