Search in sources :

Example 11 with SyncMessage

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

the class BuildToolsTooLowReporter method report.

@Override
void report(@NotNull SyncIssue syncIssue, @NotNull Module module, @Nullable VirtualFile buildFile) {
    String minimumVersion = syncIssue.getData();
    assert minimumVersion != null;
    SyncMessage message = new SyncMessage(SyncMessage.DEFAULT_GROUP, ERROR, syncIssue.getMessage());
    List<NotificationHyperlink> quickFixes = myErrorHandler.getQuickFixHyperlinks(minimumVersion, module.getProject(), module);
    message.add(quickFixes);
    getSyncMessages(module).report(message);
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)

Example 12 with SyncMessage

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

the class JdkModuleSetupStep method reportWrongJdkError.

@NotNull
private SyncMessage reportWrongJdkError(@NotNull Project project, @NotNull String text, @NotNull VirtualFile buildFile) {
    int line = -1;
    int column = -1;
    Document document = FileDocumentManager.getInstance().getDocument(buildFile);
    if (document != null) {
        int offset = myCompileSdkVersionFinder.findOffsetIn(document.getText());
        if (offset > -1) {
            line = document.getLineNumber(offset);
            if (line > -1) {
                int lineStartOffset = document.getLineStartOffset(line);
                column = offset - lineStartOffset;
            }
        }
    }
    PositionInFile position = new PositionInFile(buildFile, line, column);
    SyncMessage msg = new SyncMessage(project, PROJECT_CONFIGURATION_SYNC_MESSAGE_GROUP, ERROR, position, text);
    List<NotificationHyperlink> quickFixes = Lists.newArrayList(myJdks.getWrongJdkQuickFixes(project));
    quickFixes.add(new OpenFileHyperlink(buildFile.getPath(), "Open build.gradle File", line, column));
    msg.add(quickFixes);
    return msg;
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) PositionInFile(com.android.tools.idea.gradle.util.PositionInFile) OpenFileHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenFileHyperlink) Document(com.intellij.openapi.editor.Document) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with SyncMessage

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

the class JdkModuleSetupStep method reportWrongJdkError.

@NotNull
private SyncMessage reportWrongJdkError(@NotNull Project project, @NotNull String text) {
    SyncMessage msg = new SyncMessage(PROJECT_CONFIGURATION_SYNC_MESSAGE_GROUP, ERROR, NonNavigatable.INSTANCE, text);
    msg.add(myJdks.getWrongJdkQuickFixes(project));
    return msg;
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with SyncMessage

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

the class UniquePathModuleValidatorStrategy method fixAndReportFoundIssues.

@Override
void fixAndReportFoundIssues() {
    Set<String> modulePaths = myModulesByPath.keySet();
    for (String modulePath : modulePaths) {
        Collection<Module> modules = myModulesByPath.get(modulePath);
        int moduleCount = modules.size();
        if (moduleCount <= 1) {
            continue;
        }
        StringBuilder msg = new StringBuilder();
        msg.append("The modules [");
        int i = 0;
        Set<String> moduleNames = Sets.newHashSet();
        for (Module module : modules) {
            if (i++ != 0) {
                msg.append(", ");
            }
            String name = module.getName();
            moduleNames.add(name);
            msg.append("'").append(name).append("'");
        }
        msg.append("] point to same directory in the file system.");
        String[] lines = { msg.toString(), "Each module has to have a unique path." };
        SyncMessage message = new SyncMessage(PROJECT_STRUCTURE_ISSUES, ERROR, lines);
        List<DataNode<ModuleData>> modulesToDisplayInDialog = Lists.newArrayList();
        Project project = getProject();
        if (ProjectSubset.getInstance(project).isFeatureEnabled()) {
            DataNode<ProjectData> projectInfo = DataNodeCaches.getInstance(project).getCachedProjectData();
            if (projectInfo != null) {
                Collection<DataNode<ModuleData>> cachedModules = findAll(projectInfo, MODULE);
                for (DataNode<ModuleData> moduleNode : cachedModules) {
                    if (moduleNames.contains(moduleNode.getData().getExternalName())) {
                        modulesToDisplayInDialog.add(moduleNode);
                    }
                }
            }
        }
        if (!modulesToDisplayInDialog.isEmpty()) {
            message.add(new AddOrRemoveModulesHyperlink());
        }
        SyncMessages.getInstance(project).report(message);
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) Project(com.intellij.openapi.project.Project) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) Module(com.intellij.openapi.module.Module) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 15 with SyncMessage

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

the class BuildTools23Rc1ValidationStrategy method fixAndReportFoundIssues.

@Override
void fixAndReportFoundIssues() {
    if (!myModules.isEmpty()) {
        sort(myModules);
        StringBuilder msg = new StringBuilder();
        // @formatter:off
        msg.append("Build Tools 23.0.0 rc1 is <b>deprecated</b>.<br>\n").append("Please update these modules to use Build Tools 23.0.0 rc2 (or newer) instead:");
        for (String module : myModules) {
            msg.append("<br>\n * ").append(module);
        }
        msg.append("<br>\n<br>\nOtherwise the project won't build. ");
        Project project = getProject();
        SyncMessage message = new SyncMessage(DEFAULT_GROUP, ERROR, msg.toString());
        SyncMessages.getInstance(project).report(message);
        GradleSyncState.getInstance(project).getSummary().setSyncErrorsFound(true);
    }
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) AndroidProject(com.android.builder.model.AndroidProject) Project(com.intellij.openapi.project.Project)

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