Skip to content
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

Make line numbers in ERXExceptionPage clickable, navigating to them in Eclipse #995

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@
background-color: rgb(255,150,160);
}
</style>
<script>
// For communicating with the WOLips server
function invokeURL( url ) {
const Http = new XMLHttpRequest();
Http.open("GET", url);
Http.send();
}
</script>
</head>
<body>
<div class="container">
Expand All @@ -105,7 +113,7 @@ <h3><wo:str value="$exceptionParser.typeException" /><wo:if condition="$exceptio
<wo:repetition list="$exceptionParser.stackTrace" item="$currentErrorLine">
<wo:container elementName="tr" class="$currentRowClass">
<td><wo:str value="$currentErrorLine.fileName" /></td>
<td><wo:str value="$currentErrorLine.lineNumber" /></td>
<td><wo:link href="$currentLineURL" disabled="$currentLineDisabled"><wo:str value="$currentErrorLine.lineNumber" /></wo:link></td>
<td><wo:str value="$currentErrorLine.methodName" /></td>
<td><wo:str value="$currentErrorLine.packageName" /></td>
<td><wo:str value="$currentBundle.name" /></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import er.extensions.appserver.ERXApplication;
import er.extensions.components.ERXComponent;
import er.extensions.foundation.ERXProperties;

/**
* A nicer version of WOExceptionPage.
Expand Down Expand Up @@ -244,4 +245,44 @@ public String currentRowClass() {

return null;
}

/**
* @return A URL for opening the current line in Eclipse using the WOLips server
*/
public String currentLineURL() {
// WOExceptionParser returns the string "NA" for lines without a number (native code, synthetic/generated code etc.)
final boolean noLineNumber = "NA".equals( currentErrorLine.lineNumber() );

// No sense in generating a link for a missing line number
if( noLineNumber ) {
return null;
}

final String wolipsPassword = ERXProperties.stringForKey("wolips.password" );

// We can't communicate with the WOLips server if the password isn't set. No link for you.
if( wolipsPassword == null ) {
return null;
}

final int wolipsPortnumber = ERXProperties.intForKeyWithDefault("wolips.port", 9485 );
final String applicationName = application().name();
final String className = currentErrorLine.packageName() + "." + currentErrorLine.className();
final int lineNumber = currentErrorLine.line();

// Now use our parameters to generate the URL to communicate with the WOLips server.
String url = String.format( "http://localhost:%s/openJavaFile?pw=%s&app=%s&className=%s&lineNumber=%s", wolipsPortnumber, wolipsPassword, applicationName, className, lineNumber );

// Let's wrap the URL in a javascript method invocation
url = String.format( "javascript:invokeURL('%s')",url);

return url;
}

/**
* @return True if the current line can't be navigated to
*/
public boolean currentLineDisabled() {
return currentLineURL() == null;
}
}