I implemented a little plugin to extend content assistance and
validation for HTML files. Everything works fine so far: I extended
StructuredTextViewerConfigurationHTML and returned my own
ContentAssistProcessor.

However, the possible proposals are dependent on some project specific
properties (at least in some cases). I understand how to store these
properties on the project resource, but I don't know how to get to the
IProject resource from my ContentAssistProcessor. In
IContentAssistProcessor.computeCompletionProposals there is a
ITextViewer object and in my
StructuredTextViewerConfiguration.getContentAssistProcessors a
ISourceViewer object as parameter, but I don't see a way to get to the
project resource from there. Can anybody help?

Dominik Raymann wrote:
> Hi there,
>
> I implemented a little plugin to extend content assistance and
> validation for HTML files. Everything works fine so far: I extended
> StructuredTextViewerConfigurationHTML and returned my own
> ContentAssistProcessor.
>
> However, the possible proposals are dependent on some project specific
> properties (at least in some cases). I understand how to store these
> properties on the project resource, but I don't know how to get to the
> IProject resource from my ContentAssistProcessor. In
> IContentAssistProcessor.computeCompletionProposals there is a
> ITextViewer object and in my
> StructuredTextViewerConfiguration.getContentAssistProcessors a
> ISourceViewer object as parameter, but I don't see a way to get to the
> project resource from there. Can anybody help?

I suspect you need to access it through the bundle getWorkspace()
method, and then get then check the appropriate project. You might also
be able to get the project from the IDocument for the particular file or
the EditorPart.

David Carver schrieb:
> Dominik Raymann wrote:
>> Hi there,
>>
>> I implemented a little plugin to extend content assistance and
>> validation for HTML files. Everything works fine so far: I extended
>> StructuredTextViewerConfigurationHTML and returned my own
>> ContentAssistProcessor.
>>
>> However, the possible proposals are dependent on some project specific
>> properties (at least in some cases). I understand how to store these
>> properties on the project resource, but I don't know how to get to the
>> IProject resource from my ContentAssistProcessor. In
>> IContentAssistProcessor.computeCompletionProposals there is a
>> ITextViewer object and in my
>> StructuredTextViewerConfiguration.getContentAssistProcessors a
>> ISourceViewer object as parameter, but I don't see a way to get to the
>> project resource from there. Can anybody help?
>
> I suspect you need to access it through the bundle getWorkspace()
> method, and then get then check the appropriate project. You might also
> be able to get the project from the IDocument for the particular file or
> the EditorPart.
>
> Dave

Thanks for your answer. However, I don't see how I can access my bundle
from my ContentAssistProcessor (or my validator). Do I have to pass a
reference to it somehow? Could you give an example?

I also don't know how to get to the project from the IDocument as a
starting point. Does anybody have an example? I think this should be a
quite common problem, shouldn't it?

Just in case anybody has found this thread while googling for an answer
to a question similar to mine:

I found a way to get the actual file of a IDocument (if there is an
associated WST model). I can't remember where I found the code, I think
it's from a Spring Plugin. You can easily get the project afterwards by
calling the getProject() method of the file afterwards. I don't know
whether it is the best way, but it seems to work. So here we go:

Dominik Raymann schrieb:
> David Carver schrieb:
>> Dominik Raymann wrote:
>>> Hi there,
>>>
>>> I implemented a little plugin to extend content assistance and
>>> validation for HTML files. Everything works fine so far: I extended
>>> StructuredTextViewerConfigurationHTML and returned my own
>>> ContentAssistProcessor.
>>>
>>> However, the possible proposals are dependent on some project specific
>>> properties (at least in some cases). I understand how to store these
>>> properties on the project resource, but I don't know how to get to the
>>> IProject resource from my ContentAssistProcessor. In
>>> IContentAssistProcessor.computeCompletionProposals there is a
>>> ITextViewer object and in my
>>> StructuredTextViewerConfiguration.getContentAssistProcessors a
>>> ISourceViewer object as parameter, but I don't see a way to get to the
>>> project resource from there. Can anybody help?
>>
>> I suspect you need to access it through the bundle getWorkspace()
>> method, and then get then check the appropriate project. You might
>> also be able to get the project from the IDocument for the particular
>> file or the EditorPart.
>>
>> Dave
>
> Thanks for your answer. However, I don't see how I can access my bundle
> from my ContentAssistProcessor (or my validator). Do I have to pass a
> reference to it somehow? Could you give an example?
>
> I also don't know how to get to the project from the IDocument as a
> starting point. Does anybody have an example? I think this should be a
> quite common problem, shouldn't it?
>
> Dominik