Skip to content

Commit

Permalink
As a reviewee, I want to be able of setting the caret in the proper l…
Browse files Browse the repository at this point in the history
…ine after clicking on a comment (#14)
  • Loading branch information
duxtinto committed Feb 6, 2018
1 parent dd866ca commit bcdb60c
Show file tree
Hide file tree
Showing 44 changed files with 404 additions and 177 deletions.
16 changes: 12 additions & 4 deletions github_code_review.iml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/commonTest/kotlin" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/ideaTest/kotlin" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/uiTest/kotlin" isTestSource="true" />
Expand All @@ -51,6 +52,12 @@
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
<excludeFolder url="file://$MODULE_DIR$/out" />
</content>
<content url="file://$MODULE_DIR$/build/generated/source/kapt/main">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kapt/main" isTestSource="false" generated="true" />
</content>
<content url="file://$MODULE_DIR$/build/generated/source/kaptKotlin/main">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/kaptKotlin/main" isTestSource="false" generated="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.guava:guava:23.6-jre" level="project" />
Expand Down Expand Up @@ -366,17 +373,18 @@
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.plugins:remote-servers-git:2017.3.2" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.plugins:git4idea:2017.3.2" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.plugins:github:2017.3.2" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.assertj:assertj-swing-junit:3.8.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-test-junit:1.2.21" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.junit.platform:junit-platform-console:1.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.junit.jupiter:junit-jupiter-params:5.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.junit.jupiter:junit-jupiter-api:5.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.assertj:assertj-swing-junit:3.8.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.assertj:assertj-swing:3.8.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.assertj:assertj-core:3.9.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jmockit:jmockit:1.38" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.nhaarman.mockitokotlin2:mockito-kotlin:2.0.0-alpha02" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: io.github.benas:random-beans-randomizers:3.7.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: io.github.benas:random-beans:3.7.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-test-junit:1.2.21" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-reflect:1.2.21" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.21" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.google.code.findbugs:jsr305:3.0.2" level="project" />
Expand All @@ -385,12 +393,12 @@
<orderEntry type="library" scope="TEST" name="Gradle: com.google.j2objc:j2objc-annotations:1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: javax.inject:javax.inject:1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.junit.platform:junit-platform-launcher:1.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.junit.platform:junit-platform-engine:1.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.junit.platform:junit-platform-commons:1.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.apiguardian:apiguardian-api:1.0.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.opentest4j:opentest4j:1.0.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.easytesting:fest-reflect:1.4.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-test:1.2.21" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.21" level="project" />
Expand All @@ -400,7 +408,6 @@
<orderEntry type="library" scope="TEST" name="Gradle: io.github.lukehutch:fast-classpath-scanner:2.2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.fasterxml.jackson.core:jackson-databind:2.8.8.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.github.javafaker:javafaker:0.13" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.easytesting:fest-util:1.2.5" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: net.bytebuddy:byte-buddy:1.7.9" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: net.bytebuddy:byte-buddy-agent:1.7.9" level="project" />
Expand All @@ -410,6 +417,7 @@
<orderEntry type="library" scope="TEST" name="Gradle: com.github.mifmif:generex:1.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: dk.brics.automaton:automaton:1.11-8" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains:annotations:13.0" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.junit.vintage:junit-vintage-engine:4.12.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.junit.jupiter:junit-jupiter-engine:5.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: tools" level="project" />
</component>
Expand Down
2 changes: 2 additions & 0 deletions gradle/scripts/dependencies.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ ext {
jsoup : '1.11.2',

// Testing
junit4 : '4.12',
junit : '5.0.3',
junit_platform : '1.0.3',
junit_vintage : '4.12.3',
assertj : '3.9.0',
assertj_swing : '3.8.0',
assertj_guava : '3.1.0',
Expand Down
7 changes: 7 additions & 0 deletions gradle/scripts/intellij.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ patchPluginXml {
sinceBuild 162
untilBuild '181.*'
}

idea {
module {
sourceDirs += files('build/generated/source/kapt/main', 'build/generated/source/kaptKotlin/main')
generatedSourceDirs += files('build/generated/source/kapt/main', 'build/generated/source/kaptKotlin/main')
}
}
5 changes: 4 additions & 1 deletion gradle/scripts/testing.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ sourceSets {
kotlin.srcDirs += [
'src/commonTest/kotlin',
'src/test/kotlin',
'src/uiTest/kotlin'
'src/uiTest/kotlin',
'src/ideaTest/kotlin',
]
}
}
Expand All @@ -16,6 +17,7 @@ dependencies {
)

testCompile(
"junit:junit:${project.versions.junit4}",
"org.junit.platform:junit-platform-console:${project.versions.junit_platform}",
"org.junit.jupiter:junit-jupiter-api:${project.versions.junit}",
"org.junit.jupiter:junit-jupiter-params:${project.versions.junit}",
Expand All @@ -32,6 +34,7 @@ dependencies {

testRuntime(
"org.junit.jupiter:junit-jupiter-engine:${project.versions.junit}",
"org.junit.vintage:junit-vintage-engine:${project.versions.junit_vintage}",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object Fixture {
return CodeReviewFixtureBuilder()
}

internal fun reviewComments(): CodeReviewCommentFixtureBuilder {
internal fun reviewComment(): CodeReviewCommentFixtureBuilder {
return CodeReviewCommentFixtureBuilder()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import io.github.benas.randombeans.api.EnhancedRandom
import io.github.benas.randombeans.registerRandomizersForIdeaClasses
import io.github.benas.randombeans.registerRandomizersForJavaClasses
import io.github.benas.randombeans.registerRandomizersForPluginClasses
import org.jetbrains.debugger.getClassName
import kotlin.reflect.KClass

class RandomGenerator {
companion object {
Expand All @@ -19,10 +17,7 @@ class RandomGenerator {

@JvmStatic
inline fun <reified C> next(): C {
return when {
C::class.isInstance(Long) -> random.nextLong() as C
else -> random.nextObject(C::class.java)
}
return random.nextObject(C::class.java)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class CodeReviewCommentRandomizer : Randomizer<CodeReviewCommentEntity> {
return CodeReviewCommentEntity(
id = RandomGenerator.next(),
reviewId = RandomGenerator.next(),
body = RandomGenerator.next()
body = RandomGenerator.next(),
filePath = RandomGenerator.next(),
lineNumber = RandomGenerator.next()
)
}
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
package com.duxtinto.intellij.plugin.github.codereviews.di.impl.dagger.modules

import com.duxtinto.intellij.plugin.github.codereviews.di.scopes.ProjectScoped
import com.duxtinto.intellij.plugin.github.codereviews.ide.acl.entities.ProjectExt
import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.openapi.wm.impl.ToolWindowImpl
import com.intellij.tasks.TaskManager
import com.intellij.ui.content.ContentManager
import com.duxtinto.intellij.plugin.github.codereviews.di.impl.dagger.modules.idea.*
import dagger.Module
import dagger.Provides
import javax.inject.Named

@Module
class AntiCorruptionLayerModule {
@Provides
@ProjectScoped
fun provideTaskManager(project: ProjectExt): TaskManager {
return project.delegate().getComponent(TaskManager::class.java)
}

@Provides
@ProjectScoped
fun provideToolWindowManager(project: ProjectExt): ToolWindowManager {
return ToolWindowManager.getInstance(project.delegate())
}

@Provides
@ProjectScoped
@Named("GH_Reviews")
fun provideToolWindowImpl(toolWindowManager: ToolWindowManager): ToolWindowImpl {
return toolWindowManager.getToolWindow("GitHub Reviews") as ToolWindowImpl
}

@Provides
@ProjectScoped
@Named("GH_Reviews")
fun provideContentManager(@Named("GH_Reviews") toolWindow: ToolWindowImpl): ContentManager {
return toolWindow.contentManager
}
}
@Module(includes = [
IdeaTaskModule::class,
IdeaToolWindowModule::class,
IdeaUiContentModule::class,
IdeaFileAndDocumentModule::class,
IdeaGitModule::class
])
class AntiCorruptionLayerModule
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AuthModule {
fun provideGithubAuthDataHolder(project: ProjectExt, progressIndicator: ProgressIndicator): GithubAuthDataHolder {
try {
// TODO: because of the exception handling here, it 'smells' to me that hidden inside a module is not the place for this call
return GithubUtil.getValidAuthDataHolderFromConfig(project.delegate(), AuthLevel.LOGGED, progressIndicator)
return GithubUtil.getValidAuthDataHolderFromConfig(project, AuthLevel.LOGGED, progressIndicator)
} catch (e: IOException) {
e.printStackTrace()
throw RuntimeException(e)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.duxtinto.intellij.plugin.github.codereviews.di.impl.dagger.modules

import com.duxtinto.intellij.plugin.github.codereviews.di.scopes.ProjectScoped
import com.duxtinto.intellij.plugin.github.codereviews.domain.DomainContract
import com.duxtinto.intellij.plugin.github.codereviews.ide.acl.services.editor.IdeaEditorDriver
import dagger.Binds
import dagger.Module

@Module
abstract class EditorModule {
@Binds
@ProjectScoped
abstract fun provideEditorDriver(switcher: IdeaEditorDriver): DomainContract.EditorDriver
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import javax.inject.Named
PullRequestModule::class,
CodeReviewModule::class,
IssueModule::class,
ToolWindowModule::class
ToolWindowModule::class,
EditorModule::class
])
class ProjectModule(private val project: ProjectExt) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package com.duxtinto.intellij.plugin.github.codereviews.di.impl.dagger.modules

import com.duxtinto.intellij.plugin.github.codereviews.di.scopes.ProjectScoped
import com.duxtinto.intellij.plugin.github.codereviews.domain.repositories.RepositoriesDomainContract
import com.duxtinto.intellij.plugin.github.codereviews.events.repos.GitChangeListener
import com.duxtinto.intellij.plugin.github.codereviews.ide.acl.services.GitRepositoryFinderImpl
import com.duxtinto.intellij.plugin.github.codereviews.ide.acl.services.GithubRepositoryFinderImpl
import com.intellij.dvcs.repo.VcsRepositoryMappingListener
import dagger.Binds
import dagger.Module

Expand All @@ -18,8 +16,4 @@ abstract class ReposModule {
@Binds
@ProjectScoped
abstract fun provideGithubRepositoryFinder(githubRepositoryFinder: GithubRepositoryFinderImpl): RepositoriesDomainContract.GithubRepositoryFinder

@Binds
@ProjectScoped
abstract fun provideVcsRepositoryMappingListener(changeListener: GitChangeListener): VcsRepositoryMappingListener
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package com.duxtinto.intellij.plugin.github.codereviews.di.impl.dagger.modules

import com.duxtinto.intellij.plugin.github.codereviews.di.scopes.ProjectScoped
import com.duxtinto.intellij.plugin.github.codereviews.domain.pullrequests.reviews.comments.ActionOnReviewCommentInteractor
import com.duxtinto.intellij.plugin.github.codereviews.domain.pullrequests.reviews.comments.CommentsByReviewInteractor
import com.duxtinto.intellij.plugin.github.codereviews.domain.pullrequests.reviews.comments.GetAllCommentsForInteractor
import com.duxtinto.intellij.plugin.github.codereviews.domain.pullrequests.reviews.comments.GoToCommentLineInteractor
import dagger.Binds
import dagger.Module
import javax.inject.Named

@Module
abstract class ReviewCommentModule {
@Binds
@ProjectScoped
abstract fun provideCommentsByReviewInteractor(review: GetAllCommentsForInteractor): CommentsByReviewInteractor
abstract fun provideCommentsByReviewInteractor(interactor: GetAllCommentsForInteractor): CommentsByReviewInteractor

@Binds
@ProjectScoped
@Named("goToLine")
abstract fun provideGoToCommentLineInteractor(interactor: GoToCommentLineInteractor): ActionOnReviewCommentInteractor
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.duxtinto.intellij.plugin.github.codereviews.di.impl.dagger.modules.idea

import dagger.Module

@Module
class IdeaFileAndDocumentModule
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.duxtinto.intellij.plugin.github.codereviews.di.impl.dagger.modules.idea

import com.duxtinto.intellij.plugin.github.codereviews.di.scopes.ProjectScoped
import com.duxtinto.intellij.plugin.github.codereviews.domain.pullrequests.GetAllOpenForRepoInteractor
import com.duxtinto.intellij.plugin.github.codereviews.domain.repositories.FindGithubRepoForRootFolderInteractor
import com.duxtinto.intellij.plugin.github.codereviews.ide.acl.entities.ProjectExt
import com.duxtinto.intellij.plugin.github.codereviews.ide.acl.events.repositories.GitChangeListener
import com.duxtinto.intellij.plugin.github.codereviews.ui.toolwindow.pullrequestlist.PullRequestList
import com.intellij.dvcs.repo.VcsRepositoryMappingListener
import dagger.Module
import dagger.Provides
import git4idea.repo.GitRepositoryManager

@Module
class IdeaGitModule {
@Provides
@ProjectScoped
fun provideVcsRepositoryMappingListener(
repoFinder: FindGithubRepoForRootFolderInteractor,
prFetcher: GetAllOpenForRepoInteractor,
prPresenter: PullRequestList.Presenter): VcsRepositoryMappingListener {
return GitChangeListener(repoFinder, prFetcher, prPresenter)
}

@Provides
@ProjectScoped
fun provideGitRepositoryManager(project: ProjectExt): GitRepositoryManager {
return GitRepositoryManager.getInstance(project)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.duxtinto.intellij.plugin.github.codereviews.di.impl.dagger.modules.idea

import com.duxtinto.intellij.plugin.github.codereviews.di.scopes.ProjectScoped
import com.duxtinto.intellij.plugin.github.codereviews.ide.acl.entities.ProjectExt
import com.intellij.tasks.TaskManager
import dagger.Module
import dagger.Provides

@Module
class IdeaTaskModule {
@Provides
@ProjectScoped
fun provideTaskManager(project: ProjectExt): TaskManager {
return project.getComponent(TaskManager::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.duxtinto.intellij.plugin.github.codereviews.di.impl.dagger.modules.idea

import com.duxtinto.intellij.plugin.github.codereviews.di.scopes.ProjectScoped
import com.duxtinto.intellij.plugin.github.codereviews.ide.acl.entities.ProjectExt
import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.openapi.wm.impl.ToolWindowImpl
import dagger.Module
import dagger.Provides
import javax.inject.Named

@Module
class IdeaToolWindowModule {
@Provides
@ProjectScoped
fun provideToolWindowManager(project: ProjectExt): ToolWindowManager {
return ToolWindowManager.getInstance(project)
}

@Provides
@ProjectScoped
@Named("GH_Reviews")
fun provideToolWindowImpl(toolWindowManager: ToolWindowManager): ToolWindowImpl {
return toolWindowManager.getToolWindow("GitHub Reviews") as ToolWindowImpl
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.duxtinto.intellij.plugin.github.codereviews.di.impl.dagger.modules.idea

import com.duxtinto.intellij.plugin.github.codereviews.di.scopes.ProjectScoped
import com.intellij.openapi.wm.impl.ToolWindowImpl
import com.intellij.ui.content.ContentManager
import dagger.Module
import dagger.Provides
import javax.inject.Named

@Module
class IdeaUiContentModule {
@Provides
@ProjectScoped
@Named("GH_Reviews")
fun provideContentManager(@Named("GH_Reviews") toolWindow: ToolWindowImpl): ContentManager {
return toolWindow.contentManager
}
}
Loading

0 comments on commit bcdb60c

Please sign in to comment.