[pdt-dev] can i get ISourceModule from IStructuredDocumentRegion

2009-04-13 Thread 赵忠伟
i know ISourceModule can be got from File.
but i want to know if ISourceModule can be got from
IStructuredDocumentRegion.
if could,can anyone tell me how.
thank you in advance!


best regards.
___
pdt-dev mailing list
pdt-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/pdt-dev


Re: [pdt-dev] can i get ISourceModule from IStructuredDocumentRegion

2009-04-13 Thread 赵忠伟
and document to ISourceModule map seems better.lol

2009/4/13 赵忠伟 zhaozhong...@eclipseworld.org

 actually,one map to store document to editor relation is enough.

 Michael ,i want some advices from you .thank you!

 2009/4/13 赵忠伟 zhaozhong...@eclipseworld.org

  thank you for your patient!

 best regards!

   2009/4/13 Michael Spector spek...@gmail.com

 Sorry, I've forgot to compare documents. Here's the complete solution:


 IStructuredDocumentRegion sdRegion;
IStructuredDocument parentDocument =
 sdRegion.getParentDocument();
IWorkbenchPage page = PHPUiPlugin.getActivePage();
if (page != null) {
IEditorPart editor = page.getActiveEditor();
if (editor instanceof PHPStructuredEditor) {
StructuredTextViewer textViewer =
 ((PHPStructuredEditor)
 editor).getTextViewer();
if (textViewer != null 
 textViewer.getDocument() == parentDocument) {
ISourceModule sourceModule =
 (ISourceModule)
 ((PHPStructuredEditor) editor).getModelElement();
}
}
}




 2009/4/13 Michael Spector spek...@gmail.com:
   In this case you can do the following hack :)
 
  IStructuredDocumentRegion sdRegion;
  IStructuredDocument parentDocument = sdRegion.getParentDocument();
  IWorkbenchPage page = PHPUiPlugin.getActivePage();
  if (page != null) {
 IEditorPart editor = page.getActiveEditor();
 if (editor instanceof PHPStructuredEditor) {
 ISourceModule sourceModule = (ISourceModule)
 ((PHPStructuredEditor)
  editor).getModelElement();
 }
  }
 
  On Mon, Apr 13, 2009 at 12:22 PM, 赵忠伟 zhaozhong...@eclipseworld.org
 wrote:
  hi, Michael
 
  i extended the extension org.eclipse.wst.sse.ui.semanticHighlighting
  as following:
   extension point=org.eclipse.wst.sse.ui.semanticHighlighting
highlighting
 
 
 class=org.eclipse.php.internal.ui.editor.highlighting.PHPStaticSemanticHighlighting
  target=org.eclipse.php.core.phpsource
/highlighting
   /extension
 
  here PHPStaticSemanticHighlighting need to implement
 ISemanticHighlighting
  interface
  and there is a method public Position[]
 consumes(IStructuredDocumentRegion
  region); in ISemanticHighlighting interface ,so the context is i can
 get
  nothing except IStructuredDocumentRegion (actually
  XMLStructuredDocumentRegion).the method ISemanticHighlighting#consumes
 is
  called by SemanticHighlightingReconciler#reconcile (more or less 133rd
  line) .there is StructuredTextEditor in
 SemanticHighlightingReconciler,but i
  could not get it.if i the editor,i can get editorinput and the file,so
 i can
  use DLTKCore#create to get a ISourceModule ,but now i can only get
  IStructuredDocumentRegion ,nothing else!i search a lot in the pdt
 source but
  i did not find a way to get ISourceModule from
 IStructuredDocumentRegion.and
  in my oponion,ISourceModule must be relative to IScriptProject and
  IScriptFolder,so from IStructuredDocumentRegion ,it is hardly to find
 the
  corresponding ISourceModule (IScriptProject and IScriptFolder) it
 belongs
  to.i am sorry for my poor english:)
 
 
 
  thank you very much!
  best regards!
  ___
  pdt-dev mailing list
  pdt-dev@eclipse.org
  https://dev.eclipse.org/mailman/listinfo/pdt-dev
 
 
 
 
 
  --
  Best regards,
  Michael
 



 --
 Best regards,
 Michael
 ___
 pdt-dev mailing list
 pdt-dev@eclipse.org
 https://dev.eclipse.org/mailman/listinfo/pdt-dev




