Skip to content

Commit

Permalink
Merges arrow-meta-prototype (#1606)
Browse files Browse the repository at this point in the history
* first commit

* First sample

* Add resources to README.MD

* Sample check for purity that illustrate the ClassBuilder phase

* Update README.md

* Update README.md

* added intro info's about IR

* removed unness. parts in IR

* removed unness. parts in IR

* added further resources on IR

* walk function subexpressions and check for purity

* fix compiler addition

* WIP

* finding all callable expressions and type checking them against purity

* Add Jetpack Compose to list of plugin examples

* Update README.md

* Add note on Google having forked Kotlin and not having public sources

* evaluating order of compiler phases based and extensions delegation

* Add extensions invocation order

* Meta DSL progress

* Subscribing to newMethod, newField and newAnnotation on class builder generation

* Update README.md

* more progress

* remove .DS_STORE from git

* progress checkpoint

* progress checkpoint

* progress checkpoint

* progress checkpoint

* Mutate the compiler context with main services discovered in earlier analysis phase

* moar progress

* small cleanup before sharing with JB

* clean up

* clean up

* Clean up

* Clean up

* toward automatic type alias generation

* automatic type alias generation

* update kotlin version and more progress attempting to intercept calls and type resolution

* get a sample of gradle and idea plugin compiling

* minor improvements and fixes

* BOOM! implicit kinded conversions work!

* clean up

* clean up

* merge Adrians work

* Finding datatype, type class and instance based on @extension

* progress prototyping type class resolution

* Port of the most interesting parts of KEEP 87 over to the compiler plugin

* enable the ExtensionResolutionCallChecker

* Progress on the callchecker resolution

* reflection utilities to intercept compiler services

* Functions can now resolve `@with` arguments in their lexical scope

* Suppress `NO_VALUE_FOR_PARAMETER` when an extension is properly resolved.

* Ability to suppress any diagnostic given a CallCheckerContext

```kotlin
fun CallCheckerContext.suppressDiagnostic(f: (Diagnostic) -> Boolean): Unit
```

* approach to match and unapply tree based on code snippets

* quasiquote DSL progress

* intercepting class generation with quotes, only matching on name for now

* Initial Draft of the Higher Kind plugin based on quotes

* Added modality in visibility

* remove bogus import

* move trim margins up to processing

* support for kinds of N arity up to 22

* rename type parameters identifier

* class matching DSL cleanup and simplification of the model for codegen

* injection prototype working with type class package instances

* auto insert with scopes

* Support for `fun`, `val`, `object` and `class` providers of type class extensions

* utils clean up

* findExtension cleanup

* IR transformations as meta functions

* IR transformations as meta functions

* Error reporting for ambiguous extensions

* `with` injection supported in class members

* clean up and more todos

* support for internal orphan extensions

* progress with comprehensions rewrites

* progress with comprehensions rewrites

* extracting flatMap calls from bindings presence

* binding comprehensions as tree rewrites, working but lacking type checking

* failing comprehensions rewrite example due to binding variables and order

* failing comprehensions rewrite example due to binding variables and order

* clean up

* clean up

* First steps into Idea support (#21)

* some tries

* gradle is the right one

* revert to regular jar

* init

* init

* autofold plugin with innerSealedSubclass

* stash invest.

* improvements in autofold

* formating cleanUp

* fix gradle plugin

* merged with rr-typeclass

* cleanUp

* working HKplugin & Autofold init

* safe

* Move to kotlin-compiler package

This change updates the compiler plugin to use the unshaded
`kotlin-compiler` package instead of the `kotlin-compiler-embeddable`
package, as to prevent it from clashing in IntelliJ.

* added autofold plugin

* working runIde task

* added report message

* added license and fixed comments

* cleanUp

* Revert "First steps into Idea support (#21)" (#23)

This reverts commit 83ca625.

* clean Up (#26)

* fix type class resolution and plugin publishing, still need to autoinject compiler free args

* gradle plugin jar cleanUp & fix (#27)

* .

* 1 try

* further fix

* further fix

* progress with IDEA discovery shadowing and running the plugin in IDEA. Analysys not yet working

* synth resolution progress

* synth resolution progress on file save

* synthetic methods and names working!

* more synthetic resolver methods

* getSyntheticNestedClassNames

* synthetic package fragment provider

* automatic synth resolution working based on local build output

* progress on type class resolution on the IDE

* IDE body resolution accounting type class injected symbols

* Initialize IDE component registration earlier

* Merge master and some debug output for next iteration

* package organization

* package organization (:compiler-plugin)

* remove core and consumer modules

* idea reorg

* Update README.md

* Moving arrow-meta-prototype into its own subdirectory

* Moves arrow-meta-prototype into the proper subdirectory
  • Loading branch information
juanpedromoreno authored and raulraja committed Sep 18, 2019
1 parent 38147dc commit c1464c7
Show file tree
Hide file tree
Showing 75 changed files with 5,359 additions and 0 deletions.
134 changes: 134 additions & 0 deletions modules/meta/arrow-meta-prototype/.gitignore
@@ -0,0 +1,134 @@
# Created by https://www.gitignore.io/api/android,intellij

### Android ###
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# dokka + ank apidocs merge to sources
apidocs/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/libraries
.idea/markdown-navigator
.idea/

# Keystore files
*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

### Android Patch ###
gen-external-apklibs

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Jekyll
_site
.sass-cache

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

######################

reports/

# End of https://www.gitignore.io/api/android,intellij
/.idea/misc.xml

.DS_Store

target/

.bash_profile
7 changes: 7 additions & 0 deletions modules/meta/arrow-meta-prototype/README.md
@@ -0,0 +1,7 @@
# arrow-meta-prototype

**Build and run in the IDE**

```
./gradlew clean gradle-plugin:publishArrowPluginMarkerMavenPublicationToMavenLocal gradle-plugin:publishPluginMavenPublicationToMavenLocal idea-plugin:runIde -Dorg.gradle.debug=true -Dkotlin.compiler.execution.strategy="in-process"
```
21 changes: 21 additions & 0 deletions modules/meta/arrow-meta-prototype/build.gradle
@@ -0,0 +1,21 @@
buildscript {
ext.kotlin_version = '1.3.50'

repositories {
mavenCentral()
}
}

plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.50'
id 'org.jetbrains.kotlin.kapt' version '1.3.50'
id 'com.github.johnrengelman.shadow' version '5.0.0'
}

allprojects {
repositories {
maven { url "https://kotlin.bintray.com/kotlinx" }
mavenCentral()
jcenter()
}
}
132 changes: 132 additions & 0 deletions modules/meta/arrow-meta-prototype/compiler-plugin/build.gradle
@@ -0,0 +1,132 @@
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.github.johnrengelman.shadow'


//compileKotlin.kotlinOptions.freeCompilerArgs = ['-Xskip-runtime-version-check', 'true']

dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compileOnly "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
compileOnly "com.intellij:openapi:7.0.3"
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
jar {
manifest {
attributes["Specification-Title"] = project.name
attributes["Specification-Version"] = project.version
attributes["Implementation-Title"] = "arrow.meta.plugin.compiler"
attributes["Implementation-Version"] = project.version
}
}

shadowJar {
configurations = [project.configurations.compile]
relocate 'org.jetbrains.kotlin.com.intellij', 'com.intellij'
//relocate 'org.jetbrains.kotlin.load', 'kotlin.reflect.jvm.internal.impl.load'
}
//
//com.intellij.findUsagesHandlerFactory
//org.jetbrains.kotlin.scriptDefinitionsProvider
//com.intellij.runConfigurationTemplateProvider
//com.intellij.compiler.task
//org.jetbrains.kotlin.syntheticResolveExtension
//com.intellij.handleTypeFactory
//org.jetbrains.kotlin.expressionCodegenExtension
//org.jetbrains.kotlin.gradleProjectImportHandler
//com.intellij.projectExtension
//com.intellij.java.elementFinder
//org.jetbrains.kotlin.extraImportsProviderExtension
//com.intellij.compilerFactory
//com.intellij.fileContextProvider
//com.intellij.vcs
//org.jetbrains.kotlin.scriptDefinitionContributor
//com.intellij.prePushHandler
//com.intellij.projectViewNodeDecorator
//org.jetbrains.kotlin.classBuilderFactoryInterceptorExtension
//org.jetbrains.kotlin.scriptAdditionalIdeaDependenciesProvider
//org.jetbrains.kotlin.irGenerationExtension
//com.intellij.nonProjectFileWritingAccessExtension
//org.jetbrains.kotlin.jsSyntheticTranslateExtension
//com.intellij.changesViewContent
//com.intellij.vcsRepositoryCreator
//com.intellij.highlightErrorFilter
//com.intellij.projectViewPane
//com.intellij.hectorComponentProvider
//com.intellij.cachedValuesFactory
//com.intellij.vcs.baseContentProvider
//com.intellij.analyzeStacktraceFilter
//org.jetbrains.kotlin.mavenProjectImportHandler
//com.intellij.stepsBeforeRunProvider
//com.intellij.previewPanelProvider
//com.intellij.vcsIgnoreChecker
//com.intellij.checkinHandlerFactory
//com.intellij.compiler.inspectionValidator
//com.intellij.java-i18n.resourceBundleManager
//com.intellij.openapi.extensions.epAvailabilityListener
//com.intellij.editorNotificationProvider
//com.intellij.ignoredFileContentProvider
//com.intellij.highlightVisitor
//org.jetbrains.kotlin.androidDexer
//com.intellij.java.shortNamesCache
//com.intellij.logHighlighterFactory
//com.intellij.vcs.ignoredFilesHolder
//com.intellij.debugger.positionManagerFactory
//com.intellij.paletteItemProvider
//com.intellij.jvm.elementProvider
//com.intellij.favoriteNodeProvider
//org.jetbrains.android.uipreview.viewLoaderExtension
//org.jetbrains.kotlin.declarationAttributeAltererExtension
//com.intellij.vcs.taskHandler
//com.intellij.ideRootPaneNorth
//com.intellij.writingAccessProvider
//com.intellij.logProvider
//com.intellij.scopeTreeExpander
//com.intellij.coverageOptions
//com.intellij.lang.inferredAnnotationProvider
//com.intellij.java.compiler
//com.intellij.directoryIndexExcludePolicy
//org.jetbrains.kotlin.packageFragmentProviderExtension
//com.intellij.runConfigurationsSettings
//com.intellij.selectInTarget
//com.intellij.customScopesProvider
//org.jetbrains.kotlin.scriptTemplatesProvider
//com.intellij.fileBreadcrumbsCollector
//com.intellij.vcs.fileStatusProvider
//com.intellij.vcs.changes.changesViewModifier
//com.intellij.customFileDropHandler
//org.jetbrains.kotlin.kotlinIndicesHelperExtension
//com.intellij.javadocTagInfo
//com.intellij.problemFileHighlightFilter
//com.intellij.patch.extension
//com.intellij.streamProviderFactory
//com.intellij.multiHostInjector
//com.intellij.treeStructureProvider
//com.intellij.projectModelModifier
//com.intellij.psi.treeChangePreprocessor
//com.intellij.projectUndoProvider
//com.intellij.cherryPicker
//com.intellij.compiler
//com.intellij.autoImportOptionsProvider
//com.intellij.buildProcess.parametersProvider
//com.intellij.editChangelistSupport
//com.intellij.favoritesListProvider
//com.intellij.pushSupport
//com.intellij.roots.watchedRootsProvider
//com.intellij.compilerSettingsFactory
//org.jetbrains.kotlin.simpleNameReferenceExtension
//com.intellij.vcsChangesViewRefresher
//com.intellij.vcs.branchStateProvider
//org.jetbrains.kotlin.storageComponentContainerContributor
//com.intellij.refactoring.elementListenerProvider
//com.intellij.usageContextPanelProvider
//com.intellij.projectConfigurable
//org.jetbrains.kotlin.syntheticScopeProviderExtension
//com.android.project.projectsystem
@@ -0,0 +1,13 @@
package arrow.meta

import org.jetbrains.kotlin.compiler.plugin.CliOption
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor

//@AutoService(CommandLineProcessor::class)
class MetaCliProcessor : CommandLineProcessor {

override val pluginId: String = "arrow.meta.plugin.compiler"

override val pluginOptions: Collection<CliOption> = emptyList()

}
@@ -0,0 +1,12 @@
package arrow.meta

import org.jetbrains.kotlin.compiler.plugin.CliOption
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor

class MetaCommandLineProcessor : CommandLineProcessor {

override val pluginId: String = "arrow.meta.plugin.compiler"

override val pluginOptions: Collection<CliOption> = emptyList()

}
@@ -0,0 +1,18 @@
package arrow.meta

import arrow.meta.dsl.MetaPluginSyntax
import arrow.meta.internal.registry.InternalRegistry
import arrow.meta.phases.ExtensionPhase
import org.jetbrains.kotlin.com.intellij.mock.MockProject
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.name.Name

interface MetaComponentRegistrar : ComponentRegistrar, MetaPluginSyntax, InternalRegistry {

override fun intercept(): List<Pair<Name, List<ExtensionPhase>>>

override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) =
super.registerProjectComponents(project, configuration)

}
@@ -0,0 +1,11 @@
package arrow.meta

import arrow.meta.phases.ExtensionPhase
import arrow.meta.plugins.higherkind.higherKindedTypes
import arrow.meta.plugins.typeclasses.typeClasses
import org.jetbrains.kotlin.name.Name

open class MetaPlugin : MetaComponentRegistrar {
override fun intercept(): List<Pair<Name, List<ExtensionPhase>>> =
listOf(higherKindedTypes, typeClasses) //, higherKindedTypes, typeClasses, comprehensions)
}
@@ -0,0 +1,14 @@
package arrow.meta.dsl

import arrow.meta.dsl.analysis.AnalysisSyntax
import arrow.meta.dsl.codegen.CodegenSyntax
import arrow.meta.dsl.config.ConfigSyntax
import arrow.meta.dsl.resolve.ResolveSyntax
import arrow.meta.phases.ExtensionPhase

interface MetaPluginSyntax : ConfigSyntax, AnalysisSyntax, ResolveSyntax, CodegenSyntax {

fun meta(vararg phases: ExtensionPhase): List<ExtensionPhase> =
phases.toList()

}

0 comments on commit c1464c7

Please sign in to comment.