Search in sources :

Example 1 with SyncMessages

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessages in project android by JetBrains.

the class JavaModuleSetup method setUpModule.

public void setUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull JavaModuleModel javaModuleModel, @Nullable SyncAction.ModuleModels models, @Nullable ProgressIndicator indicator) {
    if (javaModuleModel.isAndroidModuleWithoutVariants()) {
        // See https://code.google.com/p/android/issues/detail?id=170722
        SyncMessages messages = SyncMessages.getInstance(module.getProject());
        String[] text = { String.format("The module '%1$s' is an Android project without build variants, and cannot be built.", module.getName()), "Please fix the module's configuration in the build.gradle file and sync the project again." };
        messages.report(new SyncMessage(PROJECT_STRUCTURE_ISSUES, ERROR, text));
        cleanUpAndroidModuleWithoutVariants(module, ideModelsProvider);
        // happen due to a project configuration error and there is a lot of module configuration missing, there is no point on even trying.
        return;
    }
    for (JavaModuleSetupStep step : mySetupSteps) {
        if (indicator != null) {
            step.displayDescription(module, indicator);
        }
        step.setUpModule(module, ideModelsProvider, javaModuleModel, models, indicator);
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SyncMessages(com.android.tools.idea.gradle.project.sync.messages.SyncMessages)

Example 2 with SyncMessages

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessages in project android by JetBrains.

the class ExtraGeneratedFolderValidationStrategy method fixAndReportFoundIssues.

@Override
void fixAndReportFoundIssues() {
    if (!myExtraGeneratedSourceFolderPaths.isEmpty()) {
        SyncMessages messages = SyncMessages.getInstance(getProject());
        Collections.sort(myExtraGeneratedSourceFolderPaths);
        // Warn users that there are generated source folders at the wrong location.
        for (File folder : myExtraGeneratedSourceFolderPaths) {
            // Have to add a word before the path, otherwise IDEA won't show it.
            String[] text = { "Folder " + folder.getPath() };
            messages.report(new SyncMessage(GENERATED_SOURCES, WARNING, text));
        }
        messages.report(new SyncMessage(GENERATED_SOURCES, INFO, "3rd-party Gradle plug-ins may be the cause"));
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SyncMessages(com.android.tools.idea.gradle.project.sync.messages.SyncMessages) File(java.io.File)

Example 3 with SyncMessages

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessages in project android by JetBrains.

the class MissingPlatformsSetupStep method setUpProject.

@Override
public void setUpProject(@NotNull Project project, @Nullable ProgressIndicator indicator) {
    SyncMessages syncMessages = SyncMessages.getInstance(project);
    int sdkErrorCount = syncMessages.getMessageCount(SDK_SETUP_ISSUES);
    if (sdkErrorCount > 0) {
        // If we have errors due to platforms not being installed, we add an extra message that prompts user to open Android SDK manager and
        // install any missing platforms.
        String text = "Open Android SDK Manager and install all missing platforms.";
        SyncMessage hint = new SyncMessage(SDK_SETUP_ISSUES, INFO, NonNavigatable.INSTANCE, text);
        hint.add(new OpenAndroidSdkManagerHyperlink());
        syncMessages.report(hint);
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SyncMessages(com.android.tools.idea.gradle.project.sync.messages.SyncMessages) OpenAndroidSdkManagerHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink)

Example 4 with SyncMessages

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessages 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)

Example 5 with SyncMessages

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessages in project android by JetBrains.

the class ConflictSet method showSelectionConflicts.

/**
   * Shows the "variant selection" conflicts in the "Build Variant" and "Messages" windows.
   */
public void showSelectionConflicts() {
    SyncMessages messages = SyncMessages.getInstance(myProject);
    String groupName = VARIANT_SELECTION_CONFLICTS;
    messages.removeMessages(groupName);
    for (Conflict conflict : mySelectionConflicts) {
        // Creates the "Select in 'Build Variants' window" hyperlink.
        Module source = conflict.getSource();
        String hyperlinkText = String.format("Select '%1$s' in \"Build Variants\" window", source.getName());
        NotificationHyperlink selectInBuildVariantsWindowHyperlink = new NotificationHyperlink("select.conflict.in.variants.window", hyperlinkText) {

            @Override
            protected void execute(@NotNull Project project) {
                BuildVariantView.getInstance(project).findAndSelect(source);
            }
        };
        // Creates the "Fix problem" hyperlink.
        NotificationHyperlink quickFixHyperlink = new NotificationHyperlink("fix.conflict", "Fix problem") {

            @Override
            protected void execute(@NotNull Project project) {
                boolean solved = solveSelectionConflict(conflict);
                if (solved) {
                    ConflictSet conflicts = findConflicts(project);
                    conflicts.showSelectionConflicts();
                }
            }
        };
        SyncMessage msg = new SyncMessage(groupName, MessageType.WARNING, conflict.toString());
        msg.add(selectInBuildVariantsWindowHyperlink);
        msg.add(quickFixHyperlink);
        messages.report(msg);
    }
    BuildVariantView.getInstance(myProject).updateContents(mySelectionConflicts);
}
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) ConflictResolution.solveSelectionConflict(com.android.tools.idea.gradle.variant.conflict.ConflictResolution.solveSelectionConflict) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Aggregations

SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)5 SyncMessages (com.android.tools.idea.gradle.project.sync.messages.SyncMessages)5 Project (com.intellij.openapi.project.Project)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 OpenAndroidSdkManagerHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.OpenAndroidSdkManagerHyperlink)1 MessageType (com.android.tools.idea.gradle.project.sync.messages.MessageType)1 PositionInFile (com.android.tools.idea.gradle.util.PositionInFile)1 ConflictResolution.solveSelectionConflict (com.android.tools.idea.gradle.variant.conflict.ConflictResolution.solveSelectionConflict)1 ExternalSystemException (com.intellij.openapi.externalSystem.model.ExternalSystemException)1 NotificationCategory (com.intellij.openapi.externalSystem.service.notification.NotificationCategory)1 NotificationData (com.intellij.openapi.externalSystem.service.notification.NotificationData)1 Module (com.intellij.openapi.module.Module)1 File (java.io.File)1 NotNull (org.jetbrains.annotations.NotNull)1