Skip to content

Commit

Permalink
navigation to editor from logview (#1071)
Browse files Browse the repository at this point in the history
* navigation to editor from logview

* revert SetOutputPath fix
  • Loading branch information
van800 committed Feb 28, 2019
1 parent ea16ab0 commit f5a6fea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,32 @@ class UnityLogPanelEventList(lifetime: Lifetime) : JBList<LogPanelItem>(emptyLis
}

fun getNavigatableForSelected(list: UnityLogPanelEventList, project: Project): Navigatable? {
val node = list.selectedValue
if (node!=null && (node.stackTrace=="")) {
val index = node.message.indexOf("(")
if (index<0)
return null
val path = node.message.substring(0, index)
val regex = Regex("^\\(\\d{1,}\\,\\d{1,}\\)")
val res = regex.find(node.message.substring(index), 0) ?: return null
val coordinates = res.value.substring(1, res.value.length-1).split(",")
val line = (coordinates[0])
val col = coordinates[1]
val node = list.selectedValue ?: return null

val file = File(project.basePath, path)
if (!file.exists())
return null
val virtualFile = file.toVirtualFile()
return if (virtualFile != null)
OpenFileDescriptor(project, virtualFile , line.toInt()-1, col.toInt()-1, true)
else
null
val match: MatchResult?
var col = 0
if (node.stackTrace=="") {
val regex = Regex("""(?<path>^.*(?=\())\((?<line>\d+(?=,)),(?<col>\d+(?=\)))""")
match = regex.find(node.message) ?: return null
col = (match.groups["col"]?.value?.toInt() ?: return null)-1
}
return null
else {
// Use first (at Assets/NewBehaviourScript.cs:16) in stacktrace
val regex = Regex("""\(at (?<path>.*(?=:)):(?<line>\d+(?=\)))""")
match = regex.find(node.stackTrace) ?: return null
}

val path = match.groups["path"]?.value ?: return null
val line = (match.groups["line"]?.value?.toInt() ?: return null) - 1

val file = File(project.basePath, path)
if (!file.exists())
return null
val virtualFile = file.toVirtualFile()
return if (virtualFile != null)
OpenFileDescriptor(project, virtualFile, line, col, true)
else
null
}

override fun getData(dataId: String): Any? = when {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,10 @@ private static bool UpgradeProjectFile(string projectFile, XDocument doc)
changed |= SetXCodeDllReference("UnityEditor.iOS.Extensions.Common.dll", projectContentElement, xmlns);
changed |= SetDisableHandlePackageFileConflicts(projectContentElement, xmlns);
changed |= SetGenerateTargetFrameworkAttribute(projectContentElement, xmlns);
changed |= SetOutputPath(projectContentElement, xmlns);

return changed;
}

// update <OutputPath>Temp\bin\Debug\</OutputPath> into <OutputPath>Library\ScriptAssemblies\</OutputPath>
// Particularly useful for UnitTesting
private static bool SetOutputPath(XElement projectContentElement, XNamespace xmlns)
{
return SetOrUpdateProperty(projectContentElement, xmlns, "OutputPath", existing => "Library/ScriptAssemblies/");
}

/* Since Unity 2018.1.5f1 it looks like this:
<PropertyGroup>
<NoConfig>true</NoConfig>
Expand Down

0 comments on commit f5a6fea

Please sign in to comment.