mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-25 13:42:06 +00:00
GT-113_emteere Adding sleigh compiler error navigation
This commit is contained in:
parent
a15c70950f
commit
0428895780
@ -27,6 +27,7 @@ ghidra.xtext.sleigh.ui/plugin.xml||GHIDRA||||END|
|
||||
ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/SleighEObjectHoverProvider.xtend||GHIDRA||||END|
|
||||
ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/SleighTextEditComposer.xtend||GHIDRA||||END|
|
||||
ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/SleighUiModule.xtend||GHIDRA||||END|
|
||||
ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/console/ConsoleHyperlinking.xtend||GHIDRA||||END|
|
||||
ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/contentassist/SleighProposalProvider.xtend||GHIDRA||||END|
|
||||
ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/labeling/SleighDescriptionLabelProvider.xtend||GHIDRA||||END|
|
||||
ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/labeling/SleighLabelProvider.xtend||GHIDRA||||END|
|
||||
|
@ -17,7 +17,8 @@ Require-Bundle: ghidra.xtext.sleigh,
|
||||
org.eclipse.compare,
|
||||
org.eclipse.xtext.builder,
|
||||
org.eclipse.xtext.xbase.lib;bundle-version="2.14.0",
|
||||
org.eclipse.xtend.lib;bundle-version="2.14.0";resolution:=optional
|
||||
org.eclipse.xtend.lib;bundle-version="2.14.0";resolution:=optional,
|
||||
org.eclipse.ui.console;bundle-version="3.8.400"
|
||||
Import-Package: org.apache.log4j
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Export-Package: ghidra.xtext.sleigh.ui.internal,
|
||||
|
@ -510,4 +510,62 @@
|
||||
<keywordReference id="ghidra.xtext.sleigh.ui.keyword_Sleigh"/>
|
||||
</page>
|
||||
</extension>
|
||||
<!-- Console Extensions -->
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.consoleLineTrackers">
|
||||
<consoleLineTracker
|
||||
class="ghidra.xtext.sleigh.ui.console.ConsoleLineTracker"
|
||||
processType="org.eclipse.ant.ui.antProcess"
|
||||
id="ghidra.xtext.sleigh.taskLineTracker">
|
||||
</consoleLineTracker>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.console.consolePatternMatchListeners">
|
||||
<consolePatternMatchListener
|
||||
class="ghidra.xtext.sleigh.ui.console.ConsoleHyperlinking"
|
||||
id="ghidra.xtext.sleigh.ui.consoleHyperlinking.Compiling"
|
||||
qualifier="javac"
|
||||
regex="Compiling .*.slaspec(:\d+)">
|
||||
<enablement>
|
||||
<test property="org.eclipse.debug.ui.processTypeTest" value="org.eclipse.ant.ui.antProcess"/>
|
||||
</enablement>
|
||||
</consolePatternMatchListener>
|
||||
<consolePatternMatchListener
|
||||
class="ghidra.xtext.sleigh.ui.console.ConsoleHyperlinking"
|
||||
id="ghidra.xtext.sleigh.ui.console.ConsoleHyperlinking.All"
|
||||
regex="\[java\] .*\.slaspec failed to compile">
|
||||
<enablement>
|
||||
<or>
|
||||
<test property="org.eclipse.ui.console.consoleTypeTest" value="javaStackTraceConsole"/>
|
||||
<test property="org.eclipse.debug.ui.processTypeTest" value="java"/>
|
||||
<test property="org.eclipse.debug.ui.processTypeTest" value="org.eclipse.ant.ui.antProcess"/>
|
||||
</or>
|
||||
</enablement>
|
||||
</consolePatternMatchListener>
|
||||
<consolePatternMatchListener
|
||||
class="ghidra.xtext.sleigh.ui.console.ConsoleHyperlinking"
|
||||
id="ghidra.xtext.sleigh.ui.console.ConsoleHyperlinking.All"
|
||||
regex="Compiling .*\.slaspec">
|
||||
<enablement>
|
||||
<or>
|
||||
<test property="org.eclipse.ui.console.consoleTypeTest" value="javaStackTraceConsole"/>
|
||||
<test property="org.eclipse.debug.ui.processTypeTest" value="java"/>
|
||||
<test property="org.eclipse.debug.ui.processTypeTest" value="org.eclipse.ant.ui.antProcess"/>
|
||||
</or>
|
||||
</enablement>
|
||||
</consolePatternMatchListener>
|
||||
<consolePatternMatchListener
|
||||
class="ghidra.xtext.sleigh.ui.console.ConsoleHyperlinking"
|
||||
id="ghidra.xtext.sleigh.ui.console.ConsoleHyperlinking.All"
|
||||
regex="\w+\.slaspec(:\d+)|\w+\.sinc(:\d+)">
|
||||
<enablement>
|
||||
<or>
|
||||
<test property="org.eclipse.ui.console.consoleTypeTest" value="javaStackTraceConsole"/>
|
||||
<test property="org.eclipse.debug.ui.processTypeTest" value="java"/>
|
||||
<test property="org.eclipse.debug.ui.processTypeTest" value="org.eclipse.ant.ui.antProcess"/>
|
||||
</or>
|
||||
</enablement>
|
||||
</consolePatternMatchListener>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
@ -0,0 +1,105 @@
|
||||
package ghidra.xtext.sleigh.ui.console
|
||||
|
||||
import java.util.HashMap
|
||||
import java.util.Map
|
||||
import org.eclipse.core.resources.IFile
|
||||
import org.eclipse.core.resources.ResourcesPlugin
|
||||
import org.eclipse.core.runtime.Path
|
||||
import org.eclipse.debug.ui.console.FileLink
|
||||
import org.eclipse.jface.text.BadLocationException
|
||||
import org.eclipse.ui.console.IPatternMatchListenerDelegate
|
||||
import org.eclipse.ui.console.PatternMatchEvent
|
||||
import org.eclipse.ui.console.TextConsole
|
||||
|
||||
class ConsoleHyperlinking implements IPatternMatchListenerDelegate {
|
||||
|
||||
static final String compilingBase = "Compiling ";
|
||||
static final String failedBase = " failed to compile";
|
||||
static final String javaPrefix = "[java] ";
|
||||
Map<String, IFile> fFileNameToIFile = new HashMap();
|
||||
|
||||
static String lastBase = ""; // last full path base name found
|
||||
|
||||
TextConsole console
|
||||
|
||||
override matchFound(PatternMatchEvent event) {
|
||||
try {
|
||||
var offset = event.getOffset();
|
||||
var length = event.getLength();
|
||||
var _str = console.document.get(offset, length);
|
||||
var setBase = false;
|
||||
|
||||
if (_str.indexOf(compilingBase) != -1) {
|
||||
_str = _str.replace(compilingBase, "");
|
||||
setBase = true;
|
||||
offset += compilingBase.length
|
||||
length -= compilingBase.length
|
||||
}
|
||||
|
||||
if (_str.indexOf(failedBase) != -1) {
|
||||
_str = _str.replace(failedBase, "");
|
||||
_str = _str.replace(javaPrefix, "");
|
||||
setBase = true;
|
||||
offset += javaPrefix.length
|
||||
length -= failedBase.length + javaPrefix.length
|
||||
}
|
||||
|
||||
// get filename and optional linenumber after ':'
|
||||
val indexOfColon = _str.indexOf(":")
|
||||
var fileName = ""
|
||||
var lineNumber = 1
|
||||
if (indexOfColon != -1) {
|
||||
fileName = _str.substring(0, indexOfColon)
|
||||
lineNumber = Integer.valueOf(_str.substring(indexOfColon + 1))
|
||||
} else {
|
||||
fileName = _str
|
||||
}
|
||||
|
||||
var file = getIFile(fileName, setBase);
|
||||
|
||||
if (file !== null) {
|
||||
val link = new FileLink(file, null, -1, -1, lineNumber);
|
||||
console.addHyperlink(link, offset, length);
|
||||
}
|
||||
} catch (BadLocationException | NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
|
||||
override connect(TextConsole console) {
|
||||
this.console = console
|
||||
lastBase = ""
|
||||
}
|
||||
|
||||
override disconnect() {
|
||||
this.console = null
|
||||
fFileNameToIFile.clear();
|
||||
}
|
||||
|
||||
def IFile getIFile(String filePath, boolean setBase) {
|
||||
if (filePath === null) {
|
||||
return null;
|
||||
}
|
||||
// check the name to IFile cache
|
||||
var file = fFileNameToIFile.get(filePath);
|
||||
if (file === null) {
|
||||
var f = new Path(filePath).toFile()
|
||||
var uri = f.toURI();
|
||||
var files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri);
|
||||
if (files.length <= 0) {
|
||||
// didn't find the file, try tacking on the lastbase path
|
||||
f = new Path(lastBase + Path.SEPARATOR + filePath).toFile()
|
||||
f.toURI();
|
||||
uri = f.toURI()
|
||||
files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri);
|
||||
}
|
||||
if (files.length > 0) {
|
||||
file = files.get(0);
|
||||
fFileNameToIFile.put(filePath, file);
|
||||
if (setBase) {
|
||||
lastBase = f.parent
|
||||
}
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.xtext.sleigh.ui.console;
|
||||
|
||||
import org.eclipse.debug.core.model.IProcess;
|
||||
import org.eclipse.debug.ui.console.IConsole;
|
||||
import org.eclipse.debug.ui.console.IConsoleLineTracker;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
|
||||
//import org.eclipse.ant.internal.ui.launchConfigurations.TaskLinkManager;
|
||||
|
||||
public class ConsoleLineTracker implements IConsoleLineTracker {
|
||||
|
||||
private IConsole fConsole;
|
||||
|
||||
/**
|
||||
* @see org.eclipse.debug.ui.console.IConsoleLineTracker#init(org.eclipse.debug.ui.console.IConsole)
|
||||
*/
|
||||
@Override
|
||||
public void init(IConsole console) {
|
||||
IProcess process = console.getProcess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lineAppended(IRegion line) {
|
||||
// TaskLinkManager.processNewLine(fConsole, line);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
fConsole = null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user