___
pdt-dev mailing list
pdt-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/pdt-dev


Re: [pdt-dev] can i get ISourceModule from IStructuredDocumentRegion

2009-04-13 Thread Michael Spector
Can you use PlatformUI.getWorkbench().getDisplay().syncExec() ?

2009/4/13 赵忠伟 zhaozhong...@eclipseworld.org:
 thanks for your reply.i think it is executed in non-ui thread ,and the
 result is (page == null),as i use the following code.

 //   IWorkbench workbench  = PlatformUI.getWorkbench();
 //   IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
 //   IWorkbenchPage page  = window.getActivePage();
 //   IEditorPart editorpart = page.getActiveEditor();
 //   if(editorpart instanceof PHPStructuredEditor){
 but i think i have some other method to get the edtior.descript as
 following:

 PHPStructuredEditor#createStructedTextViewer
  protected StructuredTextViewer createStructedTextViewer(Composite parent,
 IVerticalRuler verticalRuler, int styles) {
   PHPStructuredTextViewer structuredTextViewer = new
 PHPStructuredTextViewer(this, parent, verticalRuler, getOverviewRuler(),
 isOverviewRulerVisible(), styles);
   structuredTextViewer.addTextInputListener(new ITextInputListener(){

public void inputDocumentChanged(IDocument oldInput, IDocument newInput)
 {
 //do some operation
}

public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument
 newInput) {
}
   });
   return structuredTextViewer;
  }
 i do some operations to put the current PHPStructuredEditor instance and
 IDocument to two global maps(they map to each other in a thread save way)
 .,and remove them when the editor is disposed.

 so in  ISemanticHighlighting#consumes i can get the IDocument :
 IStructuredDocumentRegion sdRegion;
 IStructuredDocument parentDocument = sdRegion.getParentDocument();

 and then through the global map,i think i can make it. i think it is a very
 poor way!


 wei

 2009/4/13 Michael Spector spek...@gmail.com

 In this case you can do the following hack :)

 IStructuredDocumentRegion sdRegion;
 IStructuredDocument parentDocument = sdRegion.getParentDocument();
 IWorkbenchPage page = PHPUiPlugin.getActivePage();
 if (page != null) {
IEditorPart editor = page.getActiveEditor();
if (editor instanceof PHPStructuredEditor) {
ISourceModule sourceModule = (ISourceModule)
 ((PHPStructuredEditor)
 editor).getModelElement();
}
 }

 On Mon, Apr 13, 2009 at 12:22 PM, 赵忠伟 zhaozhong...@eclipseworld.org
 wrote:
  hi, Michael
 
  i extended the extension org.eclipse.wst.sse.ui.semanticHighlighting
  as following:
   extension point=org.eclipse.wst.sse.ui.semanticHighlighting
highlighting
 
 
  class=org.eclipse.php.internal.ui.editor.highlighting.PHPStaticSemanticHighlighting
  target=org.eclipse.php.core.phpsource
/highlighting
   /extension
 
  here PHPStaticSemanticHighlighting need to implement
  ISemanticHighlighting
  interface
  and there is a method public Position[]
  consumes(IStructuredDocumentRegion
  region); in ISemanticHighlighting interface ,so the context is i can get
  nothing except IStructuredDocumentRegion (actually
  XMLStructuredDocumentRegion).the method ISemanticHighlighting#consumes
  is
  called by SemanticHighlightingReconciler#reconcile (more or less 133rd
  line) .there is StructuredTextEditor in
  SemanticHighlightingReconciler,but i
  could not get it.if i the editor,i can get editorinput and the file,so i
  can
  use DLTKCore#create to get a ISourceModule ,but now i can only get
  IStructuredDocumentRegion ,nothing else!i search a lot in the pdt source
  but
  i did not find a way to get ISourceModule from
  IStructuredDocumentRegion.and
  in my oponion,ISourceModule must be relative to IScriptProject and
  IScriptFolder,so from IStructuredDocumentRegion ,it is hardly to find
  the
  corresponding ISourceModule (IScriptProject and IScriptFolder) it
  belongs
  to.i am sorry for my poor english:)
 
 
 
  thank you very much!
  best regards!
  ___
  pdt-dev mailing list
  pdt-dev@eclipse.org
  https://dev.eclipse.org/mailman/listinfo/pdt-dev
 
 



 --
 Best regards,
 Michael
 ___
 pdt-dev mailing list
 pdt-dev@eclipse.org
 https://dev.eclipse.org/mailman/listinfo/pdt-dev


 ___
 pdt-dev mailing list
 pdt-dev@eclipse.org
 https://dev.eclipse.org/mailman/listinfo/pdt-dev





