Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[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 <85940359+maclick@users.noreply.github.com>
# 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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants