Author Topic: PL/SQL tagging  (Read 2505 times)

rod_gomz

  • Community Member
  • Posts: 80
  • Hero Points: 1
PL/SQL tagging
« on: February 18, 2010, 04:10:07 pm »
So I'm looking at the PLSQL.e file and I made my own language and made new changes i.e.:

Code: [Select]
_str plsqlrodrigo2_proc_search(_str &proc_name,int find_first)
{
 
   _str symbol_after_body='';
   _str symbol_after_package_decleration='';

   typeless status=0;
   if ( find_first ) {
     

      word_chars := _clex_identifier_chars();
      _str variable_re='(['word_chars'.]#)';
      _str re='{#1(procedure|function|trigger|cursor|package)}[\n \t]+{#0'variable_re'}';
         //_mdi.p_child.insert_line(re);
      mark_option := (p_EmbeddedLexerName != '')? 'm':'';
      status=search(re,'w:phri'mark_option'@xcs');
      if ( status==0 ) {
         if (lowcase(get_match_text(0))=='body') {
           
            re='{#1(procedure|function|trigger|cursor|package)}[\n \t]+body[\n \t]+{#0'variable_re'}';
           
            status=search(re,'w:phri'mark_option'@xcs');
            if (status==0) {
               symbol_after_body = lowcase(get_match_text(0));
            }
           
         }else{
            _str line;
            get_line(line);
            if (pos('[\n \t]+package[\n \t]+',line,1,'R')>0) {
               symbol_after_package_decleration = lowcase(get_match_text(0));
            }

         }

          re='{#1(procedure|function|trigger|cursor|package)}[\n \t]+{#0'variable_re'}';
         status=search(re,'w:phri'mark_option'@xcs');
      }

   } else {
      status=repeat_search();
   }

   _str the_package;
   _str the_class;
   _str type="";
   _str name="";
   _str line="";
   _str first_word="";
   _str keyword="";
   //_str classname="";
   typeless orig_pos;
   save_pos(orig_pos);
   for (;;) {
      if ( status ) {
         restore_pos(orig_pos);
         break;
      }
      if (symbol_after_body!='') {
         name=symbol_after_body;
      }
      else if (symbol_after_package_decleration!='') {

         name=symbol_after_package_decleration;
      }
      else{
         name=get_match_text(0);
      }
      keyword=get_match_text(1);
      if (lowcase(keyword)=='cursor') {
         type='cursor)';
      } else {
         // Check if this is a prototype or procedure definition
         if (_isProtoType()) {
            type='proto)';
         } else {
            type='func)';
         }
      }
      get_line(line);
      parse line with first_word .;
      if (lowcase(first_word)=='drop' || lowcase(name)=='for') {
         status=repeat_search();
         continue;
      }
      if (symbol_after_body!='' || symbol_after_package_decleration !='') {
         parse name with the_package'.'the_class;
         if (the_class=='') {
            the_class=the_package;
         }
         name='('the_package'/'the_class')(class)';
         //name=name'(class)';

         //_mdi.p_child.insert_line(name);
         //name=name'(class)';
      }else{
         name= name'('the_package'/'the_class':' type;
      }
      if (proc_name:=='') {
         proc_name=name;
         return(0);
      }
      if (proc_name==name) {
         return(0);
      }
      status=repeat_search();
   }
   return(status);

}

However, there stills alot todo according:
http://blog.slickedit.com/2008/05/tutorial-adding-language-support-to-slickedit/

I believe there is no full tagging support or something is amiss since when I do search for a tag:

Code: [Select]
create or replace package body apackage.mypackage is
When I put my cursor in the word mypackage and I search for references it says: "Tag 'mypackage' not found, search for references anyway?". But if I search by copying the the whole tag "apackage.mypackage" and putting it in the references little window it doesn't complain. So it seems that a tag is considering everything: apackage.mypackage, schema and all but the editor only consider part of the name, i.e. mypackage.

If I have some time, I'll add more support of PL/SQL. I would like to block match code like this:
Code: [Select]
if a is null then
end if;

If my cursor is in the if i like to match and go to the end if and back and forth.

Also the current tagging support is missing member variables i.e.
Code: [Select]
create or replace package body apackage.mypackage is
subtype VARCHAR2s       is my_app.Varchar2s;
CLIENT constant pls_integer := 0;
NULLABLE                constant boolean := true;
end BULK_ENROLLMENT_UTIL#002;

Otherwise, I think the PL/SQL support is decent.

I'm only inquiring about pl/sql and are motivate for pl/sql since I do have alot with plsql, and maybe not by design, because my company has alot of code in plsql, of course in java as well. And even though i use IntelliJ idea, slick is much better in working with *ALL* of the code and not just java, in addition to loading huge files, for data loading, etc...

Rodrigo Gomez


rod_gomz

  • Community Member
  • Posts: 80
  • Hero Points: 1
Re: PL/SQL tagging
« Reply #1 on: February 19, 2010, 01:14:29 am »
Actually there is block matching support for "if end if" if the cursor sits in the if or end if. However, I often try to jump from the then.

rod_gomz

  • Community Member
  • Posts: 80
  • Hero Points: 1
Re: PL/SQL tagging
« Reply #2 on: February 19, 2010, 01:16:57 am »
Adding support to jump from the "then" was easy!

just added this:

if (word == "if" || word=="then")

Easy!