-- 
Best regards,
Michael
___
pdt-dev mailing list
pdt-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/pdt-dev


Re: [pdt-dev] can i get ISourceModule from IStructuredDocumentRegion

2009-04-13 Thread 赵忠伟
how to use PlatformUI.getWorkbench().getDisplay().syncExec() ?

ISemanticHighlighting#consumes is called by wtp,so i can not change the way
it is called.
all i can do is in ISemanticHighlighting#consumes use the limited
parameter,but it is not enough,so i want to do some operation on pdt.

i just want to add pdt some semantic highlighting function:)

and the  semantic highlighting interface and extension are defined in
wtp.soany advice there?
2009/4/13 Michael Spector spek...@gmail.com

 Can you use PlatformUI.getWorkbench().getDisplay().syncExec() ?

 2009/4/13 赵忠伟 zhaozhong...@eclipseworld.org:
   thanks for your reply.i think it is executed in non-ui thread ,and the
  result is (page == null),as i use the following code.
 
  //   IWorkbench workbench  = PlatformUI.getWorkbench();
  //   IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
  //   IWorkbenchPage page  = window.getActivePage();
  //   IEditorPart editorpart = page.getActiveEditor();
  //   if(editorpart instanceof PHPStructuredEditor){
  but i think i have some other method to get the edtior.descript as
  following:
 
  PHPStructuredEditor#createStructedTextViewer
   protected StructuredTextViewer createStructedTextViewer(Composite
 parent,
  IVerticalRuler verticalRuler, int styles) {
PHPStructuredTextViewer structuredTextViewer = new
  PHPStructuredTextViewer(this, parent, verticalRuler, getOverviewRuler(),
  isOverviewRulerVisible(), styles);
structuredTextViewer.addTextInputListener(new ITextInputListener(){
 
 public void inputDocumentChanged(IDocument oldInput, IDocument
 newInput)
  {
  //do some operation
 }
 
 public void inputDocumentAboutToBeChanged(IDocument oldInput,
 IDocument
  newInput) {
 }
});
return structuredTextViewer;
   }
  i do some operations to put the current PHPStructuredEditor instance and
  IDocument to two global maps(they map to each other in a thread save way)
  .,and remove them when the editor is disposed.
 
  so in  ISemanticHighlighting#consumes i can get the IDocument :
  IStructuredDocumentRegion sdRegion;
  IStructuredDocument parentDocument = sdRegion.getParentDocument();
 
  and then through the global map,i think i can make it. i think it is a
 very
  poor way!
 
 
  wei
 
  2009/4/13 Michael Spector spek...@gmail.com
 
  In this case you can do the following hack :)
 
  IStructuredDocumentRegion sdRegion;
  IStructuredDocument parentDocument = sdRegion.getParentDocument();
  IWorkbenchPage page = PHPUiPlugin.getActivePage();
  if (page != null) {
 IEditorPart editor = page.getActiveEditor();
 if (editor instanceof PHPStructuredEditor) {
 ISourceModule sourceModule = (ISourceModule)
  ((PHPStructuredEditor)
  editor).getModelElement();
 }
  }
 
  On Mon, Apr 13, 2009 at 12:22 PM, 赵忠伟 zhaozhong...@eclipseworld.org
  wrote:
   hi, Michael
  
   i extended the extension org.eclipse.wst.sse.ui.semanticHighlighting
   as following:
extension point=org.eclipse.wst.sse.ui.semanticHighlighting
 highlighting
  
  
  
 class=org.eclipse.php.internal.ui.editor.highlighting.PHPStaticSemanticHighlighting
   target=org.eclipse.php.core.phpsource
 /highlighting
