use of com.intellij.openapi.diagnostic.Attachment in project intellij-plugins by JetBrains.
the class SwfProjectViewStructureProvider method getChildrenForPackage.
static Collection<AbstractTreeNode> getChildrenForPackage(String aPackage, List<JSQualifiedNamedElement> elements, int from, int to, Project project, ViewSettings settings) {
List<AbstractTreeNode> packages = new ArrayList<>();
List<AbstractTreeNode> classes = new ArrayList<>();
int subpackageStart = -1;
String currentSubpackage = null;
for (int i = from; i < to; i++) {
JSQualifiedNamedElement element = elements.get(i);
String qName = element.getQualifiedName();
assert aPackage.isEmpty() || qName.startsWith(aPackage + ".") : qName + " does not start with " + aPackage;
if (StringUtil.getPackageName(qName).equals(aPackage)) {
classes.add(new SwfQualifiedNamedElementNode(project, element, settings));
} else {
final int endIndex = qName.indexOf('.', aPackage.length() + 1);
if (endIndex <= 0) {
final Attachment attachment = element.getParent() != null ? new Attachment("Parent element.txt", element.getParent().getText()) : new Attachment("Element text.txt", element.getText());
LOG.error(LogMessageEx.createEvent("package=[" + aPackage + "], qName=[" + qName + "]", DebugUtil.currentStackTrace(), attachment));
continue;
}
String subpackage = settings.isFlattenPackages() ? StringUtil.getPackageName(qName) : qName.substring(0, endIndex);
if (currentSubpackage == null) {
subpackageStart = i;
} else if (!currentSubpackage.equals(subpackage)) {
packages.add(createSubpackageNode(elements, project, settings, subpackageStart, i, currentSubpackage));
subpackageStart = i;
}
currentSubpackage = subpackage;
}
}
if (currentSubpackage != null) {
packages.add(createSubpackageNode(elements, project, settings, subpackageStart, to, currentSubpackage));
}
return ContainerUtil.concat(packages, classes);
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class LogMessageEx method error.
public static void error(@NotNull Logger logger, @NotNull String message, @NotNull Throwable cause, @NotNull String... attachmentText) {
StringBuilder detailsBuffer = new StringBuilder();
for (String detail : attachmentText) {
detailsBuffer.append(detail).append(",");
}
if (attachmentText.length > 0 && detailsBuffer.length() > 0) {
detailsBuffer.setLength(detailsBuffer.length() - 1);
}
Attachment attachment = detailsBuffer.length() > 0 ? new Attachment("current-context.txt", detailsBuffer.toString()) : null;
logger.error(createEvent(message, ExceptionUtil.getThrowableText(cause), null, null, attachment));
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class ITNProxy method createParameters.
@NotNull
private static Multimap<String, String> createParameters(String login, String password, @NotNull ErrorBean error) {
Multimap<String, String> params = ArrayListMultimap.create(40, 1);
params.put("protocol.version", "1");
params.put("user.login", login);
params.put("user.password", password);
params.put("os.name", SystemProperties.getOsName());
params.put("java.version", SystemProperties.getJavaVersion());
params.put("java.vm.vendor", SystemProperties.getJavaVmVendor());
ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
Application application = ApplicationManager.getApplication();
params.put("app.name", namesInfo.getProductName());
params.put("app.name.full", namesInfo.getFullProductName());
params.put("app.name.version", appInfo.getVersionName());
params.put("app.eap", Boolean.toString(appInfo.isEAP()));
params.put("app.internal", Boolean.toString(application.isInternal()));
params.put("app.build", appInfo.getApiVersion());
params.put("app.version.major", appInfo.getMajorVersion());
params.put("app.version.minor", appInfo.getMinorVersion());
params.put("app.build.date", format(appInfo.getBuildDate()));
params.put("app.build.date.release", format(appInfo.getMajorReleaseBuildDate()));
params.put("app.compilation.timestamp", IdeaLogger.getOurCompilationTimestamp());
BuildNumber build = appInfo.getBuild();
String buildNumberWithAllDetails = build.asString();
params.put("app.product.code", build.getProductCode());
if (StringUtil.startsWith(buildNumberWithAllDetails, build.getProductCode() + "-")) {
buildNumberWithAllDetails = buildNumberWithAllDetails.substring(build.getProductCode().length() + 1);
}
params.put("app.build.number", buildNumberWithAllDetails);
UpdateSettings updateSettings = UpdateSettings.getInstance();
params.put("update.channel.status", updateSettings.getSelectedChannelStatus().getCode());
params.put("update.ignored.builds", StringUtil.join(updateSettings.getIgnoredBuildNumbers(), ","));
params.put("plugin.name", error.getPluginName());
params.put("plugin.version", error.getPluginVersion());
params.put("last.action", error.getLastAction());
params.put("previous.exception", error.getPreviousException() == null ? null : Integer.toString(error.getPreviousException()));
params.put("error.message", error.getMessage());
params.put("error.stacktrace", error.getStackTrace());
params.put("error.description", error.getDescription());
params.put("assignee.id", error.getAssigneeId() == null ? null : Integer.toString(error.getAssigneeId()));
for (Attachment attachment : error.getAttachments()) {
params.put("attachment.name", attachment.getName());
params.put("attachment.value", attachment.getEncodedBytes());
}
return params;
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class ReadMostlyRWLock method ensureNoPrivilegedReaders.
private void ensureNoPrivilegedReaders() {
if (!privilegedReaders.isEmpty()) {
List<String> offenderNames = ContainerUtil.map(privilegedReaders.keySet(), Thread::getName);
privilegedReaders.clear();
LOG.error("Pooled threads created during write action suspension should have been terminated: " + offenderNames, new Attachment("threadDump.txt", ThreadDumper.dumpThreadsToString()));
}
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class CompletionAssertions method assertCompletionPositionPsiConsistent.
static void assertCompletionPositionPsiConsistent(CompletionContext newContext, int offset, PsiFile fileCopy, PsiFile originalFile, PsiElement insertedElement) {
if (insertedElement == null) {
throw new LogEventException("No element at insertion offset", "offset=" + newContext.getStartOffset() + "\n" + DebugUtil.currentStackTrace(), createFileTextAttachment(fileCopy, originalFile), createAstAttachment(fileCopy, originalFile));
}
if (fileCopy.findElementAt(offset) != insertedElement) {
throw new AssertionError("wrong offset");
}
final TextRange range = insertedElement.getTextRange();
CharSequence fileCopyText = fileCopy.getViewProvider().getContents();
if ((range.getEndOffset() > fileCopyText.length()) || !fileCopyText.subSequence(range.getStartOffset(), range.getEndOffset()).toString().equals(insertedElement.getText())) {
throw new LogEventException("Inconsistent completion tree", "range=" + range + "\n" + DebugUtil.currentStackTrace(), createFileTextAttachment(fileCopy, originalFile), createAstAttachment(fileCopy, originalFile), new Attachment("Element at caret.txt", insertedElement.getText()));
}
}
Aggregations