What happened to "src" attribute auto-completion ?

My goal is to extend the HTML auto-completion and also use an annotator for HTML editing. I know that in Demetra i can use the brand new Language.injectAnnotator API but for now i can only count with what the 5.1 API gives me.

So, to add an annotator i have to create a FileType of my own that is exactly like the HtmlFileType except for the getAnnotator() method that returns an instance of my annotator, unregister the default HtmlFileType and register my implementation. This gets the annotator working:

String[] extensions = FileTypeManager.getInstance().getAssociatedExtensions(StdFileTypes.HTML);
((FileTypeManagerEx) FileTypeManager.getInstance()).unregisterFileType(StdFileTypes.HTML);
FileTypeManager.getInstance().registerFileType(myNewFileType, extensions);



To register the auto-completion i then use:

CompletionUtil.registerCompletionData(myNewFileType, myNewCompletionData);


This works just fine except for the annoying fact that the auto-completion feature for the "src" of the "img" tag(or any other tag that has the "src" attribute) is lost. The completion of the other tags seems to be working ok.

Does anyone please have any clues to what happened ?

Thanks

Hugo

6 comments

Doesn't look like it. I'm not even registering a ReferenceProvider, just using completion data.

My guess is that the "src" attribute auto-completion is not implemented in the HtmlCompletionData class, problably because it has to access the file system to browse files. What i have to support this is:

String[] extensions = FileTypeManager.getInstance().getAssociatedExtensions(StdFileTypes.HTML);
CompletionData htmlCompletetionData = CompletionUtil.getCompletionDataByFileType(StdFileTypes.HTML);
((FileTypeManagerEx) FileTypeManager.getInstance()).unregisterFileType(StdFileTypes.HTML);
FileTypeManager.getInstance().registerFileType(myFileType, extensions);
CompletionUtil.registerCompletionData(myFileType, htmlCompletetionData);

With this code everything works fine except for the "src" attribute again. So what i need to find out is where is the "src" attribute auto-completion is implemented so that i can use it in my custom file type.

0

Hi,

Your completion data does not provide completions for references (and
src attribute value is not only case when it does not work). Most like
adding results of getVariants() invokation on reference should help.

Hugo Palma wrote:

Doesn't look like it. I'm not even registering a ReferenceProvider, just using completion data.

My guess is that the "src" attribute auto-completion is not implemented in the HtmlCompletionData class, problably because it has to access the file system to browse files. What i have to support this is:

String[] extensions = FileTypeManager.getInstance().getAssociatedExtensions(StdFileTypes.HTML);
CompletionData htmlCompletetionData = CompletionUtil.getCompletionDataByFileType(StdFileTypes.HTML);
((FileTypeManagerEx) FileTypeManager.getInstance()).unregisterFileType(StdFileTypes.HTML);
FileTypeManager.getInstance().registerFileType(myFileType, extensions);
CompletionUtil.registerCompletionData(myFileType, htmlCompletetionData);

With this code everything works fine except for the "src" attribute again. So what i need to find out is where is the "src" attribute auto-completion is implemented so that i can use it in my custom file type.



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

If the problem was with my completion data implementation the code i showed is the last post would work right ?

0

Wild guess: The HTML reference provider has a filter/does a check for the type of the file that contains the element it should provide the references for and only accepts (X)HTML. This is completely unrelated to the CompletionData. I'd try to subclass the HtmlReferenceProvider and try to make it work with your own file type.

Sascha

0

Thanks, it worked great. You're a life saver.


Cheers

Hugo

0

Please sign in to leave a comment.