Author Topic: compile javac externally then testing for errors  (Read 6047 times)

sbusch

  • Community Member
  • Posts: 27
  • Hero Points: 0
compile javac externally then testing for errors
« on: January 11, 2007, 10:09:08 pm »
Tech support was good enough to start me with being able to do a javac (Windows/MKS toolkit) from the command line and then being able to find the errors in se. For example:
javac *.java > /tmp/tmp/proj.err
if [ $? -eq 0 ]; then
  break; # no errors
else
  vs.exe "-#javaErr $PWD"
fi

Acknowledging that this is much harder to do using a .bat file, what's really relevant that I want to process the errors in se. The macro code is below. Attached is the setup for JavaParse.

Finally my questions:
1. project_userTool() opens up the build window, which is great. However, it doesn't clear out the errors from the previous compile. Is there a way to clear the errors out?

2. cd1(path) does not change directories sufficiently to let se know where the java files are

Thanks for any help.

Steve
--------------------------
_command void javaErr(_str arg1='') name_info(',' VSARG2_REQUIRES_MDI_EDITORCTL|VSARG2_READ_ONLY|VSARG2_ICON)
{
   cd1(arg1);
   project_usertool("JavaParse");
   next_error();
}

_command void cd1(_str arg1='') name_info(',' VSARG2_REQUIRES_MDI_EDITORCTL|VSARG2_READ_ONLY|VSARG2_ICON)
{
   cd(arg1, 'm');
   _cd_tbopen();
  _process_cd(arg1);
}
« Last Edit: January 11, 2007, 10:11:09 pm by sbusch »

hs2

  • Senior Community Member
  • Posts: 2738
  • Hero Points: 288
Re: compile javac externally then testing for errors
« Reply #1 on: January 12, 2007, 10:02:18 am »
@sbusch:
You can try the patched macro below.
I didn't try it by myself, but at least clear_pbuffer () is needed to clear the Build window).
Code: [Select]
_command void javaErr(_str arg1='') name_info(',' VSARG2_REQUIRES_MDI_EDITORCTL|VSARG2_READ_ONLY|VSARG2_ICON)
{
   cd1(arg1);

   // clear process buffer
   clear_pbuffer ();
   // maybe this is also useful
   clear_all_error_markers();
   
   project_usertool("JavaParse");
   next_error();
}

Hope it works/helps,

HS2

sbusch

  • Community Member
  • Posts: 27
  • Hero Points: 0
Re: compile javac externally then testing for errors
« Reply #2 on: January 12, 2007, 01:10:21 pm »
As Mr. Burns would say: Excellent! Now, I'm pushing the envelope here, but is there a way of closing the build window if the compile is in fact successful?

Thanks again.

hs2

  • Senior Community Member
  • Posts: 2738
  • Hero Points: 288
Re: compile javac externally then testing for errors
« Reply #3 on: January 12, 2007, 02:46:20 pm »
You could this snippet in your javaErr:
Code: [Select]
_command void javaErr(_str arg1='') name_info(',' VSARG2_REQUIRES_MDI_EDITORCTL|VSARG2_READ_ONLY|VSARG2_ICON)
{
   cd1(arg1);

   // clear process buffer
   clear_pbuffer ();
   // maybe this is also useful
   clear_all_error_markers();
   
   project_usertool("JavaParse");

   // error parse result
   if ( next_error () )
   {
      // no error detected ...
      // stop/exit build shell
      exit_process();

      // some bells and whistles ...
      // clear all output / markers
      clear_pbuffer ();
      clear_all_error_markers();
     
      // switch focus to edit win
      cursor_data();
      // and signal success
      _beep ();
   }
}

or simply:
Code: [Select]
if [ $? -eq 0 ]; then
  vs.exe "-#exit-process"  # no errors
instead of
   break; # no errors

HS2

sbusch

  • Community Member
  • Posts: 27
  • Hero Points: 0
Re: compile javac externally then testing for errors
« Reply #4 on: January 12, 2007, 02:58:41 pm »
I like your 2nd approach better. However, it appears that exit_process does not close the build window (I ran it from se's command line). (This is a very trivial issue, but what-the-heck, I sit in front of an editor all day, so I'm down to little things)

Thanks again.

hs2

  • Senior Community Member
  • Posts: 2738
  • Hero Points: 288
Re: compile javac externally then testing for errors
« Reply #5 on: January 12, 2007, 03:24:32 pm »
If you want to (auto-)hide the 'Build' window this could help:

Code: [Select]
_command void exit_close_process ()
{
   exit_process ();
   tbHide ( "_tbshell_form" );
}

and

Code: [Select]
if [ $? -eq 0 ]; then
  vs.exe "-#exit-close-process"  # no errors

HS2

sbusch

  • Community Member
  • Posts: 27
  • Hero Points: 0
Re: compile javac externally then testing for errors
« Reply #6 on: January 12, 2007, 04:01:37 pm »
Works like a charm! Now I'm really really really pushing it: If SE is resident, then the code below does *not* change *all* the directory buffers, specifically, the GUI File>Open, and File>Change Directory. Any thoughts on how I can accomplish this? My intention is to navigate/changes directories using my DOS/Unix shell rather than SE. This is one of the few cases were it's really easier not to use SE for navigation.

Thanks again.

   cd(arg1, 'm');
   _cd_tbopen();
  _process_cd(arg1);

Steve
PS I was the lucky 1000th registered member of the SlickEdit Community Forum (I get a goody bag). It's people like HS2 that make life so much easier for all of us.

hs2

  • Senior Community Member
  • Posts: 2738
  • Hero Points: 288
Re: compile javac externally then testing for errors
« Reply #7 on: January 12, 2007, 05:49:14 pm »
This is unfortunately not working :(
It's the same issue you mentioned earlier in this thread: http://community.slickedit.com/index.php?topic=798.msg3491#msg3491
I also made a few tests, but w/ no luck using the Slick way...

You can try this nasty hack to achieve the sync'd cd:
VsCmd.exe "cd $PWD"
to feed a cmdline to SE from an external shell script

VsCmd.exe assumes 1 (resident) SE instance and just:
1. activates SE window if existing
2. simulates 'ESC' to goto cmdline (no other dialog should be active)
3. simulates typing of SHIFT-HOME + 'cmdline>' text + ENTER
    to mark poss. existing cmdline text, overtype it with <cmdline> and hit ENTER to execute it.

The ultimate (freeware) tool to do that (and much, much more) is Autohotkey http://www.autohotkey.com
See attached the ahk source and the compiled (there is a script compiler bundled with Autohotkey) executable:
Syntax: VsCmd.exe <cmdline> (just invoke it w/o parameter to get a 'syntax' pop-up)

HS2

PS: Congrats being the 1000th community member !

sbusch

  • Community Member
  • Posts: 27
  • Hero Points: 0
Re: compile javac externally then testing for errors
« Reply #8 on: January 12, 2007, 06:01:37 pm »
Thanks again for your help. I'll definitely take your suggestions (you haven't let me down yet ...).

Steve