Search in sources :

Example 36 with SyncMessage

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

the class LayoutRenderingIssueValidationStrategy method fixAndReportFoundIssues.

@Override
void fixAndReportFoundIssues() {
    if (myModelVersion != null) {
        String text = String.format("Using an obsolete version of the Gradle plugin (%1$s);", myModelVersion);
        text += " this can lead to layouts not rendering correctly.";
        SyncMessage message = new SyncMessage(DEFAULT_GROUP, WARNING, text);
        message.add(Arrays.asList(new FixAndroidGradlePluginVersionHyperlink(), new OpenUrlHyperlink("https://code.google.com/p/android/issues/detail?id=170841", "More Info...")));
        SyncMessages.getInstance(getProject()).report(message);
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) FixAndroidGradlePluginVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink) OpenUrlHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenUrlHyperlink)

Example 37 with SyncMessage

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

the class JdkModuleSetupStep method setUpInAndroidStudio.

@VisibleForTesting
void setUpInAndroidStudio(@NotNull Module module, @NotNull AndroidModuleModel androidModel) {
    AndroidProject androidProject = androidModel.getAndroidProject();
    String compileTarget = androidProject.getCompileTarget();
    AndroidVersion version = AndroidTargetHash.getPlatformVersion(compileTarget);
    if (version != null && version.getFeatureLevel() >= 21) {
        Sdk jdk = myIdeSdks.getJdk();
        if (jdk != null && !myJdks.isApplicableJdk(jdk, JDK_1_7)) {
            Project project = module.getProject();
            SyncMessage msg;
            String text = "compileSdkVersion " + compileTarget + " requires compiling with JDK 7 or newer.";
            VirtualFile buildFile = getGradleBuildFile(module);
            if (buildFile != null) {
                msg = reportWrongJdkError(project, text, buildFile);
            } else {
                msg = reportWrongJdkError(project, text);
            }
            SyncMessages.getInstance(project).report(msg);
            GradleSyncState.getInstance(project).getSummary().setWrongJdkFound(true);
        }
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) AndroidProject(com.android.builder.model.AndroidProject) AndroidProject(com.android.builder.model.AndroidProject) Sdk(com.intellij.openapi.projectRoots.Sdk) AndroidVersion(com.android.sdklib.AndroidVersion) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 38 with SyncMessage

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

the class SdkModuleSetupStep method showPlatformNotFoundError.

private static void showPlatformNotFoundError(@NotNull Module module, @NotNull String compileTarget) {
    String text = String.format("Module '%1$s': platform '%2$s' not found.", module.getName(), compileTarget);
    getLog().warn(text);
    SyncMessage msg = new SyncMessage(SDK_SETUP_ISSUES, ERROR, text);
    SyncMessages.getInstance(module.getProject()).report(msg);
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage)

Example 39 with SyncMessage

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessage 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 40 with SyncMessage

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

the class UnsupportedGradleReporter method report.

@Override
void report(@NotNull SyncIssue syncIssue, @NotNull Module module, @Nullable VirtualFile buildFile) {
    String text = syncIssue.getMessage();
    MessageType type = getMessageType(syncIssue);
    SyncMessage message = new SyncMessage(DEFAULT_GROUP, type, NonNavigatable.INSTANCE, text);
    String gradleVersion = syncIssue.getData();
    List<NotificationHyperlink> quickFixes = getQuickFixHyperlinks(module.getProject(), gradleVersion);
    message.add(quickFixes);
    getSyncMessages(module).report(message);
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) MessageType(com.android.tools.idea.gradle.project.sync.messages.MessageType) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Aggregations

SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)55 Module (com.intellij.openapi.module.Module)18 Project (com.intellij.openapi.project.Project)14 SyncMessagesStub (com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)12 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)11 PositionInFile (com.android.tools.idea.gradle.util.PositionInFile)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 AndroidProject (com.android.builder.model.AndroidProject)5 MessageType (com.android.tools.idea.gradle.project.sync.messages.MessageType)5 SyncMessages (com.android.tools.idea.gradle.project.sync.messages.SyncMessages)5 Sdk (com.intellij.openapi.projectRoots.Sdk)5 GradleVersion (com.android.ide.common.repository.GradleVersion)3 ProjectSubset (com.android.tools.idea.gradle.project.subset.ProjectSubset)3 ComponentVersionReader (com.android.tools.idea.gradle.project.sync.compatibility.version.ComponentVersionReader)3 ArrayList (java.util.ArrayList)3 NotNull (org.jetbrains.annotations.NotNull)3 Message (com.android.ide.common.blame.Message)2 AndroidVersion (com.android.sdklib.AndroidVersion)2 AndroidPluginVersionUpdater (com.android.tools.idea.gradle.plugin.AndroidPluginVersionUpdater)2 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2