Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » IMarker - problem view and editor
IMarker - problem view and editor [message #331936] Tue, 30 September 2008 02:06 Go to next message
John Rodriguez is currently offline John RodriguezFriend
Messages: 8
Registered: July 2009
Junior Member
I have written a new implementation of a debugger and editor for Lua.

I was trying to set an "Error" IMarker in the editor.

I set an IMarker and the marker shows up in the "Problems view" but not in
the editor. How can I get it to appear in both?

Here is the code I set the marker with.

IWorkspaceRunnable editorMarker = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
IMarker marker =
ResourcesPlugin.getWorkspace().getRoot().
createMarker(IMarker.PROBLEM);
marker.setAttribute(IMarker.MESSAGE, msg);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
marker.setAttribute(IMarker.TRANSIENT, true);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
}
};
try {
ResourcesPlugin.getWorkspace().run(editorMarker, null);
} catch (CoreException e) {
System.err.println("Some error set marker: " + e);
}
Re: IMarker - problem view and editor [message #331945 is a reply to message #331936] Tue, 30 September 2008 07:45 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
John Rodriguez wrote:
> I have written a new implementation of a debugger and editor for Lua.
>
> I was trying to set an "Error" IMarker in the editor.
>
> I set an IMarker and the marker shows up in the "Problems view" but
> not in the editor. How can I get it to appear in both?
> Here is the code I set the marker with.
>
> IWorkspaceRunnable editorMarker = new IWorkspaceRunnable() {
> public void run(IProgressMonitor monitor) throws CoreException {
> IMarker marker = ResourcesPlugin.getWorkspace().getRoot().
This is wrong. You need to create the marker on the resource that's
shown in the editor.

Dani
> createMarker(IMarker.PROBLEM);
> marker.setAttribute(IMarker.MESSAGE, msg);
> marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
> marker.setAttribute(IMarker.TRANSIENT, true);
> marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
> }
> };
> try {
> ResourcesPlugin.getWorkspace().run(editorMarker, null);
> } catch (CoreException e) {
> System.err.println("Some error set marker: " + e);
> }
>
Re: IMarker - problem view and editor [message #331972 is a reply to message #331945] Tue, 30 September 2008 19:36 Go to previous messageGo to next message
John Rodriguez is currently offline John RodriguezFriend
Messages: 8
Registered: July 2009
Junior Member
Thanks for your help.

Can getting the resource be done with static calls to get the resource (I
don't have the IRresource when I am trying to make a marker because I have
only a file name path that is given back from the Lua interpreter).

For example using:
ResourcesPlugin.getWorkspace() ...

In my line break point code, I am given a IWorkBechPart, from which I can
get my text editor:

public void toggleLineBreakpoints(IWorkbenchPart part, ISelection
selection) throws CoreException {
ITextEditor textEditor = getEditor(part);
IResource resource = (IResource)
editorPart.getEditorInput().getAdapter(IResource.class);

But I believe you are referring to the file resource that I have
interpreted to find the Lua syntax error in the editor, correct?


Daniel Megert wrote:

> John Rodriguez wrote:
>> I have written a new implementation of a debugger and editor for Lua.
>>
>> I was trying to set an "Error" IMarker in the editor.
>>
>> I set an IMarker and the marker shows up in the "Problems view" but
>> not in the editor. How can I get it to appear in both?
>> Here is the code I set the marker with.
>>
>> IWorkspaceRunnable editorMarker = new IWorkspaceRunnable() {
>> public void run(IProgressMonitor monitor) throws CoreException {
>> IMarker marker = ResourcesPlugin.getWorkspace().getRoot().
> This is wrong. You need to create the marker on the resource that's
> shown in the editor.

> Dani
>> createMarker(IMarker.PROBLEM);
>> marker.setAttribute(IMarker.MESSAGE, msg);
>> marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
>> marker.setAttribute(IMarker.TRANSIENT, true);
>> marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
>> }
>> };
>> try {
>> ResourcesPlugin.getWorkspace().run(editorMarker, null);
>> } catch (CoreException e) {
>> System.err.println("Some error set marker: " + e);
>> }
>>
Re: IMarker - problem view and editor [message #331992 is a reply to message #331972] Wed, 01 October 2008 10:54 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
John Rodriguez wrote:
> Thanks for your help.
>
> Can getting the resource be done with static calls to get the resource
> (I don't have the IRresource when I am trying to make a marker because
> I have only a file name path that is given back from the Lua
> interpreter).
>
> For example using:
> ResourcesPlugin.getWorkspace() ...
>
> In my line break point code, I am given a IWorkBechPart, from which I
> can get my text editor:
>
> public void toggleLineBreakpoints(IWorkbenchPart part, ISelection
> selection) throws CoreException {
> ITextEditor textEditor = getEditor(part);
> IResource resource = (IResource)
> editorPart.getEditorInput().getAdapter(IResource.class);
>
> But I believe you are referring to the file resource that I have
> interpreted to find the Lua syntax error in the editor, correct?
Right. At the point you add the marker you need to resolve the correct
resource otherwise it won't show up in the editor.

Dani
>
>
> Daniel Megert wrote:
>
>> John Rodriguez wrote:
>>> I have written a new implementation of a debugger and editor for Lua.
>>>
>>> I was trying to set an "Error" IMarker in the editor.
>>>
>>> I set an IMarker and the marker shows up in the "Problems view" but
>>> not in the editor. How can I get it to appear in both?
>>> Here is the code I set the marker with.
>>>
>>> IWorkspaceRunnable editorMarker = new IWorkspaceRunnable() {
>>> public void run(IProgressMonitor monitor) throws CoreException {
>>> IMarker marker =
>>> ResourcesPlugin.getWorkspace().getRoot().
>> This is wrong. You need to create the marker on the resource that's
>> shown in the editor.
>
>> Dani
>>> createMarker(IMarker.PROBLEM);
>>> marker.setAttribute(IMarker.MESSAGE, msg);
>>> marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
>>> marker.setAttribute(IMarker.TRANSIENT, true);
>>> marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
>>> }
>>> };
>>> try {
>>> ResourcesPlugin.getWorkspace().run(editorMarker, null);
>>> } catch (CoreException e) {
>>> System.err.println("Some error set marker: " + e);
>>> }
>>>
>
>
Previous Topic:JVM terminated. Exit code 13
Next Topic:Unable to register Search Extension to search extension point.
Goto Forum:
  


Current Time: Sun Sep 01 07:14:34 GMT 2024

Powered by FUDForum. Page generated in 0.04110 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top