mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-CR-53251: [Gradle] navigate to the right column from the console file link IDEA-217932
GitOrigin-RevId: abe72f480db9c2b46e514c75440378e7be3022a2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
90bd782473
commit
ccf0ec14e0
@@ -31,11 +31,15 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
*/
|
||||
public class GradleConsoleFilter implements Filter {
|
||||
public static final Pattern LINE_AND_COLUMN_PATTERN = Pattern.compile("line (\\d+), column (\\d+)\\.");
|
||||
|
||||
@Nullable
|
||||
private final Project myProject;
|
||||
private static final TextAttributes HYPERLINK_ATTRIBUTES =
|
||||
@@ -107,7 +111,15 @@ public class GradleConsoleFilter implements Filter {
|
||||
int highlightEndOffset = textStartOffset + fileName.length();
|
||||
OpenFileHyperlinkInfo info = null;
|
||||
if (myProject != null) {
|
||||
info = new OpenFileHyperlinkInfo(myProject, file, Math.max(lineNumber - 1, 0));
|
||||
int columnNumber = 0;
|
||||
String lineAndColumn = StringUtil.substringAfterLast(line, " @ ");
|
||||
if (lineAndColumn != null) {
|
||||
Matcher matcher = LINE_AND_COLUMN_PATTERN.matcher(lineAndColumn);
|
||||
if (matcher.find()) {
|
||||
columnNumber = Integer.parseInt(matcher.group(2));
|
||||
}
|
||||
}
|
||||
info = new OpenFileHyperlinkInfo(myProject, file, Math.max(lineNumber - 1, 0), columnNumber);
|
||||
}
|
||||
TextAttributes attributes = HYPERLINK_ATTRIBUTES.clone();
|
||||
if (myProject != null && !ProjectRootManager.getInstance(myProject).getFileIndex().isInContent(file)) {
|
||||
|
||||
+8
-16
@@ -110,22 +110,14 @@ class GradleBuildScriptErrorParser : BuildOutputParser {
|
||||
|
||||
private fun getStartupErrorReasonAndFilePosition(errorText: String, filter: GradleConsoleFilter): Pair<String, FilePosition>? {
|
||||
val locationLine = errorText.substringAfter("> startup failed:", "").nullize()?.trimStart()?.substringBefore("\n") ?: return null
|
||||
val failedStartupReason = locationLine.substringAfter("'${filter.filteredFileName}': ${filter.filteredLineNumber}: ",
|
||||
"").nullize()?.substringBeforeLast('@') ?: return null
|
||||
val locationPart = locationLine.substringAfterLast('@')
|
||||
val line: Int
|
||||
val column: Int
|
||||
|
||||
val values = Regex(" line (\\d+), column (\\d+)\\.").matchEntire(locationPart)?.groupValues
|
||||
if (values != null) {
|
||||
line = values[1].toInt() - 1
|
||||
column = values[2].toInt()
|
||||
} else {
|
||||
line = filter.filteredLineNumber - 1
|
||||
column = 0
|
||||
}
|
||||
val filePosition = FilePosition(File(filter.filteredFileName), line, column)
|
||||
return Pair(failedStartupReason, filePosition)
|
||||
val failedStartupReason = locationLine.substringAfter("'${filter.filteredFileName}': ${filter.filteredLineNumber}: ", "")
|
||||
.nullize()?.substringBeforeLast(" @ ") ?: return null
|
||||
val locationPart = locationLine.substringAfterLast(" @ ")
|
||||
val matchResult = GradleConsoleFilter.LINE_AND_COLUMN_PATTERN.toRegex().matchEntire(locationPart)
|
||||
val values = matchResult?.groupValues?.drop(1)?.map { it.toInt() } ?: listOf(filter.filteredLineNumber, 0)
|
||||
val line = values[0] - 1
|
||||
val column = values[1]
|
||||
return Pair(failedStartupReason, FilePosition(File(filter.filteredFileName), line, column))
|
||||
}
|
||||
|
||||
private fun checkUnresolvedDependencyError(reason: String, description: StringBuilder, parentId: Any): BuildEvent? {
|
||||
|
||||
Reference in New Issue
Block a user