diff --git a/GhidraBuild/EclipsePlugins/SleighEditor/certification.manifest b/GhidraBuild/EclipsePlugins/SleighEditor/certification.manifest index e40d9e3a38..98e4da090e 100644 --- a/GhidraBuild/EclipsePlugins/SleighEditor/certification.manifest +++ b/GhidraBuild/EclipsePlugins/SleighEditor/certification.manifest @@ -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| diff --git a/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/META-INF/MANIFEST.MF b/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/META-INF/MANIFEST.MF index bcc4b7c765..55989317a5 100644 --- a/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/META-INF/MANIFEST.MF +++ b/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/META-INF/MANIFEST.MF @@ -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, diff --git a/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/plugin.xml b/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/plugin.xml index 7ab07ef916..1fb7470ae3 100644 --- a/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/plugin.xml +++ b/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/plugin.xml @@ -510,4 +510,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/console/ConsoleHyperlinking.xtend b/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/console/ConsoleHyperlinking.xtend new file mode 100644 index 0000000000..66e0cac48f --- /dev/null +++ b/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/console/ConsoleHyperlinking.xtend @@ -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 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; + } +} diff --git a/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/console/ConsoleLineTracker.java b/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/console/ConsoleLineTracker.java new file mode 100644 index 0000000000..534ec5ac10 --- /dev/null +++ b/GhidraBuild/EclipsePlugins/SleighEditor/ghidra.xtext.sleigh.ui/src/ghidra/xtext/sleigh/ui/console/ConsoleLineTracker.java @@ -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; + } + +}