下面列出了怎么用org.eclipse.ui.console.PatternMatchEvent的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void matchFound(PatternMatchEvent event) {
try {
CppStyleMessageConsole console = (CppStyleMessageConsole) event.getSource();
String line = console.getDocument().get(event.getOffset(), event.getLength());
Matcher m = pattern.matcher(line);
if (m.matches()) {
String ln = m.group(lineNumGroup);
int lineno = Integer.parseInt(ln);
FileLink link = new FileLink(file, null, -1, -1, lineno == 0 ? 1 : lineno);
console.addFileLink(link, event.getOffset(), event.getLength());
}
} catch (BadLocationException e) {
CppStyle.log("Failed to add link", e);
}
}
@Override
public void matchFound(PatternMatchEvent event) {
try {
int offset = event.getOffset();
int length = event.getLength();
N4JSStackTraceHyperlink link = n4JSStackTraceHyperlinkProvider.get();
link.setTextConsole(console);
console.addHyperlink(link, offset + 1, length - 2);
} catch (BadLocationException e) {
// no link to add
}
}
@Override
public void matchFound(PatternMatchEvent event) {
try {
int offset = event.getOffset();
int length = event.getLength();
IProcess process = (IProcess) console.getAttribute(IDebugUIConstants.ATTR_CONSOLE_PROCESS);
if (process != null) {
ILaunch launch = process.getLaunch();
String projectAttribute = RustLaunchDelegateTools.PROJECT_ATTRIBUTE;
String launchConfigurationType = launch.getLaunchConfiguration().getType().getIdentifier();
if (launchConfigurationType.equals(RustLaunchDelegateTools.CORROSION_DEBUG_LAUNCH_CONFIG_TYPE)) {
// support debug launch configs
projectAttribute = ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME;
}
String projectName = launch.getLaunchConfiguration().getAttribute(projectAttribute, ""); //$NON-NLS-1$
if (projectName.trim().isEmpty()) {
return; // can't determine project so prevent error down
}
IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject myProject = myWorkspaceRoot.getProject(projectName);
String errorString = console.getDocument().get(event.getOffset(), event.getLength());
String[] coordinates = errorString.split(":"); //$NON-NLS-1$
IHyperlink link = makeHyperlink(myProject.getFile(coordinates[0]), Integer.parseInt(coordinates[1]),
Integer.parseInt(coordinates[2]));
console.addHyperlink(link, offset, length);
}
} catch (BadLocationException | CoreException e) {
// ignore
}
}
@Override
public void matchFound(PatternMatchEvent event) {
if (event.getSource() instanceof TextConsole) {
try {
final TextConsole console = (TextConsole) event.getSource();
final int start = event.getOffset();
final int length = event.getLength();
IHyperlink link = new BrowserSupportBasedHyperlink(console.getDocument().get(start, length));
console.addHyperlink(link, start, length);
} catch (BadLocationException e) {
logger.log(Level.SEVERE, "Cannot create hyperlink", e);
}
}
}
@Override
public void matchFound(final PatternMatchEvent event) {
try {
final int offset = event.getOffset();
final int length = event.getLength();
String _get = this.console.getDocument().get(offset, length);
final XtendFileHyperlink link = new XtendFileHyperlink(_get, this.workbench, this.console);
this.console.addHyperlink(link, offset, length);
} catch (final Throwable _t) {
if (_t instanceof BadLocationException || _t instanceof NumberFormatException) {
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}