org.jetbrains.kotlin.lexer.KotlinLexerException: Error: could not match input at ''


(Lucian Suhov) #1
  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube: 7.2.1
    Scanner: 2.6.2
    SonarKotlin: 1.0

  • error observed
    When trying to run gradle sonarqube task, I receive the following exception for all Kotlin files:
    WARN: org.jetbrains.kotlin.lexer._JetLexer
    org.jetbrains.kotlin.lexer.KotlinLexerException: Error: could not match input
    at ‘’
    package com.test.showcase.data.rx

import io.reactivex.Scheduler
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import javax.inject.Inject

class RxSchedulersImpl @Inject constructor() : RxSchedulers {

override fun main(): Scheduler = AndroidSchedulers.mainThread()

override fun single(): Scheduler = Schedulers.single()

override fun io(): Scheduler = Schedulers.io()

override fun computation(): Scheduler = Schedulers.computation()

override fun trampoline(): Scheduler = Schedulers.trampoline()

}

at org.jetbrains.kotlin.lexer._JetLexer.zzScanError(_JetLexer.java:814)
at org.jetbrains.kotlin.lexer._JetLexer.advance(_JetLexer.java:1409)
at org.jetbrains.kotlin.com.intellij.lexer.FlexAdapter.locateToken(FlexAdapter.java:110)
at org.jetbrains.kotlin.com.intellij.lexer.FlexAdapter.getTokenType(FlexAdapter.java:69)
at org.jetbrains.kotlin.com.intellij.lang.impl.TokenSequence$Builder.performLexing(TokenSequence.java:71)
at org.jetbrains.kotlin.com.intellij.lang.impl.PsiBuilderImpl.performLexing(PsiBuilderImpl.java:202)
at org.jetbrains.kotlin.com.intellij.lang.impl.PsiBuilderImpl.<init>(PsiBuilderImpl.java:175)
at org.jetbrains.kotlin.com.intellij.lang.impl.PsiBuilderImpl.<init>(PsiBuilderImpl.java:130)
at org.jetbrains.kotlin.com.intellij.lang.impl.PsiBuilderFactoryImpl.createBuilder(PsiBuilderFactoryImpl.java:52)
at org.jetbrains.kotlin.psi.stubs.elements.KtFileElementType.doParseContents(KtFileElementType.java:80)
at org.jetbrains.kotlin.com.intellij.psi.tree.IFileElementType.parseContents(IFileElementType.java:49)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LazyParseableElement.ensureParsed(LazyParseableElement.java:192)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LazyParseableElement.getFirstChildNode(LazyParseableElement.java:240)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LazyParseableElement.getFirstChildNode(LazyParseableElement.java:39)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.RecursiveTreeElementWalkingVisitor$ASTTreeGuide.getFirstChild(RecursiveTreeElementWalkingVisitor.java:47)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.RecursiveTreeElementWalkingVisitor$ASTTreeGuide.getFirstChild(RecursiveTreeElementWalkingVisitor.java:34)
at org.jetbrains.kotlin.com.intellij.util.WalkingState.next(WalkingState.java:73)
at org.jetbrains.kotlin.com.intellij.util.WalkingState.walkChildren(WalkingState.java:61)
at org.jetbrains.kotlin.com.intellij.util.WalkingState.elementStarted(WalkingState.java:52)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.RecursiveTreeElementWalkingVisitor.visitNode(RecursiveTreeElementWalkingVisitor.java:85)
at org.jetbrains.kotlin.com.intellij.psi.impl.GeneratedMarkerVisitor.visitNode(GeneratedMarkerVisitor.java:28)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.RecursiveTreeElementWalkingVisitor.visitComposite(RecursiveTreeElementWalkingVisitor.java:80)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.CompositeElement.acceptTree(CompositeElement.java:133)
at org.jetbrains.kotlin.com.intellij.psi.impl.PsiFileFactoryImpl.markGenerated(PsiFileFactoryImpl.java:228)
at org.jetbrains.kotlin.com.intellij.psi.impl.PsiFileFactoryImpl.trySetupPsiForFile(PsiFileFactoryImpl.java:130)
at org.jetbrains.kotlin.com.intellij.psi.impl.PsiFileFactoryImpl.createFileFromText(PsiFileFactoryImpl.java:88)
at org.jetbrains.kotlin.com.intellij.psi.impl.PsiFileFactoryImpl.createFileFromText(PsiFileFactoryImpl.java:73)
at org.jetbrains.kotlin.com.intellij.psi.impl.PsiFileFactoryImpl.createFileFromText(PsiFileFactoryImpl.java:67)
at org.jetbrains.kotlin.com.intellij.psi.impl.PsiFileFactoryImpl.createFileFromText(PsiFileFactoryImpl.java:61)
at org.jetbrains.kotlin.com.intellij.psi.PsiFileFactory.createFileFromText(PsiFileFactory.java:68)
at org.sonarsource.slang.kotlin.KotlinConverter$KotlinTree.<init>(KotlinConverter.java:114)
at org.sonarsource.slang.kotlin.KotlinConverter.parse(KotlinConverter.java:68)
at org.sonarsource.slang.kotlin.KotlinSensor.analyseFile(KotlinSensor.java:125)
at org.sonarsource.slang.kotlin.KotlinSensor.analyseFiles(KotlinSensor.java:107)
at org.sonarsource.slang.kotlin.KotlinSensor.execute(KotlinSensor.java:88)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:68)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:182)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:312)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:307)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:305)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:281)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:81)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:132)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:111)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy662.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
at org.sonarqube.gradle.SonarQubeTask.run(SonarQubeTask.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:780)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:747)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
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)

Unable to parse file: file:///C:/Proiecte/Luci/Nagarro/AndroidKotlinShowcase/data/src/main/java/com/test/showcase/data/rx/RxSchedulersImpl.kt.
Cannot correctly map AST with a null Document object
:sonarqube:


(Pierre-Yves Nicolas) #2

Hi,

Sorry, I’m not able to reproduce the problem: analysing your project works well on my machine.
I wonder if your problem could be due to file encoding. You didn’t set sonar.sourceEncoding.
Can you please share the logs of the sonarqube gradle task at info level?

Thanks,
Pierre-Yves


(Lucian Suhov) #3

Hi Pierre,

I apologize for the late response. I will try to come back to this issue somewhere this week.

Regards,

Lucian


(Brad Almony) #4

I am having the same issue with my project currently. It is throwing the error for every single kotlin file we have in our project.


(Christophe Zurn) #5

Hello @Lucian_Suhov @derive_brad.almony,

Thank you for your feedbacks.
I was able to reproduce the problem, it is linked to line separators support: files using CR+LF as line break are currently not supported by the lexer.

I have created a ticket here to take care of this.

Cheers,
Christophe


(Brad Almony) #6

I can verify in my project after switching all the line endings to LF from CR+LF everything is working perfectly.
Thank you!