Skip to content

Commit

Permalink
Merge branch '2020.3' into 2021.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DenWav committed May 9, 2021
2 parents 3192ec3 + 697548d commit 29bd07b
Show file tree
Hide file tree
Showing 50 changed files with 962 additions and 263 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: PR Validation
on:
pull_request:
branches: ['*']

jobs:
validation:
name: Validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: gradle/wrapper-validation-action@v1
- name: Setup publish token
env:
JETBRAINS_TOKEN: ${{ secrets.JETBRAINS_TOKEN }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('gradle.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: gradle/wrapper-validation-action@v1
- run: ./gradlew build --no-daemon --stacktrace
65 changes: 36 additions & 29 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ plugins {
mcdev
groovy
idea
id("org.jetbrains.intellij") version "0.7.2"
id("org.cadixdev.licenser") version "0.5.1"
id("org.jetbrains.intellij") version "0.7.3"
id("org.cadixdev.licenser") version "0.6.0"
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
}

Expand Down Expand Up @@ -71,31 +71,28 @@ dependencies {
// Kotlin
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect"))
val coroutineVersion = "1.4.3"
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:$coroutineVersion")
implementation(libs.bundles.coroutines)

implementation(files(gradleToolingExtensionJar))

implementation("com.extracraftx.minecraft:TemplateMakerFabric:0.3.0")
implementation(libs.templateMakerFabric)

jflex("org.jetbrains.idea:jflex:1.7.0-b7f882a")
jflexSkeleton("org.jetbrains.idea:jflex:1.7.0-c1fdf11:idea@skeleton")
grammarKit("org.jetbrains.idea:grammar-kit:1.5.1")
jflex(libs.jflex.lib)
jflexSkeleton("${libs.jflex.skeleton.text()}:idea@skeleton")
grammarKit(libs.grammarKit)

testLibs("org.jetbrains.idea:mockJDK:1.7-4d76c50")
testLibs("org.spongepowered:mixin:0.7-SNAPSHOT")
testLibs("org.spongepowered:spongeapi:7.0.0:shaded")
testLibs("com.demonwav.mcdev:all-types-nbt:1.0@nbt")
testLibs(libs.test.mockJdk)
testLibs(libs.test.mixin)
testLibs("${libs.test.spongeapi.text()}:shaded")
testLibs("${libs.test.nbt.text()}@nbt")

// For non-SNAPSHOT versions (unless Jetbrains fixes this...) find the version with:
// afterEvaluate { println(intellij.ideaDependency.buildNumber.substring(intellij.type.length + 1)) }
gradleToolingExtension("com.jetbrains.intellij.gradle:gradle-tooling-extension:211.6693.111")
gradleToolingExtension("org.jetbrains:annotations:20.1.0")
gradleToolingExtension(libs.gradleToolingExtension)
gradleToolingExtension(libs.annotations)

val junitVersion = "5.7.1"
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
testImplementation(libs.junit.api)
testRuntimeOnly(libs.junit.entine)
}

intellij {
Expand Down Expand Up @@ -208,7 +205,7 @@ idea {
}

license {
header = file("copyright.txt")
header.set(resources.text.fromFile(file("copyright.txt")))
style["flex"] = HeaderStyle.BLOCK_COMMENT.format
style["bnf"] = HeaderStyle.BLOCK_COMMENT.format

Expand All @@ -233,20 +230,23 @@ license {

tasks {
register("gradle") {
files = project.fileTree(project.projectDir) {
include("**/*.gradle.kts", "gradle.properties")
exclude("**/buildSrc/**", "**/build/**")
}
files.from(
fileTree(project.projectDir) {
include("**/*.gradle.kts", "gradle.properties")
exclude("**/buildSrc/**", "**/build/**")
}
)
}
register("buildSrc") {
val buildSrc = project.projectDir.resolve("buildSrc")
files = project.fileTree(buildSrc) {
include("**/*.kt", "**/*.kts")
exclude("**/build/**")
}
files.from(
project.fileTree(project.projectDir.resolve("buildSrc")) {
include("**/*.kt", "**/*.kts")
exclude("**/build/**")
}
)
}
register("grammars") {
files = project.fileTree("src/main/grammars")
files.from(project.fileTree("src/main/grammars"))
}
}
}
Expand Down Expand Up @@ -306,3 +306,10 @@ tasks.runIde {
// systemProperty("user.language", "en")
// systemProperty("user.country", "US")
}

// version catalogs still have rough edges as it's still experimental
// this lets us get around some of that while still getting the benefits of using catalogs
fun Provider<MinimalExternalModuleDependency>.text(): String {
val dep = get()
return "${dep.module.group}:${dep.module.name}:${dep.versionConstraint}"
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ kotlin.code.style=official
ideaVersion = 2021.1
ideaVersionName = 2021.1

coreVersion = 1.5.8
coreVersion = 1.5.9
downloadIdeaSources = true

pluginTomlVersion = 0.2.144.3766-211
30 changes: 30 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[versions]
coroutines = "1.4.3"
junit = "5.7.1"

[libraries]
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "coroutines" }

templateMakerFabric = "com.extracraftx.minecraft:TemplateMakerFabric:0.3.0"

# GrammarKit
jflex-lib = "org.jetbrains.idea:jflex:1.7.0-b7f882a"
jflex-skeleton = "org.jetbrains.idea:jflex:1.7.0-c1fdf11"
grammarKit = "org.jetbrains.idea:grammar-kit:1.5.1"

# Gradle Tooling
gradleToolingExtension = "com.jetbrains.intellij.gradle:gradle-tooling-extension:211.6693.111"
annotations = "org.jetbrains:annotations:20.1.0"

# Testing
test-mockJdk = "org.jetbrains.idea:mockJDK:1.7-4d76c50"
test-mixin = "org.spongepowered:mixin:0.7-SNAPSHOT"
test-spongeapi = "org.spongepowered:spongeapi:7.0.0"
test-nbt = "com.demonwav.mcdev:all-types-nbt:1.0"

junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
junit-entine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }

[bundles]
coroutines = ["coroutines-core", "coroutines-swing"]
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Minecraft Development for IntelliJ
</tr>
</table>

Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.8-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
Info and Documentation [![Current Release](https://img.shields.io/badge/release-1.5.9-orange.svg?style=flat-square)](https://plugins.jetbrains.com/plugin/8327)
----------------------

<a href="https://discord.gg/j6UNcfr"><img src="https://i.imgur.com/JXu9C1G.png" height="48px"></img></a>
Expand Down Expand Up @@ -114,7 +114,7 @@ If you're curious about that task, it is implemented in `buildSrc`.
Developers
----------

- Project Owner - [**@DemonWav** - Kyle Wood](https://github.com/DemonWav)
- Project Owner - [**@DenWav** - Kyle Wood](https://github.com/DenWav)
- [**@Minecrell**](https://github.com/Minecrell)
- [**@PaleoCrafter** - Marvin Rösch](https://github.com/PaleoCrafter)
- [**@RedNesto**](https://github.com/RedNesto)
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
rootProject.name = "MinecraftDev"

gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS_FULL

enableFeaturePreview("VERSION_CATALOGS")
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ final class McpModelFG3BuilderImpl implements ModelBuilderService {
}

def taskOutput = task.outputs.files.singleFile
return new McpModelFG3Impl(minecraftDepVersions, extension.mappings, taskOutput, task.name)
//noinspection GroovyAssignabilityCheck
return new McpModelFG3Impl(minecraftDepVersions, extension.mappings, taskOutput, task.name, extension.accessTransformers)
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ final class McpModelFG3Impl implements McpModelFG3, Serializable {
final String mcpVersion
final File taskOutputLocation
final String taskName
final List<File> accessTransformers

McpModelFG3Impl(List<String> minecraftDepVersions, String mcpVersion, File taskOutputLocation, String taskName) {
McpModelFG3Impl(
final List<String> minecraftDepVersions,
final String mcpVersion,
final File taskOutputLocation,
final String taskName,
final List<File> accessTransformers
) {
this.minecraftDepVersions = minecraftDepVersions
this.mcpVersion = mcpVersion
this.taskOutputLocation = taskOutputLocation
this.taskName = taskName
this.accessTransformers = accessTransformers
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public interface McpModelFG3 extends McpModel {
List<String> getMinecraftDepVersions();
File getTaskOutputLocation();
String getTaskName();
List<File> getAccessTransformers();
}
4 changes: 2 additions & 2 deletions src/main/kotlin/creator/buildsystem/gradle/gradle-steps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.demonwav.mcdev.creator.buildsystem.BuildSystemTemplate
import com.demonwav.mcdev.creator.buildsystem.BuildSystemType
import com.demonwav.mcdev.creator.buildsystem.DirectorySet
import com.demonwav.mcdev.util.invokeLater
import com.demonwav.mcdev.util.runGradleTask
import com.demonwav.mcdev.util.runGradleTaskAndWait
import com.demonwav.mcdev.util.runWriteAction
import com.demonwav.mcdev.util.runWriteTask
import com.demonwav.mcdev.util.virtualFileOrError
Expand Down Expand Up @@ -272,7 +272,7 @@ class GradleWrapperStep(

indicator.text = "Setting up Gradle Wrapper"
indicator.text2 = "Running Gradle task: 'wrapper'"
runGradleTask(project, rootDirectory) { settings ->
runGradleTaskAndWait(project, rootDirectory) { settings ->
settings.taskNames = listOf("wrapper")
}
indicator.text2 = null
Expand Down
27 changes: 18 additions & 9 deletions src/main/kotlin/errorreporter/AnonymousFeedback.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ import java.net.HttpURLConnection
import java.nio.ByteBuffer
import java.nio.charset.CodingErrorAction
import org.apache.commons.io.IOUtils
import org.apache.http.HttpHeaders
import org.apache.http.entity.ContentType

object AnonymousFeedback {

data class FeedbackData(val url: String, val token: Int, val isDuplicate: Boolean)

const val url = "https://www.demonwav.com/errorReport"
const val url = "https://www.denwav.dev/errorReport"

fun sendFeedback(
factory: HttpConnectionFactory,
Expand Down Expand Up @@ -206,7 +208,11 @@ object AnonymousFeedback {
continue
}

data = connection.inputStream.reader().use(InputStreamReader::readCharSequence).toString()
val charset = connection.getHeaderField(HttpHeaders.CONTENT_TYPE)?.let {
ContentType.parse(it).charset
} ?: Charsets.UTF_8

data = connection.inputStream.reader(charset).readText()

response = Gson().fromJson(data)
list.addAll(response)
Expand All @@ -219,18 +225,21 @@ object AnonymousFeedback {
return list
}

private fun getNextLink(link: String?): String? {
if (link == null) {
private fun getNextLink(linkHeader: String?): String? {
if (linkHeader == null) {
return null
}
val lines = link.split(",")
for (line in lines) {
if (!line.contains("rel=\"next\"")) {
val links = linkHeader.split(",")
for (link in links) {
if (!link.contains("rel=\"next\"")) {
continue
}

val parts = line.split(";")
return parts[0].substring(1, parts[0].length - 1)
val parts = link.split(";")
if (parts.isEmpty()) {
continue
}
return parts[0].trim().removePrefix("<").removeSuffix(">")
}

return null
Expand Down
27 changes: 26 additions & 1 deletion src/main/kotlin/facet/MinecraftFacet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiMethod
import java.util.concurrent.ConcurrentHashMap
import javax.swing.Icon
import kotlin.jvm.Throws
import org.jetbrains.jps.model.java.JavaResourceRootType
import org.jetbrains.jps.model.java.JavaSourceRootType

Expand Down Expand Up @@ -195,10 +196,34 @@ class MinecraftFacet(
}

fun findFile(path: String, type: SourceType): VirtualFile? {
try {
return findFile0(path, type)
} catch (ignored: RefreshRootsException) {}

updateRoots()

return try {
findFile0(path, type)
} catch (ignored: RefreshRootsException) {
// Well we tried our best
null
}
}

private class RefreshRootsException : Exception()

@Throws(RefreshRootsException::class)
private fun findFile0(path: String, type: SourceType): VirtualFile? {
val roots = roots[type]

for (root in roots) {
return root?.findFileByRelativePath(path) ?: continue
val r = root ?: continue
if (!r.isValid) {
throw RefreshRootsException()
}
return r.findFileByRelativePath(path) ?: continue
}

return null
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/insight/ColorLineMarkerProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ColorLineMarkerProvider : LineMarkerProvider {
element,
color,
GutterIconNavigationHandler handler@{ _, _ ->
if (!element.isWritable) {
if (!element.isWritable || !element.isValid) {
return@handler
}

Expand Down
Loading

0 comments on commit 29bd07b

Please sign in to comment.