No Syntax coloring when opening a file with custom editor [message #333270] |
Tue, 02 December 2008 16:14  |
Eclipse User |
|
|
|
I have been updating a custom editor (cmakeed.sourceforge.net) and all
is generally going well except I have a small stumbling block.
My editor opens files with a name of "CMakeLists.txt" and "*.cmake". I
have a few projects where I have template files with names like
CMakeLists.txt.in and Project.cmake.in.
I can right click on the file in the project explorer and select the
"Open With..." menu which brings up the list of available editors. I
select CMakeEd and an editor opens BUT I have no syntax coloring or any
other custom feature that I wrote. The issues seems to be when I hit
the "createEmptyDocument(IFile) method in the
ResourceTextFileBufferManager class.
The line:
final IDocumentSetupParticipant[] participants=
((ResourceExtensionRegistry)fRegistry).getDocumentSetupParti cipants(file);
will
return a zero length array. I am assuming because it looks at the
extension points for my custom reader (among others) and decides that
the file name does not match what is in my extension point and so
returns nothing.
So my question: How do other editors handle this? I know I have had
instances where I have opened a file like source.cpp.in as a C plus
plus file and gotten the correct coloring, highlighting and all that.
Thanks for any help
Mike Jackson
BlueQuartz Software
|
|
|
|
|
|
|
Re: No Syntax coloring when opening a file with custom editor [message #333306 is a reply to message #333302] |
Wed, 03 December 2008 14:49  |
Eclipse User |
|
|
|
On 2008-12-03 12:26:14 -0500, Daniel Megert <daniel_megert@ch.ibm.com> said:
> Mike Jackson wrote:
>> On 2008-12-03 07:08:58 -0500, Daniel Megert <daniel_megert@ch.ibm.com> said:
>>
>>> Mike Jackson wrote:
>>>> I have been updating a custom editor (cmakeed.sourceforge.net) and all
>>>> is generally going well except I have a small stumbling block.
>>>>
>>>> My editor opens files with a name of "CMakeLists.txt" and "*.cmake". I
>>>> have a few projects where I have template files with names like
>>>> CMakeLists.txt.in and Project.cmake.in.
>>>>
>>>> I can right click on the file in the project explorer and select the
>>>> "Open With..." menu which brings up the list of available editors. I
>>>> select CMakeEd and an editor opens BUT I have no syntax coloring or any
>>>> other custom feature that I wrote. The issues seems to be when I hit
>>>> the "createEmptyDocument(IFile) method in the
>>>> ResourceTextFileBufferManager class.
>>>>
>>>> The line:
>>>>
>>>> final IDocumentSetupParticipant[] participants=
>>>> ((ResourceExtensionRegistry)fRegistry).getDocumentSetupParti cipants(file);
will
return
a
>>>>
>>>> zero length array. I am assuming because it looks at the extension
>>>> points for my custom reader (among others) and decides that the file
>>>> name does not match what is in my extension point and so returns
>>>> nothing.
>>>>
>>>> So my question: How do other editors handle this? I know I have had
>>>> instances where I have opened a file like source.cpp.in as a C plus
>>>> plus file and gotten the correct coloring, highlighting and all that.
>>> Do something like that:
>>>
>>> IDocumentProvider provider= new TextFileDocumentProvider();
>>> provider= new ForwardingDocumentProvider(yourPartitioning, new
>>> YourDocumentSetupParticipant(), provider);
>>> setParentDocumentProvider(provider);
>>>
>>> Dani
>>>>
>>>> Thanks for any help
>>>> Mike Jackson
>>>> BlueQuartz Software
>>
>> Awesome.. Thanks.. But I am still a bit "wet behind the ears" with this
>> so just _where_ would I put this code?
> This needs to be in the constructor of your own document provider.
>
> Dani
Got it!!. In the constructor for CMakeEditor I put the following:
IDocumentProvider provider= new TextFileDocumentProvider();
provider= new
ForwardingDocumentProvider(UIPlugin.CMAKE_PARTITIONING, new
CMakeDocumentSetupParticipant(), provider);
setDocumentProvider(provider);
And now things work as hoped/expected. THANKS!!.
Mike
|
|
|
Powered by
FUDForum. Page generated in 0.02926 seconds