/extension
  
   here PHPStaticSemanticHighlighting need to implement
   ISemanticHighlighting
   interface
   and there is a method public Position[]
   consumes(IStructuredDocumentRegion
   region); in ISemanticHighlighting interface ,so the context is i can
 get
   nothing except IStructuredDocumentRegion (actually
   XMLStructuredDocumentRegion).the method ISemanticHighlighting#consumes
   is
   called by SemanticHighlightingReconciler#reconcile (more or less 133rd
   line) .there is StructuredTextEditor in
   SemanticHighlightingReconciler,but i
   could not get it.if i the editor,i can get editorinput and the file,so
 i
   can
   use DLTKCore#create to get a ISourceModule ,but now i can only get
   IStructuredDocumentRegion ,nothing else!i search a lot in the pdt
 source
   but
   i did not find a way to get ISourceModule from
   IStructuredDocumentRegion.and
   in my oponion,ISourceModule must be relative to IScriptProject and
   IScriptFolder,so from IStructuredDocumentRegion ,it is hardly to find
   the
   corresponding ISourceModule (IScriptProject and IScriptFolder) it
   belongs
   to.i am sorry for my poor english:)
  
  
  
   thank you very much!
   best regards!
   ___
   pdt-dev mailing list
   pdt-dev@eclipse.org
   https://dev.eclipse.org/mailman/listinfo/pdt-dev
  
  
 
 
 
  --
  Best regards,
  Michael
  ___
  pdt-dev mailing list
  pdt-dev@eclipse.org
  https://dev.eclipse.org/mailman/listinfo/pdt-dev
 
 
  ___
  pdt-dev mailing list
  pdt-dev@eclipse.org
  https://dev.eclipse.org/mailman/listinfo/pdt-dev
 
 



 --
 Best regards,
 Michael
 ___
 

Re: [pdt-dev] can i get ISourceModule from IStructuredDocumentRegion

2009-04-13 Thread Michael Spector
I mean you can use syncExec() for running things in UI thread... like
getting an active editor page.

2009/4/13 赵忠伟 zhaozhong...@eclipseworld.org:
 how to use PlatformUI.getWorkbench().getDisplay().syncExec() ?
 ISemanticHighlighting#consumes is called by wtp,so i can not change the way
 it is called.
 all i can do is in ISemanticHighlighting#consumes use the limited
 parameter,but it is not enough,so i want to do some operation on pdt.

 i just want to add pdt some semantic highlighting function:)

 and the  semantic highlighting interface and extension are defined in
 wtp.soany advice there?
 2009/4/13 Michael Spector spek...@gmail.com

 Can you use PlatformUI.getWorkbench().getDisplay().syncExec() ?

 2009/4/13 赵忠伟 zhaozhong...@eclipseworld.org:
  thanks for your reply.i think it is executed in non-ui thread ,and the
  result is (page == null),as i use the following code.
 
  //   IWorkbench workbench  = PlatformUI.getWorkbench();
  //   IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
  //   IWorkbenchPage page  = window.getActivePage();
  //   IEditorPart editorpart = page.getActiveEditor();
  //   if(editorpart instanceof PHPStructuredEditor){
  but i think i have some other method to get the edtior.descript as
  following:
 
  PHPStructuredEditor#createStructedTextViewer
   protected StructuredTextViewer createStructedTextViewer(Composite
  parent,
  IVerticalRuler verticalRuler, int styles) {
PHPStructuredTextViewer structuredTextViewer = new
  PHPStructuredTextViewer(this, parent, verticalRuler, getOverviewRuler(),
  isOverviewRulerVisible(), styles);
structuredTextViewer.addTextInputListener(new ITextInputListener(){
 
 public void inputDocumentChanged(IDocument oldInput, IDocument
  newInput)
  {
  //do some operation
 }
 
 public void inputDocumentAboutToBeChanged(IDocument oldInput,
  IDocument
  newInput) {
 }
});
return structuredTextViewer;
   }
  i do some operations to put the current PHPStructuredEditor instance and
  IDocument to two global maps(they map to each other in a thread save
  way)
  .,and remove them when the editor is disposed.
 
  so in  ISemanticHighlighting#consumes i can get the IDocument :
  IStructuredDocumentRegion sdRegion;
  IStructuredDocument parentDocument = sdRegion.getParentDocument();
 
  and then through the global map,i think i can make it. i think it is a
  very
  poor way!
 
 
  wei
 
  2009/4/13 Michael Spector spek...@gmail.com
 
  In this case you can do the following hack :)
 
  IStructuredDocumentRegion sdRegion;
  IStructuredDocument parentDocument = sdRegion.getParentDocument();
  IWorkbenchPage page = PHPUiPlugin.getActivePage();
  if (page != null) {
 IEditorPart editor = page.getActiveEditor();
 if (editor instanceof PHPStructuredEditor) {
 ISourceModule sourceModule = (ISourceModule)
  ((PHPStructuredEditor)
  editor).getModelElement();
 }
  }
 
  On Mon, Apr 13, 2009 at 12:22 PM, 赵忠伟 zhaozhong...@eclipseworld.org
  wrote:
   hi, Michael
  
   i extended the extension
   org.eclipse.wst.sse.ui.semanticHighlighting
   as following:
