use of com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink in project android by JetBrains.
the class AndroidGradlePluginVersionReader method getQuickFixes.
@Override
@NotNull
public List<NotificationHyperlink> getQuickFixes(@NotNull Module module, @Nullable VersionRange expectedVersion, @Nullable PositionInFile location) {
AndroidPluginInfo pluginInfo = AndroidPluginInfo.find(module.getProject());
if (isSupportedGeneration(pluginInfo)) {
String version = pluginInfo.getPluginGeneration().getLatestKnownVersion();
List<NotificationHyperlink> quickFixes = new ArrayList<>();
quickFixes.add(new FixAndroidGradlePluginVersionHyperlink(GradleVersion.parse(version), GradleVersion.parse(GRADLE_LATEST_VERSION)));
quickFixes.add(new OpenUrlHyperlink("https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle", "Open Documentation"));
return quickFixes;
}
return emptyList();
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink in project android by JetBrains.
the class GradleVersionReaderTest method testGetQuickFixes.
public void testGetQuickFixes() throws Exception {
loadSimpleApplication();
Module appModule = myModules.getAppModule();
List<NotificationHyperlink> quickFixes = myVersionReader.getQuickFixes(appModule, null, null);
assertThat(quickFixes).hasSize(2);
NotificationHyperlink quickFix = quickFixes.get(0);
assertThat(quickFix).isInstanceOf(FixAndroidGradlePluginVersionHyperlink.class);
FixAndroidGradlePluginVersionHyperlink fixAndroidGradlePluginQuickFix = (FixAndroidGradlePluginVersionHyperlink) quickFix;
assertEquals(BuildEnvironment.getInstance().getGradlePluginVersion(), fixAndroidGradlePluginQuickFix.getPluginVersion().toString());
GradleVersion gradleVersion = fixAndroidGradlePluginQuickFix.getGradleVersion();
assertNotNull(gradleVersion);
assertEquals(GRADLE_LATEST_VERSION, gradleVersion.toString());
quickFix = quickFixes.get(1);
assertThat(quickFix).isInstanceOf(OpenUrlHyperlink.class);
OpenUrlHyperlink openUrlQuickFix = (OpenUrlHyperlink) quickFix;
assertEquals("https://developer.android.com/studio/releases/index.html#Revisions", openUrlQuickFix.getUrl());
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink in project android by JetBrains.
the class AndroidGradleExperimentalPluginVersionReaderTest method testGetQuickFixesWithExperimentalPlugin.
public void testGetQuickFixesWithExperimentalPlugin() throws Exception {
loadProject(EXPERIMENTAL_PLUGIN);
Module appModule = myModules.getAppModule();
List<NotificationHyperlink> quickFixes = myVersionReader.getQuickFixes(appModule, VersionRange.parse("[0.7.0, +)"), null);
assertThat(quickFixes).hasSize(2);
NotificationHyperlink quickFix = quickFixes.get(0);
assertThat(quickFix).isInstanceOf(FixAndroidGradlePluginVersionHyperlink.class);
FixAndroidGradlePluginVersionHyperlink fixAndroidGradlePluginQuickFix = (FixAndroidGradlePluginVersionHyperlink) quickFix;
assertEquals(BuildEnvironment.getInstance().getExperimentalPluginVersion(), fixAndroidGradlePluginQuickFix.getPluginVersion().toString());
quickFix = quickFixes.get(1);
assertThat(quickFix).isInstanceOf(OpenUrlHyperlink.class);
OpenUrlHyperlink openUrlQuickFix = (OpenUrlHyperlink) quickFix;
assertEquals("https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle", openUrlQuickFix.getUrl());
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink in project android by JetBrains.
the class GradleRenderErrorContributor method reportIssue170841.
private void reportIssue170841(RenderLogger logger, AndroidFacet facet) {
Map<String, Throwable> brokenClasses = logger.getBrokenClasses();
if (brokenClasses == null || brokenClasses.isEmpty() || facet == null) {
return;
}
AndroidModuleModel model = AndroidModuleModel.get(facet);
if (model == null || !model.getFeatures().isLayoutRenderingIssuePresent()) {
return;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
FixAndroidGradlePluginVersionHyperlink quickFix = new FixAndroidGradlePluginVersionHyperlink(GradleVersion.parse(GRADLE_PLUGIN_RECOMMENDED_VERSION), null);
quickFix.executeIfClicked(facet.getModule().getProject(), new HyperlinkEvent(this, HyperlinkEvent.EventType.ACTIVATED, null, quickFix.getUrl()));
}
};
HtmlBuilder builder = new HtmlBuilder();
HtmlLinkManager linkManager = logger.getLinkManager();
builder.add("Tip: Either ").addLink("update the Gradle plugin build version to 1.2.3", linkManager.createRunnableLink(runnable)).add(" or later, or downgrade to version 1.1.3, or as a workaround, ");
builder.beginList().listItem().addLink("", "Build the project", ", then", linkManager.createBuildProjectUrl()).listItem().addLink("", "Gradle Sync the project", ", then", linkManager.createSyncProjectUrl()).listItem().addLink("Manually ", "refresh the layout", " (or restart the IDE)", linkManager.createRefreshRenderUrl()).endList();
builder.newline();
GradleVersion modelVersion = model.getModelVersion();
addIssue().setSeverity(HighlightSeverity.ERROR).setSummary("Using an obsolete version of the Gradle plugin (" + modelVersion + "); " + "this can lead to layouts not rendering correctly.").setHtmlContent(builder).build();
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink 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);
}
}
Aggregations