[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [pdt-dev] can i get ISourceModule from IStructuredDocumentRegion

and document to ISourceModule map seems better.lol

2009/4/13 赵忠伟 <zhaozhongwei@xxxxxxxxxxxxxxxx>
actually,one map to store document to editor relation is enough.
 
Michael ,i want some advices from you .thank you!

2009/4/13 赵忠伟 <zhaozhongwei@xxxxxxxxxxxxxxxx>

thank you for your patient!
 
best regards!

2009/4/13 Michael Spector <spektom@xxxxxxxxx>
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 <spektom@xxxxxxxxx>:
> 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, 赵忠伟 <zhaozhongwei@xxxxxxxxxxxxxxxx> 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@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/pdt-dev
>>
>>
>
>
>
> --
> Best regards,
> Michael
>



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