extension point=org.eclipse.wst.sse.ui.semanticHighlighting
 highlighting
  
  
  
   class=org.eclipse.php.internal.ui.editor.highlighting.PHPStaticSemanticHighlighting
   target=org.eclipse.php.core.phpsource
 /highlighting
/extension
  
   here PHPStaticSemanticHighlighting need to implement
   ISemanticHighlighting
   interface
   and there is a method public Position[]
   consumes(IStructuredDocumentRegion
   region); in ISemanticHighlighting interface ,so the context is i can
   get
   nothing except IStructuredDocumentRegion (actually
   XMLStructuredDocumentRegion).the method
   ISemanticHighlighting#consumes
   is
   called by SemanticHighlightingReconciler#reconcile (more or less
   133rd
   line) .there is StructuredTextEditor in
   SemanticHighlightingReconciler,but i
   could not get it.if i the editor,i can get editorinput and the
   file,so i
   can
   use DLTKCore#create to get a ISourceModule ,but now i can only get
   IStructuredDocumentRegion ,nothing else!i search a lot in the pdt
   source
   but
   i did not find a way to get ISourceModule from
   IStructuredDocumentRegion.and
   in my oponion,ISourceModule must be relative to IScriptProject and
   IScriptFolder,so from IStructuredDocumentRegion ,it is hardly to find
   the
   corresponding ISourceModule (IScriptProject and IScriptFolder) it
   belongs
   to.i am sorry for my poor english:)
  
  
  
   thank you very much!
   best regards!
   ___
   pdt-dev mailing list
   pdt-dev@eclipse.org
   https://dev.eclipse.org/mailman/listinfo/pdt-dev
  
  
 
 
 
  --
  Best regards,
  Michael
  ___
  pdt-dev mailing list
  pdt-dev@eclipse.org
  https://dev.eclipse.org/mailman/listinfo/pdt-dev
 
 
  ___
  

Re: [pdt-dev] can i get ISourceModule from IStructuredDocumentRegion

