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);
}
}
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"));
}
}
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);
}
}
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);
}
}
}
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);
}
Aggregations