AutoComplete values of RDFa(XML) attributes

Questions on using RText should go here.

Moderator: robert

AutoComplete values of RDFa(XML) attributes

Postby celsowm » Fri Aug 20, 2010 2:45 am

Hi ! First of all !
RText is amazing !!!

I need provide a different KeyWords list for each RDFa attribute of a tag (any tag)

RDFa attributes like "property=", "typeof=", "rel=" ...

Code: Select all
<tag typeof="MYLIST_1">
<tag property="MYLIST_2">


Thanks,
Celso.
celsowm
 
Posts: 4
Joined: Fri Aug 20, 2010 2:30 am

Re: AutoComplete values of RDFa(XML) attributes

Postby robert » Mon Aug 23, 2010 1:22 pm

Hi Celso,

Thanks for the kind words! Neither RText nor RSTALanguageSupport (the add-on library allowing for code completion of languages) supports completion for RDFa, and since it's not something I'm familiar with, it might not support it for awhile, unfortunately. If you're interested in this functionality, please add a Feature Request to RSyntaxTextArea's SourceForge page so that it is tracked and not forgotten.
User avatar
robert
 
Posts: 798
Joined: Sat May 10, 2008 5:16 pm

Re: AutoComplete values of RDFa(XML) attributes

Postby celsowm » Tue Aug 24, 2010 2:50 pm

Hi Robert !
Thanks for explanations !
But... i think that is possible (simple mode) something like this:

Code: Select all
      provider.addCompletion(new BasicCompletion(provider, "typeof='foaf:Person'"));
      provider.addCompletion(new BasicCompletion(provider, "typeof='foaf:Organization'"));
      provider.addCompletion(new BasicCompletion(provider, "typeof='foaf:Project'"));
...


Code: Select all
      provider.addCompletion(new BasicCompletion(provider, "property='foaf:account'"));
      provider.addCompletion(new BasicCompletion(provider, "property='foaf:geekcode'"));
      provider.addCompletion(new BasicCompletion(provider, "property='foaf:gender'"));
...


but if it is possible to detect the 'typeof=' and then show an autocomplete list only for him, it would be a bit prettier.
Anyway, since it was really cool!

Celso.
celsowm
 
Posts: 4
Joined: Fri Aug 20, 2010 2:30 am

Re: AutoComplete values of RDFa(XML) attributes

Postby robert » Thu Aug 26, 2010 12:39 pm

If I'm understanding you correctly, you can do something similar to what I suggest in this post, and subclass DefaultCompletionProvider to make it accept the chars =, ', and : . For example:

Code: Select all
@Override
protected boolean isValidChar(char ch) {
   return super.isValidChar(ch) || ch=='=' || ch=='\'' || ch==':';
}


DefaultCompletionProvider is designed to be simple, and usable for completion of mostly keywords and fields in languages with relatively simple syntax such as C. DefaultCompletionProvider only scans the chars just before the caret; any contiguous block of letters or '_' chars is treated as the token to complete. This is done in its isValidChar(char) method. If you'd like to include other characters, such as '=', you can subclass DefaultCompletionProvider and override isValidChar(char) to also accept that character.

Hope this helps!
User avatar
robert
 
Posts: 798
Joined: Sat May 10, 2008 5:16 pm

Re: AutoComplete values of RDFa(XML) attributes

Postby celsowm » Thu Aug 26, 2010 6:30 pm

a ultimate question:

How do you make the "Intelligent attribute completion" http://fifesoft.com/blog/?p=146 ? Something special?

Very Thanks,
Celso.
celsowm
 
Posts: 4
Joined: Fri Aug 20, 2010 2:30 am

Re: AutoComplete values of RDFa(XML) attributes

Postby robert » Sat Aug 28, 2010 8:34 pm

You can take a look at the implementation of HTML, Java, PHP, Perl, and C code completion in the RSTALanguageSupport add-on library for RSyntaxTextArea (Subversion repository is here). I tried to keep the code well documented, but it might be tough just diving in, trying to figure it out.

Each language's completion has a different level of complexity. The C and Unix shell completion is mostly simple keyword completion (albeit only where necessary, e.g. different completions when in code, comments, or string literals). HTML code completion is just slightly more complicated, because it determines what completion suggestions to show based on whether you're just starting a tag, or already in one, so it does some extra scanning to determine what HTML tag (if any) you're inside. The Java completion is by far the most complex, and comes with a Java parser that analyzes your code, to determine what local variables (for example) to suggest.
User avatar
robert
 
Posts: 798
Joined: Sat May 10, 2008 5:16 pm

Re: AutoComplete values of RDFa(XML) attributes

Postby celsowm » Sat Sep 04, 2010 11:53 pm

robert wrote:You can take a look at the implementation of HTML, Java, PHP, Perl, and C code completion in the RSTALanguageSupport.


How to get the .JAR of RSTALanguageSupport?
Thanks,
Celso.
celsowm
 
Posts: 4
Joined: Fri Aug 20, 2010 2:30 am

Re: AutoComplete values of RDFa(XML) attributes

Postby robert » Tue Sep 07, 2010 1:49 pm

I don't have a download for a jar just yet, because the library isn't quite ready for prime time. You can grab the source from the Subversion repository here:

http://svn.fifesoft.com/svn/RSyntaxTextArea/RSTALanguageSupport/trunk/

and compile it yourself though. Building is as simple as running an Ant file, and is described in the project's readme file.
User avatar
robert
 
Posts: 798
Joined: Sat May 10, 2008 5:16 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 2 guests

cron