use of com.android.tools.idea.gradle.project.sync.messages.MessageType 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);
}
use of com.android.tools.idea.gradle.project.sync.messages.MessageType in project android by JetBrains.
the class DependencySetupErrors method reportModulesNotFoundIssues.
private void reportModulesNotFoundIssues(@NotNull List<MissingModule> missingModules) {
if (!missingModules.isEmpty()) {
MessageType type = ERROR;
for (MissingModule missingModule : missingModules) {
List<String> messageLines = new ArrayList<>();
StringBuilder text = new StringBuilder();
text.append(String.format("Unable to find module with Gradle path '%1$s' (needed by module", missingModule.dependencyPath));
addDependentsToText(text, missingModule.dependentNames);
text.append(".)");
messageLines.add(text.toString());
String backupLibraryName = missingModule.backupLibraryName;
if (isNotEmpty(backupLibraryName)) {
type = WARNING;
String msg = String.format("Linking to library '%1$s' instead.", backupLibraryName);
messageLines.add(msg);
}
mySyncMessages.report(new SyncMessage(MISSING_DEPENDENCIES, type, toStringArray(messageLines)));
}
// If the project is really a subset of the project, attempt to find and include missing modules.
ProjectSubset projectSubset = ProjectSubset.getInstance(myProject);
String[] selection = projectSubset.getSelection();
boolean hasSelection = selection != null && selection.length > 0;
if (type == ERROR && hasSelection && projectSubset.hasCachedModules()) {
String text = "The missing modules may have been excluded from the project subset.";
SyncMessage message = new SyncMessage(MISSING_DEPENDENCIES, MessageType.INFO, text);
message.add(new IncludeMissingModulesHyperlink(missingModules));
mySyncMessages.report(message);
}
}
}
use of com.android.tools.idea.gradle.project.sync.messages.MessageType 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);
}
}
}
use of com.android.tools.idea.gradle.project.sync.messages.MessageType 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);
}
use of com.android.tools.idea.gradle.project.sync.messages.MessageType in project android by JetBrains.
the class UnhandledIssuesReporter method report.
@Override
void report(@NotNull SyncIssue syncIssue, @NotNull Module module, @Nullable VirtualFile buildFile) {
String group = DEFAULT_GROUP;
String text = syncIssue.getMessage();
MessageType type = getMessageType(syncIssue);
SyncMessage message;
if (buildFile != null) {
PositionInFile position = new PositionInFile(buildFile);
message = new SyncMessage(module.getProject(), group, type, position, text);
} else {
message = new SyncMessage(group, type, NonNavigatable.INSTANCE, text);
}
getSyncMessages(module).report(message);
}
Aggregations