List of usage examples for org.aspectj.bridge IMessage getMessage
String getMessage();
From source file:AjcCompiler.java
License:Open Source License
/** * Hook into the maven logger./* ww w .jav a2 s . c om*/ */ public boolean handleMessage(IMessage message) { if (message.getKind().equals(IMessage.WARNING) && !isIgnoring(IMessage.WARNING)) log.warning(message.getMessage()); else if (message.getKind().equals(IMessage.DEBUG) && !isIgnoring(IMessage.DEBUG)) log.fine(message.getMessage()); else if (message.getKind().equals(IMessage.ERROR) && !isIgnoring(IMessage.ERROR)) log.severe(message.getMessage()); else if (message.getKind().equals(IMessage.ABORT) && !isIgnoring(IMessage.ABORT)) log.severe(message.getMessage()); else if (message.getKind().equals(IMessage.FAIL) && !isIgnoring(IMessage.FAIL)) log.severe(message.getMessage()); else if (message.getKind().equals(IMessage.INFO) && !isIgnoring(IMessage.INFO)) log.fine(message.getMessage()); else if (message.getKind().equals(IMessage.WEAVEINFO) && !isIgnoring(IMessage.WEAVEINFO)) log.info(message.getMessage()); else if (message.getKind().equals(IMessage.TASKTAG) && !isIgnoring(IMessage.TASKTAG)) log.fine(message.getMessage()); return super.handleMessage(message); }
From source file:de.zalando.mojo.aspectj.MavenMessageHandler.java
License:Open Source License
/** * Copies output from the supplied message onto the active Maven Log. * If the message type (i.e. {@code message.getKind()}) is listed in the showDetailsForMessageKindList List, * the message is prefixed with location details (Class, row/line number etc.) as well. * <p/>// w w w . j ava2s . c o m * {@inheritDoc} */ public boolean handleMessage(final IMessage message) { // Compose the message text final StringBuilder builder = new StringBuilder(message.getMessage()); if (isMessageDetailDesired(message)) { // // The AJC details are typically delivered on the format [fileName]:[lineNumber] // (i.e. /src/main/java/Clazz.java:16). // // Mimic this, and include the context of the message as well, // including guarding against NPEs. // final ISourceLocation sourceLocation = message.getSourceLocation(); final String sourceFile = sourceLocation == null || sourceLocation.getSourceFile() == null ? "<unknown source file>" : sourceLocation.getSourceFile().getAbsolutePath(); final String context = sourceLocation == null || sourceLocation.getContext() == null ? "" : sourceLocation.getContext() + "\n"; final String line = sourceLocation == null ? "<no line information>" : "" + sourceLocation.getLine(); builder.append("\n\t").append(sourceFile).append(":").append(line).append("\n").append(context); } final String messageText = builder.toString(); if (isNotIgnored(message, IMessage.DEBUG) || isNotIgnored(message, IMessage.INFO) || isNotIgnored(message, IMessage.TASKTAG)) { // The DEBUG, INFO, and TASKTAG ajc message kinds are considered Maven Debug messages. log.debug(messageText); } else if (isNotIgnored(message, IMessage.WEAVEINFO)) { // The WEAVEINFO ajc message kind is considered Maven Info messages. log.info(messageText); } else if (isNotIgnored(message, IMessage.WARNING)) { // The WARNING ajc message kind is considered Maven Warn messages. log.warn(messageText); } else if (isNotIgnored(message, IMessage.ERROR) || isNotIgnored(message, IMessage.ABORT) || isNotIgnored(message, IMessage.FAIL)) { // We map ERROR, ABORT, and FAIL ajc message kinds to Maven Error messages. log.error(messageText); } // Delegate to normal handling. return super.handleMessage(message); }
From source file:org.caesarj.compiler.aspectj.CaesarMessageHandler.java
License:Open Source License
/** * Handles the (AspectJ) message, by creating a KOPI-error and report it to * the compiler.//from w w w .j a v a 2s. c o m */ public boolean handleMessage(IMessage message) throws AbortException { if (isIgnoring(message.getKind())) { return true; } ISourceLocation location = message.getSourceLocation(); if (message.getKind() == IMessage.WARNING) { if (location != null) { compiler.get() .reportTrouble(new CWarning( new TokenReference(location.getSourceFile().getPath(), location.getSourceFile(), location.getLine()), new Message(CaesarMessages.ASPECTJ_WARNING, message.getMessage()))); } else { compiler.get().reportTrouble(new CWarning(TokenReference.NO_REF, new Message(CaesarMessages.ASPECTJ_WARNING, message.getMessage()))); } return true; } if (location != null) { compiler.get() .reportTrouble(new PositionedError( new TokenReference(location.getSourceFile().getPath(), location.getSourceFile(), location.getLine()), new Message(CaesarMessages.ASPECTJ_ERROR, message.getMessage()))); } else { compiler.get().reportTrouble(new PositionedError(TokenReference.NO_REF, new Message(CaesarMessages.ASPECTJ_ERROR, message.getMessage()))); } return true; }
From source file:org.cooperari.core.aspectj.AgentFacade.java
License:Apache License
/** * Handle weaver agent message.//from ww w.ja v a 2s. c o m * * @param msg Message object. */ void handleMessage(IMessage msg) { if (CWorkspace.INSTANCE.isInitialized()) { if (_agentLog == null) { try { _agentLog = CWorkspace.INSTANCE.createLog(".", LOG_ID, CLog.Option.OMMIT_THREAD_INFO); } catch (Throwable e) { _agentLog = CLog.SYSTEM_OUT; } } _agentLog.message(msg.toString()); } if (msg.getKind() == IMessage.WEAVEINFO) { try { Matcher matcher = WI_MSG_PATTERN.matcher(msg.getMessage()); if (matcher.find()) { String kind = matcher.group(1); String desc = matcher.group(2); String signature; if (kind.equals(JoinPoint.SYNCHRONIZATION_LOCK)) { signature = CYieldPoint.MONITOR_ENTER_SIGNATURE; } else if (kind.equals(JoinPoint.SYNCHRONIZATION_UNLOCK)) { signature = CYieldPoint.MONITOR_EXIT_SIGNATURE; } else if (kind.equals(JoinPoint.METHOD_CALL)) { signature = uniformize(desc); } else { signature = kind + "(" + uniformize(desc) + ")"; } if (_ignoreSet.contains(signature)) { return; } String fileInfo = matcher.group(3); int lineInfo = Integer.parseInt(matcher.group(4)); CYieldPointImpl yp = new CYieldPointImpl(signature, fileInfo, lineInfo); synchronized (this) { _globalCoverageLog.recordDefinition(yp); } } } catch (Throwable e) { handleError(e); } } // else { // // } }
From source file:org.eclipse.ajdt.internal.core.ajde.CoreBuildMessageHandler.java
License:Open Source License
public boolean handleMessage(IMessage message) { if (!USE_LOG) { return true; }//from w ww . ja v a 2 s. c o m IMessage.Kind kind = message.getKind(); if (kind.equals(IMessage.ABORT)) { AJLog.log(AJLog.COMPILER, "AJC: Compiler error: " + message.getMessage()); //$NON-NLS-1$ message.getThrown().printStackTrace(); } if (isIgnoring(kind)) { return true; } AJLog.log(AJLog.COMPILER, "AJC: " + message); //$NON-NLS-1$ return true; }
From source file:org.eclipse.ajdt.internal.ui.ajde.UIMessageHandler.java
License:Open Source License
public boolean handleMessage(IMessage message) { IMessage.Kind kind = message.getKind(); if (kind == IMessage.ABORT || message.getThrown() != null) { // an exception has been thrown by AspectJ, therefore // want to create an error dialog containing the information // and display it to the user AJDTErrorHandler.handleInternalError(UIMessages.ajErrorDialogTitle, message.getMessage(), message.getThrown());/*from w w w . j a va 2 s . co m*/ return true; } if (isIgnoring(kind)) { return true; } if (message.getSourceLocation() == null) { AJLog.log(AJLog.COMPILER_MESSAGES, message.getMessage()); //$NON-NLS-1$ problems.add(new ProblemTracker(message.getMessage(), null, message.getKind())); } else { if (DebugTracing.DEBUG_COMPILER_MESSAGES) { // avoid constructing log string if trace is not active AJLog.log(AJLog.COMPILER_MESSAGES, "addSourcelineTask message=" //$NON-NLS-1$ + message.getMessage() + " file=" //$NON-NLS-1$ + message.getSourceLocation().getSourceFile().getPath() + " line=" //$NON-NLS-1$ + message.getSourceLocation().getLine()); } else { AJLog.log(AJLog.COMPILER_MESSAGES, message.getMessage()); } problems.add(new ProblemTracker(message.getMessage(), message.getSourceLocation(), message.getKind(), message.getDeclared(), message.getExtraSourceLocations(), message.getID(), message.getSourceStart(), message.getSourceEnd(), message.getThrown())); } return true; }
From source file:org.springframework.aop.aspectj.AspectJWeaverMessageHandler.java
License:Apache License
private String makeMessageFor(IMessage aMessage) { return AJ_ID + aMessage.getMessage(); }