Search in sources :

Example 1 with VersionRange

use of com.android.tools.idea.gradle.project.sync.compatibility.version.VersionRange in project android by JetBrains.

the class VersionIncompatibility method reportMessages.

void reportMessages(@NotNull Project project) {
    ComponentVersionReader reader = myReaderAndVersion.getFirst();
    String componentName = reader.getComponentName();
    String version = myReaderAndVersion.getSecond();
    String requirementComponentName = myRequirementVersionReader.getComponentName();
    StringBuilder msg = new StringBuilder();
    msg.append(componentName).append(" ").append(version);
    PositionInFile position = reader.getVersionSource(myModule);
    if (!reader.isProjectLevel() && position == null) {
        msg.append(", in module '").append(myModule.getName()).append(",'");
    }
    msg.append(" requires ").append(requirementComponentName).append(" ");
    VersionRange requirementVersionRange = myRequirement.getVersionRange();
    msg.append(requirementVersionRange.getDescription());
    int messageCount = myMessages.size();
    if (messageCount == 1) {
        msg.append(" ").append(myMessages.get(0));
    } else if (messageCount > 1) {
        msg.append("<ul>");
        for (String message : myMessages) {
            msg.append("<li>").append(message).append("</li>");
        }
        msg.append("</ul>");
    }
    MessageType messageType = myCompatibilityCheck.getType();
    SyncMessage message;
    List<String> textLines = new ArrayList<>();
    textLines.add(msg.toString());
    String failureMsg = myRequirement.getFailureMessage();
    if (failureMsg != null) {
        List<String> lines = Splitter.on("\\n").omitEmptyStrings().splitToList(failureMsg);
        textLines.addAll(lines);
    }
    String[] text = toStringArray(textLines);
    if (position != null) {
        message = new SyncMessage(project, DEFAULT_GROUP, messageType, position, text);
    } else {
        message = new SyncMessage(DEFAULT_GROUP, messageType, text);
    }
    message.add(myRequirementVersionReader.getQuickFixes(myModule, requirementVersionRange, position));
    SyncMessages.getInstance(project).report(message);
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) ArrayList(java.util.ArrayList) PositionInFile(com.android.tools.idea.gradle.util.PositionInFile) VersionRange(com.android.tools.idea.gradle.project.sync.compatibility.version.VersionRange) ComponentVersionReader(com.android.tools.idea.gradle.project.sync.compatibility.version.ComponentVersionReader) MessageType(com.android.tools.idea.gradle.project.sync.messages.MessageType)

Aggregations

ComponentVersionReader (com.android.tools.idea.gradle.project.sync.compatibility.version.ComponentVersionReader)1 VersionRange (com.android.tools.idea.gradle.project.sync.compatibility.version.VersionRange)1 MessageType (com.android.tools.idea.gradle.project.sync.messages.MessageType)1 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)1 PositionInFile (com.android.tools.idea.gradle.util.PositionInFile)1 ArrayList (java.util.ArrayList)1