fix for java annotation handling
James Ahlborn <[email protected]> Wed, 13 Nov 2019 15:02:44 -0500
| Newsgroups | gmane.comp.gnu.global.bugs |
|---|---|
| Message-ID | <CAHTTz9k0Rc_LmOsqkUoqBhAg5Gt0eeRDya4-VRc8BvN3CGkMNw@mail.gmail.com> |
hey, i decided to take a pass at fixing the issues with java annotations. the attached patch seems to work for me.
java_c.patch
(application/octet-stream, 1.8 KB)
--- global-6.6.3.orig/libparser/java.c 2018-12-16 21:54:33.000000000 -0500
+++ global-6.6.3/libparser/java.c 2019-11-13 14:32:44.000000000 -0500
@@ -8,12 +8,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -53,7 +53,7 @@
char *terminate;
int level;
} stack[MAXCLASSSTACK];
- const char *interested = "{}=;";
+ const char *interested = "{}=;@";
*classname = *completename = 0;
stack[0].classname = completename;
@@ -155,6 +155,24 @@
if (peekc(1) == '.' && (c = nexttoken(interested, java_reserved_word)) != JAVA_CLASS)
pushbacktoken();
break;
+ case '@':
+ // skip through annotations
+ if (nexttoken(interested, java_reserved_word) == SYMBOL) {
+ if(peekc(0) == '(') {
+ int paren_count = 0;
+ int in_annot = 1;
+ while(in_annot) {
+ c = nexttoken("()", java_reserved_word);
+ if(c == '(') {
+ ++paren_count;
+ } else if(c == ')') {
+ --paren_count;
+ in_annot = (paren_count > 0);
+ }
+ }
+ }
+ }
+ break;
default:
break;
}