Example usage for org.aspectj.bridge IMessage WEAVEINFO

List of usage examples for org.aspectj.bridge IMessage WEAVEINFO

Introduction

In this page you can find the example usage for org.aspectj.bridge IMessage WEAVEINFO.

Prototype

Kind WEAVEINFO

To view the source code for org.aspectj.bridge IMessage WEAVEINFO.

Click Source Link

Usage

From source file:AjcCompiler.java

License:Open Source License

/**
 * Hook into the maven logger./*from w  w w  . j  a  v  a 2 s. c  o  m*/
 */
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/>/*from ww  w .  jav a  2 s . 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:info.rubico.mock4aj.weavers.aspectj.DynamicRuntimeWeavingAdaptor.java

License:Open Source License

protected void initMessageHandler() {
    super.createMessageHandler();

    IMessageHandler messageHandler = getMessageHandler();
    // TODO Configure verbosity
    messageHandler.dontIgnore(IMessage.INFO); // VERBOSE
    messageHandler.dontIgnore(IMessage.DEBUG);
    messageHandler.dontIgnore(IMessage.WEAVEINFO);
}

From source file:org.caesarj.compiler.aspectj.CaesarMessageHandler.java

License:Open Source License

/**
 * Tells whether the given message kind should be ignored by the handler.
 */// ww  w. j  a v a 2 s  . c  o m
public boolean isIgnoring(Kind kind) {
    return kind == IMessage.INFO || kind == IMessage.WEAVEINFO || kind == IMessage.DEBUG;
}

From source file:org.cooperari.core.aspectj.AgentFacade.java

License:Apache License

/**
 * Handle weaver agent message.// ww  w .j a va  2  s . c om
 * 
 * @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 CoreBuildMessageHandler() {
    ignoring = new ArrayList<Kind>();
    ignore(IMessage.INFO);
    ignore(IMessage.WEAVEINFO);
}

From source file:org.eclipse.ajdt.internal.ui.ajde.UIMessageHandler.java

License:Open Source License

public UIMessageHandler(IProject project) {
    ignoring = new ArrayList<Kind>();

    if (!AspectJPreferences.getBooleanPrefValue(project, AspectJPreferences.OPTION_verbose)) {
        ignore(IMessage.INFO);/*  ww w.ja v  a  2 s . co m*/
    }
    if (!AspectJPreferences.getShowWeaveMessagesOption(project)) {
        ignore(IMessage.WEAVEINFO);
    }
}

From source file:org.eclipse.ajdt.internal.ui.preferences.AspectJPreferences.java

License:Open Source License

public static void setShowWeaveMessagesOption(IProject project, boolean showWeaveMessages) {
    String value = ""; //$NON-NLS-1$
    IBuildMessageHandler handler = AspectJPlugin.getDefault().getCompilerFactory()
            .getCompilerForProject(project).getMessageHandler();
    if (showWeaveMessages) {
        value = VALUE_TRUE;//from   w ww .ja  v a  2  s.co  m
        handler.dontIgnore(IMessage.WEAVEINFO);
    } else {
        value = VALUE_FALSE;
        handler.ignore(IMessage.WEAVEINFO);
    }
    if (isUsingProjectSettings(project)) {
        IScopeContext projectScope = new ProjectScope(project);
        IEclipsePreferences projectNode = projectScope.getNode(AspectJPlugin.PLUGIN_ID);
        projectNode.put(OPTION_WeaveMessages, value);
    } else {
        IPreferenceStore store = AspectJUIPlugin.getDefault().getPreferenceStore();
        store.setValue(OPTION_WeaveMessages, value);
    }
}

From source file:org.eclipse.ajdt.ui.tests.ajde.UIMessageHandlerTest.java

License:Open Source License

public void testDefaultSettingsMessagesThatAreIgnored() throws Exception {
    IProject project = createPredefinedProject("Bean Example"); //$NON-NLS-1$
    IBuildMessageHandler handler = AspectJPlugin.getDefault().getCompilerFactory()
            .getCompilerForProject(project).getMessageHandler();
    assertTrue("by default should be ignoring 'INFO' messages but " + //$NON-NLS-1$
            "are not", handler.isIgnoring(IMessage.INFO)); //$NON-NLS-1$
    assertTrue("by default should be ignoring 'WEAVEINFO' messages but " + //$NON-NLS-1$
            "are not", handler.isIgnoring(IMessage.WEAVEINFO)); //$NON-NLS-1$
}

From source file:org.eclipse.ajdt.ui.tests.ajde.UIMessageHandlerTest.java

License:Open Source License

public void testShowWeaveInfoMessagesAreNotIgnoredAfterWorkbenchPreferenceSet() throws Exception {
    IProject project = createPredefinedProject("Bean Example"); //$NON-NLS-1$
    IBuildMessageHandler handler = AspectJPlugin.getDefault().getCompilerFactory()
            .getCompilerForProject(project).getMessageHandler();

    AspectJPreferences.setShowWeaveMessagesOption(project, true);
    assertFalse("should not be ignoring 'WEAVEINFO' messages but " + //$NON-NLS-1$
            "still are", handler.isIgnoring(IMessage.WEAVEINFO)); //$NON-NLS-1$

    AspectJPreferences.setShowWeaveMessagesOption(project, false);
    assertTrue("by default should be ignoring 'WEAVEINFO' messages but " + //$NON-NLS-1$
            "are not", handler.isIgnoring(IMessage.WEAVEINFO)); //$NON-NLS-1$      
}