-
Notifications
You must be signed in to change notification settings - Fork 4
DCL improvements #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
h0tk3y
wants to merge
7
commits into
main
Choose a base branch
from
sigushkin/dcl-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
DCL improvements #45
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
41e46de
Update to latest Gradle nightly and latest version of unified plugins
ghale e7201cf
Display error messages from the DCL analyzer in popups
h0tk3y b76e076
Add features and project types info to the document view
h0tk3y f37c786
Refactor model actions into grouped collections
h0tk3y a1aaa4c
Move the `GetResilientGradleBuild` to the "Build and project" group
h0tk3y 47a70b9
Update Gradle wrapper and dependencies to `9.2.0-milestone-2`
h0tk3y 67494c1
Update the rest of the Gradle libs to `9.2.0-milestone-2`
h0tk3y File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.gradle.kotlin.dsl.dcl=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
gradle-client/src/jvmMain/kotlin/org/gradle/client/core/gradle/dcl/ErrorUtil.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.gradle.client.core.gradle.dcl | ||
|
||
import org.gradle.internal.declarativedsl.dom.AmbiguousName | ||
import org.gradle.internal.declarativedsl.dom.BlockMismatch | ||
import org.gradle.internal.declarativedsl.dom.CrossScopeAccess | ||
import org.gradle.internal.declarativedsl.dom.DeclarativeDocument | ||
import org.gradle.internal.declarativedsl.dom.DocumentResolution | ||
import org.gradle.internal.declarativedsl.dom.IllegalAugmentedAssignment | ||
import org.gradle.internal.declarativedsl.dom.IsError | ||
import org.gradle.internal.declarativedsl.dom.NonEnumValueNamedReference | ||
import org.gradle.internal.declarativedsl.dom.NotAssignable | ||
import org.gradle.internal.declarativedsl.dom.OpaqueValueInIdentityKey | ||
import org.gradle.internal.declarativedsl.dom.SyntaxError | ||
import org.gradle.internal.declarativedsl.dom.UnresolvedBase | ||
import org.gradle.internal.declarativedsl.dom.UnresolvedName | ||
import org.gradle.internal.declarativedsl.dom.UnresolvedSignature | ||
import org.gradle.internal.declarativedsl.dom.UnresolvedValueUsed | ||
import org.gradle.internal.declarativedsl.dom.UnsupportedKotlinFeature | ||
import org.gradle.internal.declarativedsl.dom.UnsupportedSyntax | ||
import org.gradle.internal.declarativedsl.dom.ValueTypeMismatch | ||
|
||
@Suppress("CyclomaticComplexMethod") | ||
fun userFriendlyErrorMessages( | ||
node: DeclarativeDocument.Node, | ||
unsuccessfulResolution: DocumentResolution.UnsuccessfulResolution | ||
): List<String> = unsuccessfulResolution.reasons.flatMap { reason -> | ||
when (reason) { | ||
AmbiguousName -> listOf("Ambiguous name") | ||
BlockMismatch -> if (node is DeclarativeDocument.DocumentNode.ElementNode) { | ||
if (node.content.isEmpty()) | ||
listOf("Block expected for element ${node.name}") | ||
else listOf("Block not expected for element ${node.name}") | ||
} else listOf("Block mismatch") | ||
|
||
CrossScopeAccess -> listOf("Cross-scope access") | ||
|
||
IsError -> if (node is DeclarativeDocument.DocumentNode.ErrorNode) { | ||
node.errors.map { error -> | ||
when (error) { | ||
is SyntaxError -> "Syntax error: ${error.parsingError.message}" | ||
is UnsupportedKotlinFeature -> | ||
"Unsupported language feature: ${error.unsupportedConstruct.languageFeature}" | ||
is UnsupportedSyntax -> "Unsupported syntax: ${error.cause}" | ||
} | ||
} | ||
} else listOf("Syntax error") | ||
|
||
OpaqueValueInIdentityKey -> listOf("Opaque value passed as identity key") | ||
UnresolvedName -> listOf("Unresolved name") | ||
UnresolvedSignature -> listOf("Unresolved function signature") | ||
IllegalAugmentedAssignment -> listOf("Illegal augmented assignment") | ||
NotAssignable -> listOf("Cannot assign property") | ||
UnresolvedValueUsed -> listOf("Assigned value is not resolved") | ||
ValueTypeMismatch -> listOf("Value type mismatch") | ||
NonEnumValueNamedReference -> listOf("Illegal named reference. Only enum entries can be referenced by name") | ||
|
||
UnresolvedBase -> emptyList<String>() | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
@file:Suppress("TooManyFunctions") | ||
|
||
package org.gradle.client.ui.composables | ||
|
||
import androidx.compose.animation.animateContentSize | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.text.ClickableText | ||
import androidx.compose.foundation.text2.input.maxLengthInChars | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.alpha | ||
import androidx.compose.ui.draw.shadow | ||
import androidx.compose.ui.layout.onSizeChanged | ||
import androidx.compose.ui.platform.LocalDensity | ||
import androidx.compose.ui.text.AnnotatedString | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.text.style.TextOverflow | ||
import androidx.compose.ui.unit.IntSize | ||
import androidx.compose.ui.unit.dp | ||
import org.gradle.client.ui.theme.spacing | ||
import org.gradle.client.ui.theme.transparency | ||
|
||
|
@@ -41,6 +59,15 @@ fun TitleSmall(text: String, modifier: Modifier = Modifier) { | |
) | ||
} | ||
|
||
@Composable | ||
fun TitleSmall(text: AnnotatedString, modifier: Modifier = Modifier) { | ||
Text( | ||
modifier = modifier, | ||
text = text, | ||
style = MaterialTheme.typography.titleSmall, | ||
) | ||
} | ||
|
||
@Composable | ||
fun BodyMedium(text: String, modifier: Modifier = Modifier) { | ||
Text( | ||
|
@@ -81,23 +108,48 @@ fun HeadlineSmall(text: String, modifier: Modifier = Modifier) { | |
fun CodeBlock( | ||
modifier: Modifier = Modifier, | ||
code: AnnotatedString, | ||
popup: String?, | ||
onClick: (Int) -> Unit = {}, | ||
) { | ||
var boxSize by remember { mutableStateOf(IntSize.Zero) } | ||
Surface( | ||
tonalElevation = MaterialTheme.spacing.level1, | ||
color = MaterialTheme.colorScheme.surface, | ||
contentColor = MaterialTheme.colorScheme.onSurface, | ||
shape = MaterialTheme.shapes.extraSmall, | ||
modifier = modifier | ||
modifier = modifier.onSizeChanged { boxSize = it } | ||
) { | ||
ClickableText( | ||
text = code, | ||
modifier = Modifier.padding(MaterialTheme.spacing.level2), | ||
style = MaterialTheme.typography.labelMedium.copy(fontFamily = FontFamily.Monospace), | ||
onClick = onClick, | ||
) | ||
Box { | ||
ClickableText( | ||
text = code, | ||
modifier = Modifier.padding(MaterialTheme.spacing.level2), | ||
style = MaterialTheme.typography.labelMedium.copy(fontFamily = FontFamily.Monospace), | ||
onClick = onClick, | ||
) | ||
Box( | ||
modifier = | ||
Modifier | ||
.padding(bottom = 8.dp) | ||
.background(MaterialTheme.colorScheme.background) | ||
.width(boxSize.width.toDp() - 8.dp) | ||
.align(Alignment.BottomCenter) | ||
.shadow(2.dp) | ||
.animateContentSize() | ||
) { | ||
if (popup != null) { | ||
Text( | ||
text = popup, | ||
overflow = TextOverflow.Ellipsis, | ||
modifier = Modifier.padding(8.dp) | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun Int.toDp() = with(LocalDensity.current) { [email protected]() } | ||
|
||
fun Modifier.semiTransparentIfNull(any: Any?) = | ||
if (any == null) alpha(MaterialTheme.transparency.HALF) else this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Good call adding some structure here