Comments (14)
I was experiencing this issue along with #51 in my Android project using Gradle.
I managed to fix this by changing the Kotlin dependency in my build.gradle
from
compile {
implementation "org.jetbrains.kotlin-stdlib-jdk7:$kotlin-version"
}
to
compile {
implementation "org.jetbrain.kotlin-stdlib:$koltin-version"
}
After changing that line and cleaning/re-building the project both primitive types and global collection initializers started getting recognised by the language server. My project seemed to compile and work properly regardless of the change. While this doesn't properly fix the issue, it might be a viable temporary solution.
Hope this helps. :)
from kotlin-language-server.
That's unfortunate. I will let you know if I find anything.
from kotlin-language-server.
@tripl3dogdare Do you use Maven or Gradle as your project model?
from kotlin-language-server.
I use Gradle. No Kotlin DSL if that matters.
from kotlin-language-server.
@tripl3dogdare Could you post the output log from the language server?
from kotlin-language-server.
@fwcd Here you go =)
[INFO] main main Connected to client
[INFO] client main Adding workspace file:///c%3A/Users/Connor/Documents/Main/Projects/2%20-%20Languages/serval to source path
[INFO] client main Adding 7 files under c:\Users\Connor\Documents\Main\Projects\2 - Languages\serval to source path
[INFO] client main Searching for dependencies in workspace root c:\Users\Connor\Documents\Main\Projects\2 - Languages\serval
[INFO] client main Attempting dependency resolution through CLI...
[INFO] client main Creating temporary gradle file C:\Users\Connor\AppData\Local\Temp\classpath769559254831354550.gradle
[INFO] client main Successfully resolved dependencies using Gradle dependencies CLI
[INFO] client main Adding 6 files to class path
[INFO] client main DidChangeConfigurationParams [
settings = {"kotlin":{}}
]
[INFO] debounce0 main Linting .../serval/Builtins.kt
[INFO] async0 main Find symbols in TextDocumentIdentifier [
uri = "file:///c%3A/Users/Connor/Documents/Main/Projects/2%20-%20Languages/serval/src/main/com/tripl3dogdare/serval/Interpreter.kt"
]
[INFO] async0 main Finished in 836 ms
[INFO] debounce0 main Reported 5 diagnostics in Builtins.kt
[INFO] debounce0 main Linting .../serval/Interpreter.kt
[INFO] debounce0 main Reported 18 diagnostics in Interpreter.kt
[INFO] debounce0 main Reported 5 diagnostics in Builtins.kt
[INFO] debounce0 main Ignore 4 diagnostics in Parser.kt because it's not open
[INFO] debounce0 main Ignore 2 diagnostics in Utils.kt because it's not open
from kotlin-language-server.
@tripl3dogdare Hmm, the log looks pretty normal.
You could clone https://github.com/fwcd/KotlinQuickStart and check whether mapOf
and listOf
are correctly recognized there. Also, the language server might have an issue with your source files being placed in src/main/kotlin
instead of src/main
(though that should not be the cause).
from kotlin-language-server.
@fwcd On further investigation, I've noticed some errors popping at at various points, though I'm not sure if they're relevant:
[Error - 3:33:21 PM] Request textDocument/hover failed.
Message: Internal error.
Code: -32603
java.util.concurrent.CompletionException: org.javacs.kt.util.KotlinLSException: Error while analyzing: class Quote(inner:ASTNode.Quote, val closure:Scope) : Value<ASTNode.Quote>(inner)
at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273)
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1592)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.javacs.kt.util.KotlinLSException: Error while analyzing: class Quote(inner:ASTNode.Quote, val closure:Scope) : Value<ASTNode.Quote>(inner)
at org.javacs.kt.Compiler.compileExpression(Compiler.kt:157)
at org.javacs.kt.CompiledFile.bindingContextOf(CompiledFile.kt:39)
at org.javacs.kt.CompiledFile.referenceAtPoint(CompiledFile.kt:53)
at org.javacs.kt.hover.HoversKt.hoverAt(hovers.kt:37)
at org.javacs.kt.KotlinTextDocumentService$hover$1.invoke(KotlinTextDocumentService.kt:66)
at org.javacs.kt.KotlinTextDocumentService$hover$1.invoke(KotlinTextDocumentService.kt:26)
at org.javacs.kt.util.AsyncExecutorKt$sam$java_util_function_Supplier$0.get(AsyncExecutor.kt)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
... 3 more
Caused by: org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression at (1,527) in /dummy.kt
at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.logOrThrowException(ExpressionTypingVisitorDispatcher.java:240)
at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.lambda$getTypeInfo$0(ExpressionTypingVisitorDispatcher.java:211)
at org.jetbrains.kotlin.util.PerformanceCounter.time(PerformanceCounter.kt:91)
at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:161)
at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:145)
at org.jetbrains.kotlin.types.expressions.ExpressionTypingServices.getTypeInfo(ExpressionTypingServices.java:114)
at org.jetbrains.kotlin.types.expressions.ExpressionTypingServices.getTypeInfo(ExpressionTypingServices.java:93)
at org.javacs.kt.Compiler.compileExpression(Compiler.kt:148)
... 10 more
Caused by: java.lang.UnsupportedOperationException: Should not be called
at org.jetbrains.kotlin.resolve.lazy.NoTopLevelDescriptorProvider.shouldNotBeCalled(TopLevelDescriptorProvider.kt:36)
at org.jetbrains.kotlin.resolve.lazy.NoTopLevelDescriptorProvider.getPackageFragment(TopLevelDescriptorProvider.kt:39)
at org.jetbrains.kotlin.resolve.DeclarationResolver.getTopLevelDescriptorsByFqName(DeclarationResolver.kt:107)
at org.jetbrains.kotlin.resolve.DeclarationResolver.checkRedeclarationsInPackages(DeclarationResolver.kt:86)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations(LazyTopDownAnalyzer.kt:214)
at org.jetbrains.kotlin.types.expressions.LocalClassifierAnalyzer.processClassOrObject(LocalClassifierAnalyzer.kt:106)
at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorForStatements.visitClass(ExpressionTypingVisitorForStatements.java:161)
at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorForStatements.visitClass(ExpressionTypingVisitorForStatements.java:62)
at org.jetbrains.kotlin.psi.KtClass.accept(KtClass.kt:34)
at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.lambda$getTypeInfo$0(ExpressionTypingVisitorDispatcher.java:172)
... 16 more
Here are the relevant declarations:
// Parser.kt
object Parser { // Redeclaration: Parser (not sure why)
sealed class ASTNode<T>(val value:T, val tokens:Tokens) {
// ...
class Quote(value:ASTNodes, tokens:Tokens) : ASTNode<ASTNodes>(value, tokens) {...}
// ...
}
// ...
}
internal typealias Tokens = List<Lexer.Token>
internal typealias ASTNodes = List<Parser.ASTNode<*>>
// Interpreter.kt
class Interpreter {
sealed class Value<T>(val inner:T) {
// ...
class Quote(inner:ASTNode.Quote, val closure:Scope) : Value<ASTNode.Quote>(inner)
// ...
}
// ...
}
internal typealias Scope = Map<String, UUID>
And my build.gradle
file for good measure:
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.2.60-eap-44'
}
group 'com.tripl3dogdare'
version '0.1-ALPHA'
repositories {
maven { url 'http://dl.bintray.com/kotlin/kotlin-eap' }
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
compile "org.jetbrains.kotlin:kotlin-reflect"
}
compileKotlin { kotlinOptions.jvmTarget = "1.8" }
compileTestKotlin { kotlinOptions.jvmTarget = "1.8" }
I tested with the project you linked, and it seemed to work fine. I also tested porting over some potentially relevant pieces of build.gradle
, but that didn't seem to change anything.
from kotlin-language-server.
Don't want to be a bother, but I'm curious if there's been any progress on this or if you have any insights on what might be causing it - I'd love to start trying out Kotlin in VSCode, since I enjoy the editor experience overall much more than IDEA, but with this in the way there's not much I can do.
from kotlin-language-server.
@tripl3dogdare I totally agree, having a lightweight alternative to IDEA that provides great Kotlin support for a variety of editors is the main goal of this project.
Unfortunately, I do not have enough free time to actively develop this project, which means I can only sporadically provide fixes. Furthermore, the Kotlin compiler APIs that power this language server are heavily undocumented, which slows down progress a lot. If you are interested in contributing, I will gladly accept PRs though.
Regarding this issue, could you provide a small repo that reproduces this bug (at least on your machine)?
from kotlin-language-server.
Apologies for the delay, I recently had my wisdom teeth removed and have been unable to work effectively for a while.
My HavenJSON project seems to replicate the issue, even after cloning it fresh from the repo, which doesn't include any of the IDEA project information, leading me to believe there is some issue with my Gradle configuration in this area. Feel free to take a dig around if you'd like and see if anything helps with the issue =)
from kotlin-language-server.
I've had an issue with the Gradle wrapper in HavenJSON, maybe this is the problem:
Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-4.4-all.zip'.
org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-4.4-all.zip'.
at org.gradle.tooling.internal.consumer.DistributionFactory$ZippedDistribution.getToolingImplementationClasspath(DistributionFactory.java:137)
at org.gradle.tooling.internal.consumer.loader.CachingToolingImplementationLoader.create(CachingToolingImplementationLoader.java:40)
at org.gradle.tooling.internal.consumer.loader.SynchronizedToolingImplementationLoader.create(SynchronizedToolingImplementationLoader.java:43)
at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.onStartAction(LazyConsumerActionExecutor.java:101)
at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:83)
at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45)
at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38)
at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
at org.gradle.tooling.internal.consumer.DefaultModelBuilder.get(DefaultModelBuilder.java:50)
at org.gradle.tooling.internal.consumer.DefaultProjectConnection.getModel(DefaultProjectConnection.java:41)
at org.eclipse.buildship.core.workspace.internal.ConnectionAwareLauncherProxy.newModelBuilder(ConnectionAwareLauncherProxy.java:64)
at org.eclipse.buildship.core.workspace.internal.DefaultModelProvider.fetchModel(DefaultModelProvider.java:68)
at org.eclipse.buildship.core.workspace.internal.DefaultModelProvider.supportsCompositeBuilds(DefaultModelProvider.java:165)
at org.eclipse.buildship.core.workspace.internal.DefaultModelProvider.fetchModels(DefaultModelProvider.java:75)
at org.eclipse.buildship.core.workspace.internal.DefaultModelProvider.fetchEclipseGradleProjects(DefaultModelProvider.java:99)
at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.startSynchronization(GradleProjectImporter.java:152)
at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.importDir(GradleProjectImporter.java:99)
at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.lambda$0(GradleProjectImporter.java:91)
at java.util.ArrayList.forEach(ArrayList.java:1249)
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080)
at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.importToWorkspace(GradleProjectImporter.java:91)
at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.importProjects(ProjectsManager.java:134)
at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.access$1(ProjectsManager.java:128)
at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager$2.run(ProjectsManager.java:122)
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:41)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:736)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2295)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2322)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5749)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5706)
at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:114)
at org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:221)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:42)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
from kotlin-language-server.
Well, I looked around for a solution to that issue, and most things suggested clearing my Gradle cache for that particular version; that doesn't seem to have had any effect, though, and I don't see that same error anywhere on my end. Not sure where to go from here.
EDIT: I've tried updating the Gradle wrapper wholesale, no dice there either.
from kotlin-language-server.
@alxndrv That actually fixed it! Thanks for the help =)
from kotlin-language-server.
Related Issues (20)
- Extend "Add missing import" code action to suggest "static methods"/functions
- C interoperability support? HOT 3
- Crash on windows
- Automatically generate "thank you" message for all contributors in release script
- Dependency module <dependencies of main> was not initialized by the time contents of dependent module <dependencies of main> were queried HOT 1
- Add code completion for labels
- JsonSyntaxException on startup HOT 7
- Re-add semantic tokens for string literals without covering up interpolations
- Support java 21 HOT 1
- Despite best efforts a sea of red in vscode: MISSING_BUILT_IN_DECLARATION HOT 1
- language server won`t start after update gradle from 8.5 to 8.6 HOT 2
- Neovim + Android + Mason: Unresolved references for certain android dependencies
- Support for multi-module project HOT 4
- Extension fails on Ubuntu devcontainer - couldn't create connection to server. HOT 3
- java.util.concurrent.TimeoutException: Unable to connect language server
- Feature - disable extension on per-file basis to mitigate `Unresolved reference:` errors HOT 2
- Suppress a warning around SLF4J HOT 3
- Too many error messages and exceptions. HOT 1
- bug: Rename variable fails
- LSP causes configuration caching to fail
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotlin-language-server.