Search in sources :

Example 1 with NotificationCategory

use of com.intellij.openapi.externalSystem.service.notification.NotificationCategory in project android by JetBrains.

the class SyncMessages method report.

public void report(@NotNull SyncMessage message) {
    String title = message.getGroup();
    String text = join(message.getText(), "\n");
    NotificationCategory category = message.getType().convertToCategory();
    PositionInFile position = message.getPosition();
    NotificationData notification = createNotification(title, text, category, position);
    Navigatable navigatable = message.getNavigatable();
    notification.setNavigatable(navigatable);
    List<NotificationHyperlink> quickFixes = message.getQuickFixes();
    if (!quickFixes.isEmpty()) {
        updateNotification(notification, text, quickFixes);
    }
    report(notification);
}
Also used : PositionInFile(com.android.tools.idea.gradle.util.PositionInFile) NotificationCategory(com.intellij.openapi.externalSystem.service.notification.NotificationCategory) NotificationData(com.intellij.openapi.externalSystem.service.notification.NotificationData) Navigatable(com.intellij.pom.Navigatable) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 2 with NotificationCategory

use of com.intellij.openapi.externalSystem.service.notification.NotificationCategory in project android by JetBrains.

the class ExternalNdkBuildIssuesReporter method report.

@Override
void report(@NotNull SyncIssue syncIssue, @NotNull Module module, @Nullable VirtualFile buildFile) {
    String group = "External Native Build Issues";
    String nativeToolOutput = syncIssue.getData();
    if (nativeToolOutput != null) {
        SyncMessages messages = getSyncMessages(module);
        // Parse the native build tool output with the list of existing parsers.
        List<Message> compilerMessages = myBuildOutputParser.parseGradleOutput(nativeToolOutput);
        for (Message compilerMessage : compilerMessages) {
            MessageType type = MessageType.findMatching(compilerMessage.getKind());
            PositionInFile position = createPosition(compilerMessage.getSourceFilePositions());
            String text = compilerMessage.getText();
            Project project = module.getProject();
            if (type == ERROR) {
                // TODO make error handlers work with SyncMessage, instead of NotificationData.
                NotificationCategory category = type.convertToCategory();
                NotificationData notification = messages.createNotification(group, text, category, position);
                // Try to parse the error messages using the list of existing error handlers to find any potential quick-fixes.
                for (SyncErrorHandler handler : myErrorHandlers) {
                    if (handler.handleError(new ExternalSystemException(text), notification, project)) {
                        break;
                    }
                }
                messages.report(notification);
                continue;
            }
            SyncMessage message;
            if (position != null) {
                message = new SyncMessage(project, group, type, position, text);
            } else {
                message = new SyncMessage(group, type, text);
            }
            messages.report(message);
        }
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SyncMessages(com.android.tools.idea.gradle.project.sync.messages.SyncMessages) Project(com.intellij.openapi.project.Project) SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) Message(com.android.ide.common.blame.Message) ExternalSystemException(com.intellij.openapi.externalSystem.model.ExternalSystemException) SyncErrorHandler(com.android.tools.idea.gradle.project.sync.errors.SyncErrorHandler) PositionInFile(com.android.tools.idea.gradle.util.PositionInFile) MessageType(com.android.tools.idea.gradle.project.sync.messages.MessageType) NotificationCategory(com.intellij.openapi.externalSystem.service.notification.NotificationCategory) NotificationData(com.intellij.openapi.externalSystem.service.notification.NotificationData)

Aggregations

PositionInFile (com.android.tools.idea.gradle.util.PositionInFile)2 NotificationCategory (com.intellij.openapi.externalSystem.service.notification.NotificationCategory)2 NotificationData (com.intellij.openapi.externalSystem.service.notification.NotificationData)2 Message (com.android.ide.common.blame.Message)1 SyncErrorHandler (com.android.tools.idea.gradle.project.sync.errors.SyncErrorHandler)1 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)1 MessageType (com.android.tools.idea.gradle.project.sync.messages.MessageType)1 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)1 SyncMessages (com.android.tools.idea.gradle.project.sync.messages.SyncMessages)1 ExternalSystemException (com.intellij.openapi.externalSystem.model.ExternalSystemException)1 Project (com.intellij.openapi.project.Project)1 Navigatable (com.intellij.pom.Navigatable)1