aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.ajdt.core
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2021-03-20 10:24:57 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2021-03-20 10:24:57 +0700
commit31b2d60b897d318bfbffde2d78dbc288f85db191 (patch)
treeb31e667d37e23dcb6ec0ffe7efac2348c0672df2 /org.aspectj.ajdt.core
parente51c43b9e3970aab098a8d17c1057f660732a584 (diff)
downloadaspectj-31b2d60b897d318bfbffde2d78dbc288f85db191.tar.gz
aspectj-31b2d60b897d318bfbffde2d78dbc288f85db191.zip
Improve usage text, error and warning output in batch compiler
- Usage texts are now printed to stdOut, no longer stdErr. - 'java ...Main -?' no longer prints usage text twice (once to stdOut and then again to stdErr). - AjdtCommand.inferKind: Usage texts are no longer mis-identified as warnings or errors just because they contain substrings "warning" or "error". Matching is now more precise, looking for "[warning]" and "[error]". But in that case the method would not be called anyway because errors and warnings are identified in other ways already. As a fall-back, the categories IMessage.ERROR and IMessage.WARNING still exist in the method. - In case of compile errors, no usage message is printed anymore, because previously the user had to scroll up a lot in order to see the actual messages. This is also in line with ECJ. The same is true for warnings, but it was like this in Ajc already. - AjdtCommand.inferKind: There is a new category IMessage.USAGE especially for AspectJ usage texts, which will be identified by string matching and then correctly handled (i.e. printed to stdOut, not stdErr). - Usage text printing is no longer done in AspectJ but in the AspectJ "shadows" fork of JDT. This helps to get rid of some now obsolete code here. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'org.aspectj.ajdt.core')
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java40
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java6
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java2
3 files changed, 21 insertions, 27 deletions
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java
index 7fa4e9c36..36168343f 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/AjdtCommand.java
@@ -44,19 +44,6 @@ public class AjdtCommand implements ICommand {
buildManager = new AjBuildManager(handler);
savedArgs = new String[args.length];
System.arraycopy(args, 0, savedArgs, 0, savedArgs.length);
- for (String arg : args) {
-// AMC - PR58681. No need to abort on -help as the Eclipse compiler does the right thing.
-// if ("-help".equals(args[i])) {
-// // should be info, but handler usually suppresses
-// MessageUtil.abort(handler, BuildArgParser.getUsage());
-// return true;
-// } else
- if ("-X".equals(arg)) {
- // should be info, but handler usually suppresses
- MessageUtil.abort(handler, BuildArgParser.getXOptionUsage());
- return true;
- }
- }
return doCommand(handler, false);
}
@@ -103,9 +90,11 @@ public class AjdtCommand implements ICommand {
if (!config.hasSources()) {
MessageUtil.error(counter, "no sources specified");
}
- if (counter.hasErrors()) { // print usage for config errors
- String usage = BuildArgParser.getUsage();
- MessageUtil.abort(handler, usage);
+ if (counter.hasErrors()) {
+ // Do *not* print usage for config errors (just like ECJ does it). Otherwise the user would have to
+ // scroll up several screens in order to actually see the error messages.
+ // String usage = BuildArgParser.getUsage();
+ // MessageUtil.abort(handler, usage);
return false;
}
//System.err.println("errs: " + counter.hasErrors());
@@ -166,14 +155,23 @@ public class AjdtCommand implements ICommand {
return config;
}
- /** @return IMessage.WARNING unless message contains error or info */
+ /**
+ * Heuristically infer the type of output message logged by the AspectJ compiler. This is a simple keyword matcher
+ * looking for substrings like "[error]", "[warning]", "AspectJ-specific options:", "AspectJ-specific non-standard
+ * options:"
+ *
+ * @param message AspectJ compiler message
+ * @return inferred message kind, either of ERROR, WARNING, USAGE, INFO
+ */
protected static IMessage.Kind inferKind(String message) { // XXX dubious
- if (message.contains("error")) {
+ if (message.contains("[error]")) {
return IMessage.ERROR;
- } else if (message.contains("info")) {
- return IMessage.INFO;
- } else {
+ } else if (message.contains("[warning]")) {
return IMessage.WARNING;
+ } else if (message.contains("AspectJ-specific options:") || message.contains("AspectJ-specific non-standard options:")) {
+ return IMessage.USAGE;
+ } else {
+ return IMessage.INFO;
}
}
}
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java
index c120e0293..e078ba7fb 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java
@@ -314,12 +314,6 @@ public class BuildArgParser extends Main {
super.initializeAnnotationProcessorManager();
}
- @Override
- public void printUsage() {
- System.out.println(getUsage());
- System.out.flush();
- }
-
/**
* Get messages not dumped to handler or any PrintWriter.
*
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java
index 4b15f0333..81ec01a42 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/tools/ajc/Main.java
@@ -640,6 +640,8 @@ public class Main {
return System.err;
} else if (verbose && IMessage.INFO.equals(kind)) {
return System.out;
+ } else if (IMessage.USAGE.equals(kind)) {
+ return System.out;
} else if (IMessage.WEAVEINFO.equals(kind)) {
return System.out;
} else {