Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » getting a resource from java (Markers)
getting a resource from java (Markers) [message #162082] Mon, 31 May 2004 04:04 Go to next message
Eclipse UserFriend
Originally posted by: sergiolopes.gdnmail.net

Hello all.

I'm having a problem with markers and java. I'm making a visitor to
discover several situations in java code, wich i then want to let the user
know through markers.

My problem is that it seems i'm not capable of getting a resource inside
my java classes in order to use the Markers.

Here's what i'm doing:

I get and IEditorPart. After getting the IEditorPart, i'm able to obtain a
IWorkingCopyManager and a IEditorInput:

IWorkingCopyManager manager = JavaUI.getWorkingCopyManager();
IEditorInput editorInput = cuEditor.getEditorInput();

Then, i get the ICompilationUnit.
ICompilationUnit cu =
manager.getWorkingCopy(cuEditor.getEditorInput());

At this point, if i try any one of this methods that return a Resource, i
get null as a result from all of them:
cu.getResource();
cu.getCorrespondingResource();
cu.getUnderlyingResource();

Then i go on to processing java code with the visitor:
CompilationUnit cuu=AST.parseCompilationUnit(this.cu, true);
cuu.accept(this);

The visitor part seems alright because i can detect what i want and send
it to the console.

I'm really bugged with this. I must be doing something wrong or not doing
what i'm supposed to be doing. Any one can help me?

Thxs in advance.

Sergio
Re: getting a resource from java (Markers) [message #162108 is a reply to message #162082] Mon, 31 May 2004 09:27 Go to previous messageGo to next message
Eclipse UserFriend
Try downcasting the IEditorInput to IFileEditorInput

Genady Beryozkin
http://www.genady.net/



Sergio wrote:

>Hello all.
>
>I'm having a problem with markers and java. I'm making a visitor to
>discover several situations in java code, wich i then want to let the user
>know through markers.
>
>My problem is that it seems i'm not capable of getting a resource inside
>my java classes in order to use the Markers.
>
>Here's what i'm doing:
>
>I get and IEditorPart. After getting the IEditorPart, i'm able to obtain a
>IWorkingCopyManager and a IEditorInput:
>
> IWorkingCopyManager manager = JavaUI.getWorkingCopyManager();
> IEditorInput editorInput = cuEditor.getEditorInput();
>
>Then, i get the ICompilationUnit.
> ICompilationUnit cu =
>manager.getWorkingCopy(cuEditor.getEditorInput());
>
>At this point, if i try any one of this methods that return a Resource, i
>get null as a result from all of them:
> cu.getResource();
> cu.getCorrespondingResource();
> cu.getUnderlyingResource();
>
>Then i go on to processing java code with the visitor:
> CompilationUnit cuu=AST.parseCompilationUnit(this.cu, true);
> cuu.accept(this);
>
>The visitor part seems alright because i can detect what i want and send
>it to the console.
>
>I'm really bugged with this. I must be doing something wrong or not doing
>what i'm supposed to be doing. Any one can help me?
>
>Thxs in advance.
>
>Sergio
>
>
>
Re: getting a resource from java (Markers) [message #162137 is a reply to message #162108] Mon, 31 May 2004 16:27 Go to previous message
Eclipse UserFriend
Originally posted by: sergiolopes.gdnmail.net

It worked :)
Tanks a lot. I would never get there.
Thxs :)

Genady wrote:

> Try downcasting the IEditorInput to IFileEditorInput
Previous Topic:Folding editor enhancements
Next Topic:How to use the TAB key to indent a line of code?
Goto Forum:
  


Current Time: Thu May 08 21:04:16 EDT 2025

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

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

Back to the top