• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Xcode 3.2 fails to highlight errors in Java source
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode 3.2 fails to highlight errors in Java source


  • Subject: Re: Xcode 3.2 fails to highlight errors in Java source
  • From: "Pelaia II, Tom" <email@hidden>
  • Date: Thu, 03 Sep 2009 10:58:01 -0400
  • Acceptlanguage: en-US
  • Thread-topic: Xcode 3.2 fails to highlight errors in Java source

Hi Michael and Greg,

Following Greg's good advice, I have generated an awk script that eliminates the need to have a separate file such as the sed script. The entire script is self contained in the xant script. I have pasted the lines below which includes documentation on the script.

Also, this script is more accurate than the sed script since it tests that the line number is preceded by a java source path.

This is just a workaround for a bug. I really hope Apple fixes this bug!

Thanks to Michael for raising this issue and to Greg for his good advice and patch to my previous script.

thanks,
tom

#!/bin/bash

# This script is a workaround for the missing "error:" tag needed by Xcode to identify
# errors and create a link back to the associated source.
# Ant generates error and warning lines by specifying the source file path followed by
# a colon, the line number and another colon and the warning or error message.
# Error messages need to begin with "error:" and warnings need to begin with "warning:"
# for Xcode to properly identify errors and warnings.
# The "error:" tag is missing in the output from the current version of ant 1.7.0.
# As a workaround, we pipe ant to an awk script that parses lines that don't have warnings,
# locates the line number at the end of the java file path and inserts the "error: " tag.

# Steps:
# pipe ant output to awk
# ignore warning lines identified as a java file followed by a colon, line number and another colon and the warning tag
# look for a match of a java file followed by a colon, line number and another colon as this indicates an error line
# if there is a match, print the line up to the end of the match, append the "error:" tag and append the remainder of the original line
# if there is no match then simply print the original line
# for warning lines, simply print the original line

# Execute the ant command and perform the substitution.
ant "$@" | awk \
'($0 !~ /\.java:[0-9]+: warning:/) {
loc = match($0,/\.java:[0-9]+:/);
if(loc) print substr($0,0,RSTART+RLENGTH-1), "error:", substr($0,RSTART+RLENGTH);
else print $0;
}
($0 ~ /\.java:[0-9]+: warning:/) { print $0; }'



On Sep 3, 2009, at 9:08 AM, Michael Ellis wrote:


Hi Greg.

I was just about to work on Tom's script when I discovered you had
fixed it already.  Thanks!

I have now configured my "/usr/bin" directory to contain the following:
1) rwxr-xr-x     1 root   wheel          26 Sep  3 08:51 ant -> ant-
fix-error-reporting.sh
2) lrwxr-xr-x     1 root   wheel          22 Aug 24 14:34 ant-1.7.0 -
/usr/share/ant/bin/ant
3) -rwxr-xr-x     1 root   wheel         213 Sep  3 08:51 ant-fix-
error-reporting.sh
4) -rw-r--r--     1 root   wheel          44 Sep  2 15:25 ant-fix-
errorsub.sed

Where:
#1 : "/usr/bin/ant" has been replaced with a symlink to the same
script as the "xant" script provided below.
#2 : The original "ant" symlink has been renamed to "ant-1.7.0" to
move it out of the way.
#3 : "ant-fix-error-reporting.sh" is my name for the "xant" script
provided below.
#4 : "ant-fix-errorsub.sed" is my name for the "errorsub.sed" script
originally given by Tom (see below)

Now when you invoke "ant" from the command line, you're really
invoking "ant-fix-error-reporting.sh", which in turn, corrects the
error reporting format from ANT.  Because this change globally
corrects output from ANT, errors now show up propertly in Xcode for
all ANT projects.

It would be nice if, in the future, this error reporting issue was
addressed by Apple.  I can think of two ways:
Fix #1: Enhance Xcode 3.2 to interpret ANT's output similar to the way
this sed script does.
- OR -
Fix #2: With the developer tools, possibly bundle a newer version of
ANT that emits correctly formatted output for errors (if the current
ANT version does not fix the error output, submit a patch that does
fix it).

Even still, I think we have a good interim solution here.

Thanks to all involved.

Regards,
Mike Ellis


On Sep 2, 2009, at 9:53 PM, email@hidden<mailto:email@hidden> wrote:

Pelaia II, Tom wrote:

xant:
#!/bin/bash

# get the root directory of this script
root_dir=${0%/*}
echo $root_dir

# execute the ant command and perform the substitution
ant $* | sed -f $root_dir/errorsub.sed

errorsub.sed:
/: warning:/! {
s/\(:[0-9]*:\)/\1 error:/
}

Thanks for doing the investigation and script, Tom.  Fixes for 'xant'
follow:

#!/bin/bash

# get the root directory of this script
root_dir="${0%/*}"
echo "$root_dir"

# execute the ant command and perform the substitution
ant "$@" | sed -f "$root_dir/errorsub.sed"


FWIW, there's probably an 'awk' or 'perl' script that would work with
only command-line args, instead of needing a separate 'sed' script.
I'm not enough of an awker or perlite to whip one up without
RTFM'ing, though.

 -- GG


=========================
Michael F. Ellis
President
Ellis Softworks Inc.
----------
Phone:  (941) 713-0361
Email: email@hidden<mailto:email@hidden>




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Xcode 3.2 fails to highlight errors in Java source (From: Michael Ellis <email@hidden>)

  • Prev by Date: Re: How to file a bug in Rez tool for Intel processor?
  • Next by Date: Interface Builder changes, release notes?
  • Previous by thread: Re: Xcode 3.2 fails to highlight errors in Java source
  • Next by thread: Problem with NSFileManager
  • Index(es):
    • Date
    • Thread