use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class GenericErrorHandler method getQuickFixHyperlinks.
@NotNull
private List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull String text) {
List<NotificationHyperlink> hyperlinks = new ArrayList<>();
List<String> message = Splitter.on('\n').omitEmptyStrings().trimResults().splitToList(text);
String lastLine = message.get(message.size() - 1);
if (lastLine != null) {
Pair<String, Integer> errorLocation = getErrorLocation(lastLine);
if (errorLocation != null) {
String filePath = errorLocation.getFirst();
int line = errorLocation.getSecond();
hyperlinks.add(new OpenFileHyperlink(filePath, line - 1));
return hyperlinks;
}
}
// Error messages may contain a file path and line number, but we need to add a hyperlink to open the file at those coordinates.
String filePath = notification.getFilePath();
if (isNotEmpty(filePath)) {
// lines are zero based.
int lineIndex = notification.getLine() - 1;
int column = notification.getColumn();
hyperlinks.add(new OpenFileHyperlink(filePath, "Open File", lineIndex, column));
}
return hyperlinks;
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class Gradle2RequiredErrorHandler method getQuickFixHyperlinks.
@Override
@NotNull
protected List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
List<NotificationHyperlink> hyperlinks = new ArrayList<>();
hyperlinks.add(new CreateGradleWrapperHyperlink());
return hyperlinks;
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class InternetConnectionErrorHandler method getQuickFixHyperlinks.
@Override
@NotNull
protected List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
List<NotificationHyperlink> hyperlinks = new ArrayList<>();
NotificationHyperlink enableOfflineMode = ToggleOfflineModeHyperlink.enableOfflineMode(project);
if (enableOfflineMode != null) {
hyperlinks.add(enableOfflineMode);
}
return hyperlinks;
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class JavaHeapSpaceErrorHandler method getQuickFixHyperlinks.
@Override
@NotNull
protected List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull NotificationData notification, @NotNull Project project, @NotNull String text) {
List<NotificationHyperlink> hyperlinks = new ArrayList<>();
hyperlinks.add(new OpenUrlHyperlink("http://www.gradle.org/docs/current/userguide/build_environment.html", "Read Gradle's configuration guide"));
hyperlinks.add(new OpenUrlHyperlink("http://docs.oracle.com/javase/7/docs/technotes/guides/vm/gc-ergonomics.html", "Read about Java's heap size"));
return hyperlinks;
}
use of com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink in project android by JetBrains.
the class CachedDependencyNotFoundErrorHandlerTest method testHandleError.
public void testHandleError() throws Exception {
GradleSettings settings = GradleSettings.getInstance(getProject());
// Set "offline mode" on to force the IDE to show quick-fix.
settings.setOfflineWork(true);
String expectedNotificationMessage = "No cached version of dependency, available for offline mode.";
String error = expectedNotificationMessage + "\nExtra error message.";
registerSyncErrorToSimulate(error);
loadProjectAndExpectSyncError(SIMPLE_APPLICATION);
SyncMessagesStub.NotificationUpdate notificationUpdate = mySyncMessagesStub.getNotificationUpdate();
assertNotNull(notificationUpdate);
assertThat(notificationUpdate.getText()).contains(expectedNotificationMessage);
List<NotificationHyperlink> quickFixes = notificationUpdate.getFixes();
assertThat(quickFixes).hasSize(1);
// Verify hyperlinks are correct.
NotificationHyperlink quickFix = quickFixes.get(0);
assertThat(quickFix).isInstanceOf(ToggleOfflineModeHyperlink.class);
ToggleOfflineModeHyperlink toggleOfflineModeQuickFix = (ToggleOfflineModeHyperlink) quickFix;
assertFalse(toggleOfflineModeQuickFix.isEnableOfflineMode());
}
Aggregations