}
taskListManager.addSourcelineTask(message);
- return true;
+ return true;// return super.handleMessage(message); // also store...
}
private boolean handleAbort(IMessage abortMessage) {
public static void setDontReport() {
reporting = false;
dumpDeltaProcessing=false;
+ dumpModel=false;
+ dumpRelationships=false;
}
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
+import org.aspectj.weaver.LintMessage;
/**
* @author colyer
if (message.getDeclared()) {
details.append("[deow=true]");
}
+ if (message instanceof LintMessage) {
+ String lintMessageName = ((LintMessage)message).getLintKind();
+ details.append("[Xlint:").append(lintMessageName).append("]");
+ }
if (details.length()!=0) {
problem.setSupplementaryMessageInfo(details.toString());
}
state.setWeaver(bcelWeaver);
state.clearBinarySourceFiles();
+ if (buildConfig.getLintMode().equals(AjBuildConfig.AJLINT_DEFAULT)) {
+ bcelWorld.getLint().loadDefaultProperties();
+ } else {
+ bcelWorld.getLint().setAll(buildConfig.getLintMode());
+ }
+ if (buildConfig.getLintSpecFile() != null) {
+ bcelWorld.getLint().setFromProperties(buildConfig.getLintSpecFile());
+ }
+
for (Iterator i = buildConfig.getAspectpath().iterator(); i.hasNext();) {
File f = (File) i.next();
if (!f.exists()) {
// String lintMode = buildConfig.getLintMode();
- if (buildConfig.getLintMode().equals(AjBuildConfig.AJLINT_DEFAULT)) {
- bcelWorld.getLint().loadDefaultProperties();
- } else {
- bcelWorld.getLint().setAll(buildConfig.getLintMode());
- }
- if (buildConfig.getLintSpecFile() != null) {
- bcelWorld.getLint().setFromProperties(buildConfig.getLintSpecFile());
- }
//??? incremental issues
for (Iterator i = buildConfig.getInJars().iterator(); i.hasNext(); ) {
IProblem[] problems = unitResult.getAllProblems();
for (int i=0; i < problems.length; i++) {
IMessage message =
- EclipseAdapterUtils.makeMessage(unitResult.compilationUnit, problems[i]);
+ EclipseAdapterUtils.makeMessage(unitResult.compilationUnit, problems[i],getBcelWorld());
handler.handleMessage(message);
}
}
import org.aspectj.bridge.SourceLocation;
import org.aspectj.org.eclipse.jdt.core.compiler.IProblem;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.aspectj.weaver.LintMessage;
+import org.aspectj.weaver.World;
-/**
- *
- */
public class EclipseAdapterUtils {
//XXX some cut-and-paste from eclipse sources
/**
* Extract message text and source location, including context.
+ * @param world
*/
- public static IMessage makeMessage(ICompilationUnit unit, IProblem problem) {
+ public static IMessage makeMessage(ICompilationUnit unit, IProblem problem, World world) {
ISourceLocation sourceLocation = makeSourceLocation(unit, problem);
IProblem[] seeAlso = problem.seeAlso();
ISourceLocation[] seeAlsoLocations = new ISourceLocation[seeAlso.length];
// in the extraDetails.
String extraDetails = problem.getSupplementaryMessageInfo();
boolean declared = false;
+ boolean isLintMessage = false;
+ String lintkey = null;
if (extraDetails!=null && extraDetails.endsWith("[deow=true]")) {
declared = true;
extraDetails = extraDetails.substring(0,extraDetails.length()-"[deow=true]".length());
}
+ if (extraDetails!=null && extraDetails.indexOf("[Xlint:")!=-1) {
+ isLintMessage = true;
+ lintkey = extraDetails.substring(extraDetails.indexOf("[Xlint:"));
+ lintkey = lintkey.substring("[Xlint:".length());
+ lintkey = lintkey.substring(0,lintkey.indexOf("]"));
+ }
// If the 'problem' represents a TO DO kind of thing then use the message kind that
// represents this so AJDT sees it correctly.
if (problem.isError()) { kind = IMessage.ERROR; }
else { kind = IMessage.WARNING; }
}
- IMessage msg = new Message(problem.getMessage(),
+ IMessage msg = null;
+ if (isLintMessage) {
+ msg = new LintMessage(
+ problem.getMessage(),
+ extraDetails,
+ world.getLint().fromKey(lintkey),
+ kind,
+ sourceLocation,
+ null,
+ seeAlsoLocations,
+ declared,
+ problem.getID(),
+ problem.getSourceStart(),problem.getSourceEnd());
+ } else {
+ msg = new Message(problem.getMessage(),
extraDetails,
kind,
sourceLocation,
declared,
problem.getID(),
problem.getSourceStart(),problem.getSourceEnd());
- return msg;
+ }
+ return msg;
}
public static IMessage makeErrorMessage(ICompilationUnit unit, String text, Exception ex) {
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.IMessageHolder;
import org.aspectj.tools.ajc.Ajc;
-import org.aspectj.weaver.Lint.LintMessage;
+import org.aspectj.weaver.LintMessage;
/**
* The superclass knows all about talking through Ajde to the compiler.
public void testPr133117() {
+// System.gc();
+// System.exit();
configureNonStandardCompileOptions("-Xlint:warning");
initialiseProject("PR133117");
build("PR133117");
configureBuildStructureModel(false);
}
-// public void testDontLoseXlintWarnings_pr141556() {
-// configureNonStandardCompileOptions("-Xlint:warning");
-// initialiseProject("PR141556");
-// build("PR141556");
-// checkWasFullBuild();
-// String warningMessage = "can not build thisJoinPoint " +
-// "lazily for this advice since it has no suitable guard " +
-// "[Xlint:noGuardForLazyTjp]";
-// assertEquals("warning message should be '" + warningMessage + "'",
-// warningMessage,
-// ((IMessage)MyTaskListManager.getWarningMessages().get(0))
-// .getMessage());
-//
-// // add a space to the Aspect but dont do a build
-// alter("PR141556","inc1");
-// // remove the space so that the Aspect is exactly as it was
-// alter("PR141556","inc2");
-// // build the project and we should not have lost the xlint warning
-// build("PR141556");
-// checkWasntFullBuild();
-// assertTrue("there should still be a warning message ",
-// !MyTaskListManager.getWarningMessages().isEmpty());
-// assertEquals("warning message should be '" + warningMessage + "'",
-// warningMessage,
-// ((IMessage)MyTaskListManager.getWarningMessages().get(0))
-// .getMessage());
-// }
+ public void testDontLoseXlintWarnings_pr141556() {
+ configureNonStandardCompileOptions("-Xlint:warning");
+ initialiseProject("PR141556");
+ build("PR141556");
+ checkWasFullBuild();
+ String warningMessage = "can not build thisJoinPoint " +
+ "lazily for this advice since it has no suitable guard " +
+ "[Xlint:noGuardForLazyTjp]";
+ assertEquals("warning message should be '" + warningMessage + "'",
+ warningMessage,
+ ((IMessage)MyTaskListManager.getWarningMessages().get(0))
+ .getMessage());
+
+ // add a space to the Aspect but dont do a build
+ alter("PR141556","inc1");
+ // remove the space so that the Aspect is exactly as it was
+ alter("PR141556","inc2");
+ // build the project and we should not have lost the xlint warning
+ build("PR141556");
+ checkWasntFullBuild();
+ assertTrue("there should still be a warning message ",
+ !MyTaskListManager.getWarningMessages().isEmpty());
+ assertEquals("warning message should be '" + warningMessage + "'",
+ warningMessage,
+ ((IMessage)MyTaskListManager.getWarningMessages().get(0))
+ .getMessage());
+ }
public void testLintMessage_pr141564() {
configureNonStandardCompileOptions("-Xlint:warning");
msg instanceof LintMessage);
assertTrue("expected message to be noGuardForLazyTjp xlint message but" +
" instead was " + ((LintMessage)msg).getKind().toString(),
- ((LintMessage)msg).isNoGuardForLazyTjp());
+ ((LintMessage)msg).getLintKind().equals("noGuardForLazyTjp"));
+
assertTrue("expected message to be against file in project 'PR141556' but wasn't",
msg.getSourceLocation().getSourceFile().getAbsolutePath().indexOf("PR141556") != -1);
}
pr="41181">
<compile files="ClinitTest.java, Util.java"/>
<run class="ClinitTest"/>
- <compile files="ClinitTest.java, Util.java, TJP.aj" options="-Xlint:warning"/>
+ <compile files="ClinitTest.java, Util.java, TJP.aj" options="-Xlint:warning">
+ <message kind="warning" line="24" text="can not build"/>
+ <message kind="warning" line="31" text="can not build"/>
+ </compile>
<run class="Util" options="-read"/>
</ajc-test>
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
-import org.aspectj.bridge.Message;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.weaver.tools.Trace;
import org.aspectj.weaver.tools.TraceFactory;
WeaverMessages.format(WeaverMessages.XLINT_VALUE_ERROR,v));
return null;
}
-
-
+
+ public Kind fromKey(String lintkey) {
+ return (Lint.Kind)kinds.get(lintkey);
+ }
public class Kind {
private String name;
public void signal(String[] infos, ISourceLocation location, ISourceLocation[] extraLocations) {
if (kind == null) return;
- String text = MessageFormat.format(message, infos );
+ String text = MessageFormat.format(message, (Object[])infos );
text += " [Xlint:" + name + "]";
world.getMessageHandler().handleMessage(
new LintMessage(text, kind, location,extraLocations,getLintKind(name)));
}
- }
-
- public class LintMessage extends Message {
-
- private Lint.Kind lintKind;
-
- public LintMessage(
- String message,
- IMessage.Kind messageKind,
- ISourceLocation location,
- ISourceLocation[] extraLocations,
- Lint.Kind lintKind) {
- super(message,"",messageKind,location,null,extraLocations);
- this.lintKind = lintKind;
- }
-
- /**
- * @return Returns the Lint kind of this message
- */
- public Lint.Kind getLintKind() {
- return lintKind;
- }
-
- /**
- * @return true if this message is a noGuardForLazyTjp xlint
- * message and false otherwise
- */
- public boolean isNoGuardForLazyTjp() {
- return lintKind.equals(noGuardForLazyTjp);
- }
+
}
}
--- /dev/null
+/* *******************************************************************
+ * Copyright (c) 2002-2006 Contributors
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * PARC initial implementation
+ * AndyClement extracted as self contained type from Lint type (4-Aug-06)
+ * ******************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.bridge.Message;
+
+public class LintMessage extends Message {
+
+ // private Lint.Kind lintKind;
+ private String lintKind;
+
+ public LintMessage(
+ String message,
+ IMessage.Kind messageKind,
+ ISourceLocation location,
+ ISourceLocation[] extraLocations,
+ Lint.Kind lintKind) {
+ super(message,"",messageKind,location,null,extraLocations);
+ this.lintKind = lintKind.getName();
+ }
+
+ public LintMessage(String message, String extraDetails, org.aspectj.weaver.Lint.Kind kind2, Kind kind, ISourceLocation sourceLocation, Throwable object,
+ ISourceLocation[] seeAlsoLocations, boolean declared, int id, int sourceStart, int sourceEnd) {
+ super(message,extraDetails,kind,sourceLocation,object,seeAlsoLocations,declared,id,sourceStart,sourceEnd);
+ this.lintKind = kind2.getName();
+ }
+
+ /**
+ * @return Returns the Lint kind of this message
+ */
+ public String getLintKind() {
+ return lintKind;
+ }
+
+}
\ No newline at end of file
private ExposedState exposedState;
private boolean hasMatchedAtLeastOnce = false;
- private boolean hasReportedNoGuardForLazyTJP = false;
public BcelAdvice(
AjAttribute.AdviceAttribute attribute,
suppressLintWarnings(world);
ShadowMunger ret = super.concretize(fromType, world, clause);
clearLintSuppressions(world,this.suppressedLintKinds);
+ IfFinder ifinder = new IfFinder();
+ ret.getPointcut().accept(ifinder,null);
+ boolean hasGuardTest = ifinder.hasIf && getKind() != AdviceKind.Around;
+ boolean isAround = getKind() == AdviceKind.Around;
+ if ((getExtraParameterFlags() & ThisJoinPoint) != 0) {
+ if (!isAround && !hasGuardTest && world.getLint().noGuardForLazyTjp.isEnabled()) {
+ // can't build tjp lazily, no suitable test...
+ // ... only want to record it once against the advice(bug 133117)
+ world.getLint().noGuardForLazyTjp.signal("",getSourceLocation());
+ }
+ }
return ret;
}
// collect up the problematic advice
((BcelShadow)shadow).addAdvicePreventingLazyTjp(this);
}
- if (!hasReportedNoGuardForLazyTJP && !isAround && !hasGuardTest && world.getLint().noGuardForLazyTjp.isEnabled()) {
- // can't build tjp lazily, no suitable test...
- // ... only want to record it once against the advice(bug 133117)
- world.getLint().noGuardForLazyTjp.signal(
- "",
- getSourceLocation()
- );
- hasReportedNoGuardForLazyTJP = true;
- }
}
if ((getExtraParameterFlags() & ThisEnclosingJoinPointStaticPart) != 0) {