use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class EditorSizeManager method assertValidState.
private void assertValidState() {
if (myDocument.isInBulkUpdate() || myDirty)
return;
if (myLineWidths.size() != myEditor.getVisibleLineCount()) {
LOG.error("Inconsistent state", new Attachment("editor.txt", myEditor.dumpState()));
reset();
}
assert myLineWidths.size() == myEditor.getVisibleLineCount();
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class DropAnErrorWithAttachmentsAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final boolean multipleAttachments = (e.getModifiers() & InputEvent.SHIFT_MASK) != 0;
Attachment[] attachments;
if (multipleAttachments) {
attachments = new Attachment[] { new Attachment("first.txt", "first content"), new Attachment("second.txt", "second content") };
} else {
attachments = new Attachment[] { new Attachment("attachment.txt", "content") };
}
IdeaLoggingEvent test = LogMessageEx.createEvent("test", "test details", attachments);
throw new LogEventException(test);
//Logger.getInstance("test (with attachments)").error(test);
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class CachingSoftWrapDataMapper method advanceSoftWrapOffsets.
/**
* Determines which soft wraps were not affected by recalculation, and shifts them to their new offsets.
*
* @return Change in soft wraps count after recalculation
*/
private void advanceSoftWrapOffsets(@NotNull IncrementalCacheUpdateEvent event) {
int lengthDiff = event.getLengthDiff();
int recalcEndOffsetTranslated = event.getActualEndOffset() - lengthDiff;
int firstIndex = -1;
int softWrappedLinesDiff = myStorage.getNumberOfSoftWrapsInRange(event.getStartOffset() + 1, myEditor.getDocument().getTextLength());
boolean softWrapsChanged = softWrappedLinesDiff > 0;
for (int i = 0; i < myAffectedByUpdateSoftWraps.size(); i++) {
SoftWrap softWrap = myAffectedByUpdateSoftWraps.get(i);
if (firstIndex < 0) {
if (softWrap.getStart() > recalcEndOffsetTranslated) {
firstIndex = i;
if (lengthDiff == 0) {
break;
}
} else {
softWrappedLinesDiff--;
softWrapsChanged = true;
}
}
if (firstIndex >= 0 && i >= firstIndex) {
((SoftWrapImpl) softWrap).advance(lengthDiff);
}
}
if (firstIndex >= 0) {
List<SoftWrapImpl> updated = myAffectedByUpdateSoftWraps.subList(firstIndex, myAffectedByUpdateSoftWraps.size());
SoftWrapImpl lastSoftWrap = getLastSoftWrap();
if (lastSoftWrap != null && lastSoftWrap.getStart() >= updated.get(0).getStart()) {
LOG.error("Invalid soft wrap recalculation", new Attachment("state.txt", myEditor.getSoftWrapModel().toString()));
}
myStorage.addAll(updated);
}
myAffectedByUpdateSoftWraps.clear();
if (softWrapsChanged) {
myStorage.notifyListenersAboutChange();
}
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class GitAnnotationProvider method parseAnnotations.
@NotNull
private GitFileAnnotation parseAnnotations(@Nullable VcsRevisionNumber revision, @NotNull VirtualFile file, @NotNull VirtualFile root, @NotNull String output) throws VcsException {
Interner<FilePath> pathInterner = new Interner<>();
try {
List<LineInfo> lines = new ArrayList<>();
HashMap<String, LineInfo> commits = new HashMap<>();
for (StringScanner s = new StringScanner(output); s.hasMoreData(); ) {
// parse header line
String commitHash = s.spaceToken();
if (commitHash.equals(GitRevisionNumber.NOT_COMMITTED_HASH)) {
commitHash = null;
}
// skip revision line number
s.spaceToken();
String s1 = s.spaceToken();
int lineNum = Integer.parseInt(s1);
s.nextLine();
// parse commit information
LineInfo commit = commits.get(commitHash);
if (commit != null || commitHash == null) {
while (s.hasMoreData() && !s.startsWith('\t')) {
s.nextLine();
}
} else {
Date committerDate = null;
FilePath filePath = null;
String subject = null;
String authorName = null;
String authorEmail = null;
String previousRevision = null;
FilePath previousFilePath = null;
while (s.hasMoreData() && !s.startsWith('\t')) {
String key = s.spaceToken();
String value = s.line();
if (SUBJECT_KEY.equals(key)) {
subject = value;
} else if (AUTHOR_KEY.equals(key)) {
authorName = value;
} else if (COMMITTER_TIME_KEY.equals(key)) {
committerDate = GitUtil.parseTimestamp(value);
} else if (FILENAME_KEY.equals(key)) {
filePath = VcsUtil.getFilePath(root, value);
} else if (AUTHOR_EMAIL_KEY.equals(key)) {
authorEmail = value;
if (authorEmail.startsWith("<") && authorEmail.endsWith(">")) {
authorEmail = authorEmail.substring(1, authorEmail.length() - 1);
}
} else if (PREVIOUS_KEY.equals(key)) {
int index = value.indexOf(' ');
if (index != -1) {
previousRevision = value.substring(0, index);
previousFilePath = VcsUtil.getFilePath(root, value.substring(index + 1, value.length()));
}
}
}
if (committerDate == null || filePath == null || authorName == null || authorEmail == null || subject == null) {
throw new VcsException("Output for line " + lineNum + " lacks necessary data");
}
GitRevisionNumber revisionNumber = new GitRevisionNumber(commitHash, committerDate);
VcsUser author = myUserRegistry.createUser(authorName, authorEmail);
GitRevisionNumber previousRevisionNumber = previousRevision != null ? new GitRevisionNumber(previousRevision) : null;
filePath = pathInterner.intern(filePath);
if (previousFilePath != null)
previousFilePath = pathInterner.intern(previousFilePath);
commit = new LineInfo(myProject, revisionNumber, filePath, committerDate, author, subject, previousRevisionNumber, previousFilePath);
commits.put(commitHash, commit);
}
s.nextLine();
int expectedLineNum = lines.size() + 1;
if (lineNum != expectedLineNum) {
throw new VcsException("Adding for info for line " + lineNum + " but we are expecting it to be for " + expectedLineNum);
}
lines.add(commit);
}
return new GitFileAnnotation(myProject, file, revision, lines);
} catch (Exception e) {
LOG.error("Couldn't parse annotation: " + e, new Attachment("output.txt", output));
throw new VcsException(e);
}
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class GitLogProvider method validateDataAndReportError.
private static void validateDataAndReportError(@NotNull final VirtualFile root, @NotNull final Set<VcsRef> allRefs, @NotNull final List<VcsCommitMetadata> sortedCommits, @NotNull final DetailedLogData firstBlockSyncData, @NotNull final Set<VcsRef> manuallyReadBranches, @Nullable final Set<String> currentTagNames, @Nullable final DetailedLogData commitsFromTags) {
StopWatch sw = StopWatch.start("validating data in " + root.getName());
final Set<Hash> refs = ContainerUtil.map2Set(allRefs, VcsRef::getCommitHash);
PermanentGraphImpl.newInstance(sortedCommits, new GraphColorManager<Hash>() {
@Override
public int getColorOfBranch(@NotNull Hash headCommit) {
return 0;
}
@Override
public int getColorOfFragment(@NotNull Hash headCommit, int magicIndex) {
return 0;
}
@Override
public int compareHeads(@NotNull Hash head1, @NotNull Hash head2) {
if (!refs.contains(head1) || !refs.contains(head2)) {
LOG.error("GitLogProvider returned inconsistent data", new Attachment("error-details.txt", printErrorDetails(root, allRefs, sortedCommits, firstBlockSyncData, manuallyReadBranches, currentTagNames, commitsFromTags)));
}
return 0;
}
}, refs);
sw.report();
}
Aggregations