Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » How access my editor in AbstractSourceParser?
How access my editor in AbstractSourceParser? [message #1070815] Thu, 18 July 2013 18:31 Go to next message
Rodrigo Antonio is currently offline Rodrigo Antonio
Messages: 17
Registered: June 2010
Location: São Paulo - Brasil
Junior Member
Hi,

I need to save my parser tree for use after dltk parse call.

In my DLTK SourceParser:
public class MyMvcSourceParser extends AbstractSourceParser {
	
	public ModuleDeclaration parse(IModuleSource input,
			IProblemReporter reporter) {

	///Parse my file using ANTLR...

	ParseTree my_tree= source.parse()

	}
}


In my case, I will use parseTree for many other things.

I tryed make an SigleTon pattern, but I had many problem, if I open 2 o more editors at the same time.


My Editor:
public class MyEditor extends ScriptEditor
{
	private ParseTree m_treeParse;
	public void setParseTree(ParseTree tree)
	{
		m_treeParse = tree;
	}

}

I want to use my editor like this:
public class MyMvcSourceParser extends AbstractSourceParser {
	
	public ModuleDeclaration parse(IModuleSource input,
			IProblemReporter reporter) {

	///Parse my file using ANTLR...

	ParseTree my_tree= source.parse()

	MyEditor editor ....; //I need 
	editor.setParseTree(my_tree)

	}
}


How I access my Editor in parse method?

I've tried this:
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();

But parse method run in another thread, And getActiveWorkbenchWindow returns null.

Any Idea?


Thanks a lot
Re: How access my editor in AbstractSourceParser? [message #1072387 is a reply to message #1070815] Mon, 22 July 2013 16:47 Go to previous message
Alex Panchenko is currently offline Alex Panchenko
Messages: 342
Registered: July 2009
Senior Member
Hi Rodrigo,

You should not access editor from the parser - parser can be called even
without having editors open.
A better approach would be returning additional values from the parser
and using them in the editor if needed.

Regards,
Alex
Previous Topic:DocumentAdapter
Next Topic:OMA DM protocol in C++
Goto Forum:
  


Current Time: Fri Oct 24 12:07:36 GMT 2014

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

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