2009-04-13 Thread 赵忠伟
thanks to both of you!
great!
syncExec() works,it can get the current active editor!
as following

   PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
 IWorkbenchPage page = PHPUiPlugin.getActivePage();
 if (page != null) {
  IEditorPart editor = page.getActiveEditor();
   if (editor instanceof PHPStructuredEditor) {


i think the things left may be esay to be done:)

2009/4/13 Roy Ganor r...@zend.com

 Obviously coloring is something that happens in the UI thread, but
 calculation of the tokens should not be dependent on it. Eventually we can
 remove the basic coloring to minimum and resolve some performance issues
 with big files... hopefully ;)

 - Roy

 -Original Message-
 From: pdt-dev-boun...@eclipse.org [mailto:pdt-dev-boun...@eclipse.org] On
 Behalf Of Michael Spector
  Sent: Monday, April 13, 2009 5:35 PM
 To: PDT Developers
 Subject: Re: [pdt-dev] can i get ISourceModule from
 IStructuredDocumentRegion

 So, in this case you should not use
 org.eclipse.wst.sse.ui.semanticHighlighting  :)

 2009/4/13 Roy Ganor r...@zend.com:
  Well, the whole idea with semantic highlighting that it is done in the
 background.
  Reviewing the Java implementation we should be able to do it without any
 dependency of the UI thread?
 
  Thoughts?
 
 
 
  -Original Message-
  From: pdt-dev-boun...@eclipse.org [mailto:pdt-dev-boun...@eclipse.org]
 On Behalf Of Michael Spector
  Sent: Monday, April 13, 2009 5:12 PM
  To: PDT Developers
  Subject: Re: [pdt-dev] can i get ISourceModule from
 IStructuredDocumentRegion
 
  I mean you can use syncExec() for running things in UI thread... like
  getting an active editor page.
 
  2009/4/13 赵忠伟 zhaozhong...@eclipseworld.org:
  how to use PlatformUI.getWorkbench().getDisplay().syncExec() ?
  ISemanticHighlighting#consumes is called by wtp,so i can not change the
 way
  it is called.
  all i can do is in ISemanticHighlighting#consumes use the limited
  parameter,but it is not enough,so i want to do some operation on pdt.
 
  i just want to add pdt some semantic highlighting function:)
 
  and the  semantic highlighting interface and extension are defined in
  wtp.soany advice there?
  2009/4/13 Michael Spector spek...@gmail.com
 
  Can you use PlatformUI.getWorkbench().getDisplay().syncExec() ?
 
  2009/4/13 赵忠伟 zhaozhong...@eclipseworld.org:
   thanks for your reply.i think it is executed in non-ui thread ,and
 the
   result is (page == null),as i use the following code.
  
   //   IWorkbench workbench  = PlatformUI.getWorkbench();
   //   IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
   //   IWorkbenchPage page  = window.getActivePage();
   //   IEditorPart editorpart = page.getActiveEditor();
   //   if(editorpart instanceof PHPStructuredEditor){
   but i think i have some other method to get the edtior.descript as
   following:
  
   PHPStructuredEditor#createStructedTextViewer
protected StructuredTextViewer createStructedTextViewer(Composite
   parent,
   IVerticalRuler verticalRuler, int styles) {
 PHPStructuredTextViewer structuredTextViewer = new
   PHPStructuredTextViewer(this, parent, verticalRuler,
 getOverviewRuler(),
   isOverviewRulerVisible(), styles);
 structuredTextViewer.addTextInputListener(new ITextInputListener(){
  
  public void inputDocumentChanged(IDocument oldInput, IDocument
   newInput)
   {
   //do some operation
  }
  
  public void inputDocumentAboutToBeChanged(IDocument oldInput,
   IDocument
   newInput) {
  }
 });
 return structuredTextViewer;
}
   i do some operations to put the current PHPStructuredEditor instance
 and
   IDocument to two global maps(they map to each other in a thread save
   way)
   .,and remove them when the editor is disposed.
  
   so in  ISemanticHighlighting#consumes i can get the IDocument :
   IStructuredDocumentRegion sdRegion;
   IStructuredDocument parentDocument = sdRegion.getParentDocument();
  
   and then through the global map,i think i can make it. i think it is
 a
   very
   poor way!
  
  
   wei
  
   2009/4/13 Michael Spector spek...@gmail.com
  
   In this case you can do the following hack :)
  
   IStructuredDocumentRegion sdRegion;
   IStructuredDocument parentDocument = sdRegion.getParentDocument();
   IWorkbenchPage page = PHPUiPlugin.getActivePage();
   if (page != null) {
  IEditorPart editor = page.getActiveEditor();
  if (editor instanceof PHPStructuredEditor) {
  ISourceModule sourceModule = (ISourceModule)
   ((PHPStructuredEditor)
   editor).getModelElement();
  }
   }
  
   On Mon, Apr 13, 2009 at 12:22 PM, 赵忠伟 
 zhaozhong...@eclipseworld.org
   wrote:
hi, Michael
   
i extended the extension
org.eclipse.wst.sse.ui.semanticHighlighting
as following:
 extension point=org.eclipse.wst.sse.ui.semanticHighlighting
  highlighting
   
   
   
   
 class