Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
273,800
List<EventLogFile> () { return myFiles; }
getFilesToSend
273,801
String () { return myTemplateUrl; }
getTemplateUrl
273,802
String () { return myProductCode; }
getProductCode
273,803
String () { return myProductVersion; }
getProductVersion
273,804
int () { return myBaselineVersion; }
getBaselineVersion
273,805
EventLogConnectionSettings () { return myConnectionSettings; }
getConnectionSettings
273,806
boolean () { return myIsInternal; }
isInternal
273,807
boolean () { return myIsTestConfig; }
isTestConfig
273,808
boolean () { return myIsTestSendEndpoint; }
isTestSendEndpoint
273,809
boolean () { return myIsEAP; }
isEAP
273,810
DataCollectorDebugLogger () { return myLogger; }
getLogger
273,811
DataCollectorSystemEventLogger () { return myEventLogger; }
getEventLogger
273,812
String (@NotNull String recorderId, @NotNull String productCode, @NotNull String templateUrl, boolean isTestConfig) { if (isTestConfig) { return String.format(templateUrl, "test/" + recorderId, productCode); } return String.format(templateUrl, recorderId, productCode); }
getConfigUrl
273,813
String () { return getEndpointValue(SEND); }
getServiceUrl
273,814
String () { return getEndpointValue(DICTIONARY); }
getDictionaryServiceUrl
273,815
boolean () { return getExternalSettings() != null; }
isSettingsReachable
273,816
boolean () { final EventLogExternalSendSettings settings = getExternalSettings(); return settings != null && settings.isSendEnabled(); }
isSendEnabled
273,817
LogEventFilter () { return new LogEventMetadataFilter(notNull(loadApprovedGroupsRules(), EventGroupsFilterRules.empty())); }
getBaseEventFilter
273,818
LogEventFilter (@NotNull LogEventFilter base, @NotNull EventLogBuildType type) { final EventLogSendConfiguration configuration = getConfiguration(type); if (configuration == null) { DataCollectorDebugLogger logger = myApplicationInfo.getLogger(); if (logger.isTraceEnabled()) { logger.trace("Cannot find send configuration for '" + type + "' -> clean up log file"); } return LogEventFalseFilter.INSTANCE; } return new LogEventCompositeFilter( new LogEventBucketsFilter(configuration.getBuckets()), base, LogEventSnapshotBuildFilter.INSTANCE ); }
getEventFilter
273,819
EventGroupsFilterRules<EventLogBuild> (@Nullable EventGroupsFilterRules<EventLogBuild> groupFilterConditions, @NotNull EventGroupsFilterRules<EventLogBuild> defaultValue) { return groupFilterConditions != null ? groupFilterConditions : defaultValue; }
notNull
273,820
EventLogApplicationInfo () { return myApplicationInfo; }
getApplicationInfo
273,821
EventGroupsFilterRules<EventLogBuild> () { final String productUrl = getMetadataProductUrl(); if (productUrl == null) return null; EventLogConnectionSettings settings = myApplicationInfo.getConnectionSettings(); return EventLogMetadataUtils.loadAndParseGroupsFilterRules(productUrl, settings); }
loadApprovedGroupsRules
273,822
String () { String baseMetadataUrl = getEndpointValue(METADATA); if (baseMetadataUrl == null) return null; return baseMetadataUrl + myApplicationInfo.getBaselineVersion() + "/" + myApplicationInfo.getProductCode() + ".json"; }
getMetadataProductUrl
273,823
StatisticsResult () { return send(myConfiguration, mySettingsService, new EventLogCounterResultDecorator(mySendListener)); }
send
273,824
StatisticsResult (@NotNull EventLogResultDecorator decorator) { return send(myConfiguration, mySettingsService, decorator); }
send
273,825
StatisticsResult (@NotNull EventLogSendConfig config, @NotNull EventLogSettingsService settings, @NotNull EventLogResultDecorator decorator) { final EventLogApplicationInfo info = settings.getApplicationInfo(); final DataCollectorDebugLogger logger = info.getLogger(); final List<EventLogFile> logs = getLogFiles(config, logger); if (!config.isSendEnabled()) { cleanupEventLogFiles(logs, logger); return new StatisticsResult(ResultCode.NOTHING_TO_SEND, "Event Log collector is not enabled"); } if (logs.isEmpty()) { return new StatisticsResult(ResultCode.NOTHING_TO_SEND, "No files to send"); } if (!settings.isSettingsReachable()) { return new StatisticsResult(StatisticsResult.ResultCode.ERROR_IN_CONFIG, "ERROR: settings server is unreachable"); } if (!settings.isSendEnabled()) { cleanupEventLogFiles(logs, logger); return new StatisticsResult(StatisticsResult.ResultCode.NOT_PERMITTED_SERVER, "NOT_PERMITTED"); } final String serviceUrl = settings.getServiceUrl(); if (serviceUrl == null) { return new StatisticsResult(StatisticsResult.ResultCode.ERROR_IN_CONFIG, "ERROR: unknown Statistics Service URL."); } final boolean isInternal = info.isInternal(); final String productCode = info.getProductCode(); EventLogBuildType defaultBuildType = getDefaultBuildType(info.isEAP()); LogEventFilter baseFilter = settings.getBaseEventFilter(); MachineId machineId = getActualOrDisabledMachineId(config.getMachineId(), settings); try { EventLogConnectionSettings connectionSettings = info.getConnectionSettings(); decorator.onLogsLoaded(logs.size()); final List<File> toRemove = new ArrayList<>(logs.size()); for (EventLogFile logFile : logs) { File file = logFile.getFile(); EventLogBuildType type = logFile.getType(defaultBuildType); LogEventFilter filter = settings.getEventFilter(baseFilter, type); String deviceId = config.getDeviceId(); LogEventRecordRequest recordRequest = LogEventRecordRequest.Companion.create(file, config.getRecorderId(), productCode, deviceId, filter, isInternal, logger, machineId, config.isEscapingEnabled()); ValidationErrorInfo error = validate(recordRequest, file); if (error != null) { if (logger.isTraceEnabled()) { logger.trace(file.getName() + "-> " + error.getMessage()); } decorator.onFailed(recordRequest, error.getCode(), null); toRemove.add(file); continue; } try { StatsHttpRequests.post(serviceUrl, connectionSettings). withBody(LogEventSerializer.INSTANCE.toString(recordRequest), "application/json", StandardCharsets.UTF_8). succeed((r, code) -> { toRemove.add(file); decorator.onSucceed(recordRequest, loadAndLogResponse(logger, r, file), file.getAbsolutePath()); }). fail((r, code) -> { if (code == HttpURLConnection.HTTP_BAD_REQUEST) { toRemove.add(file); } decorator.onFailed(recordRequest, code, loadAndLogResponse(logger, r, file)); }).send(); } catch (Exception e) { if (logger.isTraceEnabled()) { logger.trace(file.getName() + " -> " + e.getMessage()); } //noinspection InstanceofCatchParameter int errorCode = e instanceof StatsRequestBuilder.InvalidHttpRequest ? ((StatsRequestBuilder.InvalidHttpRequest)e).getCode() : 50; decorator.onFailed(null, errorCode, null); } } cleanupFiles(toRemove, logger); return decorator.onFinished(); } catch (Exception e) { final String message = e.getMessage(); logger.info(message != null ? message : "", e); throw new StatServiceException("Error during data sending.", e); } }
send
273,826
MachineId (@NotNull MachineId machineId, @NotNull EventLogSettingsService settings) { if (machineId == MachineId.DISABLED) { return MachineId.DISABLED; } Map<String, String> options = settings.getOptions(); String machineIdSaltOption = options.get(EventLogOptions.MACHINE_ID_SALT); if (EventLogOptions.MACHINE_ID_DISABLED.equals(machineIdSaltOption)) { return MachineId.DISABLED; } return machineId; }
getActualOrDisabledMachineId
273,827
EventLogBuildType (boolean isEap) { return isEap ? EventLogBuildType.EAP : EventLogBuildType.RELEASE; }
getDefaultBuildType
273,828
ValidationErrorInfo (@Nullable LogEventRecordRequest request, @NotNull File file) { if (request == null) { return new ValidationErrorInfo("File is empty or has invalid format: " + file.getName(), 1); } if (isEmpty(request.getDevice())) { return new ValidationErrorInfo("Cannot upload event log, device ID is empty", 2); } else if (isEmpty(request.getProduct())) { return new ValidationErrorInfo("Cannot upload event log, product code is empty", 3); } else if (isEmpty(request.getRecorder())) { return new ValidationErrorInfo("Cannot upload event log, recorder code is empty", 4); } else if (request.getRecords().isEmpty()) { return new ValidationErrorInfo("Cannot upload event log, record list is empty", 5); } for (LogEventRecord content : request.getRecords()) { if (content.getEvents().isEmpty()) { return new ValidationErrorInfo("Cannot upload event log, event list is empty", 6); } } return null; }
validate
273,829
List<EventLogFile> (@NotNull EventLogSendConfig config, @NotNull DataCollectorDebugLogger logger) { try { return config.getFilesToSendProvider().getFilesToSend(); } catch (Exception e) { final String message = e.getMessage(); logger.info(message != null ? message : "", e); } return Collections.emptyList(); }
getLogFiles
273,830
void (@NotNull List<EventLogFile> toRemove, @NotNull DataCollectorDebugLogger logger) { List<File> filesToRemove = new ArrayList<>(); for (EventLogFile file : toRemove) { filesToRemove.add(file.getFile()); } cleanupFiles(filesToRemove, logger); }
cleanupEventLogFiles
273,831
void (@NotNull List<? extends File> toRemove, @NotNull DataCollectorDebugLogger logger) { for (File file : toRemove) { if (!file.delete()) { logger.warn("Failed deleting event log: " + file.getName()); } if (logger.isTraceEnabled()) { logger.trace("Removed sent log: " + file.getName()); } } }
cleanupFiles
273,832
int () { return myCode; }
getCode
273,833
String () { return myError; }
getMessage
273,834
void (int localFiles) { myLocalFiles = localFiles; }
onLogsLoaded
273,835
void (@NotNull LogEventRecordRequest request, @NotNull String content, @NotNull String logPath) { mySuccessfullySentFiles.add(logPath); }
onSucceed
273,836
void (@Nullable LogEventRecordRequest request, int error, @Nullable String content) { myErrors.add(error); }
onFailed
273,837
StatisticsResult () { if (myListener != null) { myListener.onLogsSend(mySuccessfullySentFiles, myErrors, myLocalFiles); } int succeed = mySuccessfullySentFiles.size(); int failed = myErrors.size(); int total = succeed + failed; if (total == 0) { return new StatisticsResult(ResultCode.NOTHING_TO_SEND, "No files to upload."); } else if (failed > 0) { return new StatisticsResult(ResultCode.SENT_WITH_ERRORS, "Uploaded " + succeed + " out of " + total + " files."); } return new StatisticsResult(ResultCode.SEND, "Uploaded " + succeed + " files."); }
onFinished
273,838
String () { return description; }
getDescription
273,839
ResultCode () { return code; }
getCode
273,840
EventLogSendConfiguration (@NotNull EventLogBuildType type) { EventLogExternalSendSettings settings = getExternalSettings(); return settings != null ? settings.getConfiguration(type) : null; }
getConfiguration
273,841
String (@NotNull String attribute) { EventLogExternalSendSettings settings = getExternalSettings(); return settings != null ? settings.getEndpoint(attribute) : null; }
getEndpointValue
273,842
EventLogExternalSendSettings (@NotNull String recorderId, @NotNull String configUrl, @NotNull String appVersion) { try { return StatsHttpRequests.request(configUrl, myApplicationInfo.getConnectionSettings()).send(r -> { try { InputStream content = r.read(); if (content != null) { InputStreamReader reader = new InputStreamReader(content, StandardCharsets.UTF_8); return EventLogExternalSettings.parseSendSettings(reader, appVersion); } return null; } catch (EventLogConfigParserException e) { throw new StatsResponseException(e); } }).getResult(); } catch (StatsResponseException | IOException e) { logError(recorderId, e); } return null; }
loadSettings
273,843
void (@NotNull String recorderId, Exception e) { final String message = String.format(Locale.ENGLISH, "%s: %s", e.getClass().getName(), Objects.requireNonNullElse(e.getMessage(), "No message provided")); if (e instanceof ConnectException || e instanceof HttpTimeoutException || e instanceof SSLHandshakeException || e instanceof StatsResponseException) { // Expected non-critical problems: no connection, bad connection, errors on loading data myApplicationInfo.getLogger().info(message); } else { myApplicationInfo.getLogger().warn(message, e); } myApplicationInfo.getEventLogger().logErrorEvent(recorderId, "loading.config.failed", e); }
logError
273,844
String () { return getMessage(); }
getErrorType
273,845
int () { return myErrorCode; }
getErrorCode
273,846
EventLogMetadataUpdateStage () { return EventLogMetadataUpdateStage.LOADING; }
getUpdateStage
273,847
EventGroupsFilterRules<EventLogBuild> (@NotNull String serviceUrl, @NotNull EventLogConnectionSettings settings) { try { String content = loadMetadataFromServer(serviceUrl, settings); EventGroupRemoteDescriptors groups = parseGroupRemoteDescriptors(content); return EventGroupsFilterRules.create(groups, EventLogBuild.EVENT_LOG_BUILD_PRODUCER); } catch (EventLogMetadataParseException | EventLogMetadataLoadException e) { return EventGroupsFilterRules.empty(); } }
loadAndParseGroupsFilterRules
273,848
long (@Nullable String serviceUrl, @NotNull EventLogConnectionSettings settings) { if (isEmptyOrSpaces(serviceUrl)) return 0; try { StatsRequestResult<Long> result = StatsHttpRequests.head(serviceUrl, settings).send(r -> r.lastModified()); return result.getResult() != null ? result.getResult() : 0L; } catch (StatsResponseException | IOException e) { return 0; } }
lastModifiedMetadata
273,849
T () { return myResult; }
getResult
273,850
int () { return myErrorCode; }
getError
273,851
boolean () { return myResult != null; }
isSucceed
273,852
StatsRequestBuilder (@NotNull String url, @NotNull EventLogConnectionSettings settings) { return new StatsRequestBuilder("GET", url, settings); }
request
273,853
StatsRequestBuilder (@NotNull String url, @NotNull EventLogConnectionSettings settings) { return new StatsRequestBuilder("HEAD", url, settings); }
head
273,854
StatsRequestBuilder (@NotNull String url, @NotNull EventLogConnectionSettings settings) { return new StatsRequestBuilder("POST", url, settings); }
post
273,855
boolean () { return myProxy == Proxy.NO_PROXY; }
isNoProxy
273,856
Proxy () { return myProxy; }
getProxy
273,857
StatsProxyAuthProvider () { return myProxyAuth; }
getProxyAuth
273,858
int () { return myCode; }
getStatusCode
273,859
Long () { return myHttpResponse == null ? null : myHttpResponse.headers(). allValues("Last-Modified").stream(). map(value -> parseDate(value)).filter(date -> date != null).map(date -> date.getTime()). max(Long::compareTo).orElse(null); }
lastModified
273,860
StatsRequestBuilder (@NotNull String body, @NotNull String contentType, @NotNull Charset charset) { if (StatisticsStringUtil.isEmptyOrSpaces(body)) { throw new EmptyHttpRequestBody(); } myContent = body; myContentType = contentType; myCharset = charset; return this; }
withBody
273,861
StatsRequestBuilder (@NotNull StatsResponseHandler processor) { onFail = processor; return this; }
fail
273,862
StatsRequestBuilder (@NotNull StatsResponseHandler processor) { onSucceed = processor; return this; }
succeed
273,863
HttpClient () { HttpClient.Builder builder = HttpClient.newBuilder(); builder.followRedirects(HttpClient.Redirect.NORMAL); if (myProxyInfo != null && !myProxyInfo.isNoProxy()) { configureProxy(builder, myProxyInfo); } if (mySSLContext != null) { builder.sslContext(mySSLContext); } return builder.build(); }
newClient
273,864
void (HttpClient.Builder builder, @NotNull StatsProxyInfo info) { Proxy proxy = info.getProxy(); if (proxy.type() == Proxy.Type.HTTP || proxy.type() == Proxy.Type.SOCKS) { SocketAddress proxyAddress = proxy.address(); if (proxyAddress instanceof InetSocketAddress address) { String hostName = address.getHostString(); int port = address.getPort(); builder.proxy(ProxySelector.of(new InetSocketAddress(hostName, port))); StatsProxyInfo.StatsProxyAuthProvider auth = info.getProxyAuth(); if (auth != null) { String login = auth.getProxyLogin(); if (login != null) { // This Implementation require -Djdk.http.auth.tunneling.disabledSchemes="" in vm options // In other cases PasswordAuthentication will be ignored and authentication will fail builder.authenticator(new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(login, Objects.requireNonNullElse(auth.getProxyPassword(), "").toCharArray()); } }); } } } } }
configureProxy
273,865
PasswordAuthentication () { return new PasswordAuthentication(login, Objects.requireNonNullElse(auth.getProxyPassword(), "").toCharArray()); }
getPasswordAuthentication
273,866
HttpRequest () { HttpRequest.Builder builder = HttpRequest.newBuilder(). setHeader("User-Agent", myUserAgent). timeout(Duration.ofSeconds(10)). uri(URI.create(myUrl)); if ("HEAD".equals(myMethod)) { builder.method(myMethod, HttpRequest.BodyPublishers.noBody()); } else if ("POST".equals(myMethod)) { if (myContent == null || myContent.isBlank()) { throw new EmptyHttpRequestBody(); } builder.setHeader("Chunked", Boolean.toString(false)); builder.setHeader("Content-Type", String.format(Locale.ENGLISH, "%s; charset=%s", myContentType, myCharset)); builder.setHeader("Content-Encoding", "gzip"); builder.POST(HttpRequest.BodyPublishers.ofByteArray(getCompressedContent())); } else if ("GET".equals(myMethod)) { builder.GET(); } else { throw new IllegalHttpRequestTypeException(); } myExtraHeaders .forEach((k, v) -> builder.setHeader(k,v)); return builder.build(); }
newRequest
273,867
byte[] () { try (ByteArrayOutputStream gZippedBody = new ByteArrayOutputStream()) { GZIPOutputStream gZipper = new GZIPOutputStream(gZippedBody); gZipper.write(myContent.getBytes(myCharset)); gZippedBody.flush(); gZipper.close(); return gZippedBody.toByteArray(); } catch (IOException e) { throw new HttpRequestBodyGzipException(e); } }
getCompressedContent
273,868
int () { return myCode; }
getCode
273,869
Icon (@NotNull String path, int cacheKey, int flags) { return IconManager.getInstance().loadRasterizedIcon(path, PlatformStatisticsDevkitIcons.class.getClassLoader(), cacheKey, flags); }
load
273,870
ActionUpdateThread () { return ActionUpdateThread.BGT; }
getActionUpdateThread
273,871
void (@NotNull AnActionEvent e) { e.getPresentation().setEnabledAndVisible(e.getProject() != null); }
update
273,872
void (@NotNull AnActionEvent e) { final Project project = e.getProject(); if (project == null) { return; } final EventLogFile logFile = StatisticsEventLogProviderUtil.getEventLogProvider(myRecorderId).getActiveLogFile(); final VirtualFile logVFile = logFile != null ? LocalFileSystem.getInstance().refreshAndFindFileByIoFile(logFile.getFile()) : null; if (logVFile == null) { showNotification(project, StatisticsBundle.message("stats.there.is.no.active.event.log")); return; } FileEditorManager.getInstance(project).openFile(logVFile, true); }
actionPerformed
273,873
void (@NotNull Project project, @NotNull String message) { String title = StatisticsBundle.message("stats.feature.usage.statistics"); new Notification(STATISTICS_NOTIFICATION_GROUP_ID, title, message, NotificationType.WARNING) .addAction(NotificationAction.createSimple( StatisticsBundle.message("stats.enable.data.sharing"), () -> new SingleConfigurableEditor(project, new ConsentConfigurable()).show())) .notify(project); }
showNotification
273,874
void (@NotNull AnActionEvent e) { final Project project = e.getProject(); if (project != null) { final PsiFile fileType = e.getData(CommonDataKeys.PSI_FILE); final Editor editor = fileType != null && StringUtil.equalsIgnoreCase(fileType.getFileType().getName(), "json") ? e.getData(CommonDataKeys.EDITOR) : null; new TestParseEventsSchemeDialog(project, editor).show(); } }
actionPerformed
273,875
ActionUpdateThread () { return ActionUpdateThread.BGT; }
getActionUpdateThread
273,876
void (@NotNull AnActionEvent e) { boolean enabled = isEnabled(e.getProject()); e.getPresentation().setEnabledAndVisible(enabled); }
update
273,877
boolean (@Nullable Project project) { return project != null && ApplicationManager.getApplication().isInternal(); }
isEnabled
273,878
ActionUpdateThread () { return ActionUpdateThread.BGT; }
getActionUpdateThread
273,879
void (@NotNull AnActionEvent e) { String recorderId = StringUtil.trim(Registry.stringValue("usage.statistics.test.action.recorder.id")); e.getPresentation().setEnabledAndVisible(e.getProject() != null && StatisticsRecorderUtil.isTestModeEnabled(recorderId)); }
update
273,880
void (@NotNull AnActionEvent e) { final Project project = e.getProject(); if (project == null) { return; } ProgressManager.getInstance().run(new Task.Backgroundable(project, StatisticsBundle.message("stats.send.feature.usage.event.log"), false) { @Override public void run(@NotNull ProgressIndicator indicator) { final StatisticsResult result = send(); final StatisticsResult.ResultCode code = result.getCode(); if (code == StatisticsResult.ResultCode.SENT_WITH_ERRORS || code == StatisticsResult.ResultCode.SEND) { final boolean succeed = tryToOpenInScratch(project, result.getDescription()); if (succeed) { return; } } ApplicationManager.getApplication().invokeLater( () -> Messages.showMultilineInputDialog(project, "Result: " + code, "Statistics Result", StringUtil.replace(result.getDescription(), ";", "\n"), null, null), ModalityState.nonModal(), project.getDisposed()); } private static StatisticsResult send() { String recorderId = StringUtil.trim(Registry.stringValue("usage.statistics.test.action.recorder.id")); return EventLogStatisticsService.send( EventLogInternalSendConfig.createByRecorder(recorderId, true), new EventLogTestSettingsService(recorderId), new EventLogTestResultDecorator() ); } }); }
actionPerformed
273,881
void (@NotNull ProgressIndicator indicator) { final StatisticsResult result = send(); final StatisticsResult.ResultCode code = result.getCode(); if (code == StatisticsResult.ResultCode.SENT_WITH_ERRORS || code == StatisticsResult.ResultCode.SEND) { final boolean succeed = tryToOpenInScratch(project, result.getDescription()); if (succeed) { return; } } ApplicationManager.getApplication().invokeLater( () -> Messages.showMultilineInputDialog(project, "Result: " + code, "Statistics Result", StringUtil.replace(result.getDescription(), ";", "\n"), null, null), ModalityState.nonModal(), project.getDisposed()); }
run
273,882
StatisticsResult () { String recorderId = StringUtil.trim(Registry.stringValue("usage.statistics.test.action.recorder.id")); return EventLogStatisticsService.send( EventLogInternalSendConfig.createByRecorder(recorderId, true), new EventLogTestSettingsService(recorderId), new EventLogTestResultDecorator() ); }
send
273,883
LogEventFilter (@NotNull LogEventFilter base, @NotNull EventLogBuildType type) { LogEventFilter filter = super.getEventFilter(base, type); if (filter instanceof LogEventCompositeFilter) { LogEventFilter[] withoutSnapshot = Arrays.stream(((LogEventCompositeFilter)filter).getFilters()) .filter(f -> f != LogEventSnapshotBuildFilter.INSTANCE) .toArray(LogEventFilter[]::new); return new LogEventCompositeFilter(withoutSnapshot); } return filter; }
getEventFilter
273,884
boolean () { return true; }
isInternal
273,885
void (@NotNull LogEventRecordRequest request, @NotNull String content, @NotNull String logPath) { mySucceed.add(request); }
onSucceed
273,886
void (@Nullable LogEventRecordRequest request, int error, @Nullable String content) { if (request != null) { myFailed.add(request); } else { myFailed.add(new LogEventRecordRequest("INVALID", "INVALID", "INVALID", ContainerUtil.emptyList(), true)); } }
onFailed
273,887
StatisticsResult () { int total = mySucceed.size() + myFailed.size(); if (mySucceed.isEmpty() && myFailed.isEmpty()) { return new StatisticsResult(StatisticsResult.ResultCode.NOTHING_TO_SEND, "No files to upload."); } else if (!myFailed.isEmpty()) { final StringBuilder out = new StringBuilder("{\"total\":"); out.append(total).append(", \"uploaded\":").append(mySucceed.size()).append(","); out.append("\"failed\":["); append(out, myFailed); out.append("],\"succeed\":["); append(out, mySucceed); out.append("]}"); return new StatisticsResult(StatisticsResult.ResultCode.SENT_WITH_ERRORS, out.toString()); } final StringBuilder out = new StringBuilder("{\"total\":"); out.append(total).append(", \"uploaded\":").append(mySucceed.size()).append(","); out.append("\"succeed\":["); append(out, mySucceed); out.append("]}"); return new StatisticsResult(StatisticsResult.ResultCode.SEND, out.toString()); }
onFinished
273,888
void (@NotNull StringBuilder out, @NotNull List<LogEventRecordRequest> requests) { boolean isFirst = true; for (LogEventRecordRequest request : requests) { if (isFirst) { isFirst = false; } else { out.append(","); } out.append(LogEventSerializer.INSTANCE.toString(request)); } }
append
273,889
boolean (@NotNull Project project, @NotNull String request) { final String fileName = "fus-event-log.json"; try { final ThrowableComputable<NavigatablePsiElement, Exception> computable = () -> { final ScratchFileService fileService = ScratchFileService.getInstance(); final VirtualFile file = fileService.findFile(RootType.findById("scratches"), fileName, ScratchFileService.Option.create_new_always); fileService.getScratchesMapping().setMapping(file, Language.findLanguageByID("JSON")); final PsiFile psiFile = PsiManager.getInstance(project).findFile(file); final Document document = psiFile != null ? PsiDocumentManager.getInstance(project).getDocument(psiFile) : null; if (document == null) { return null; } document.insertString(document.getTextLength(), request); PsiDocumentManager.getInstance(project).commitDocument(document); return psiFile; }; final NavigatablePsiElement psiElement = writeCommandAction(project) .withName(StatisticsBundle.message("stats.creating.json.for.event.log.upload.results")) .withGlobalUndo().shouldRecordActionForActiveDocument(false) .withUndoConfirmationPolicy(UndoConfirmationPolicy.REQUEST_CONFIRMATION) .compute(computable); if (psiElement != null) { AppUIExecutor.onUiThread().expireWith(project).submit(() -> psiElement.navigate(true)); return true; } } catch (Exception e) { // ignore } return false; }
tryToOpenInScratch
273,890
EditorEx (@Nullable Editor selectedEditor, @NotNull String fileName, @NotNull String templateText) { if (selectedEditor != null) { return (EditorEx)EditorFactory.getInstance().createEditor(selectedEditor.getDocument(), myProject); } final PsiFile file = createTempFile(myProject, fileName, templateText); assert file != null; myTempFiles.add(file); Document document = PsiDocumentManager.getInstance(myProject).getDocument(file); if (document == null) { document = EditorFactory.getInstance().createDocument(templateText); } VirtualFile virtualFile = file.getVirtualFile(); final EditorEx editor = (EditorEx)EditorFactory.getInstance().createEditor(document, myProject, virtualFile, false); editor.setFile(virtualFile); return editor; }
initEditor
273,891
PsiFile (@NotNull Project project, @NotNull String filename, @NotNull String request) { final String fileName = PathUtil.makeFileName(filename, "json"); try { final ThrowableComputable<PsiFile, Exception> computable = () -> { final ScratchFileService fileService = ScratchFileService.getInstance(); final VirtualFile file = fileService.findFile(RootType.findById("scratches"), fileName, ScratchFileService.Option.create_if_missing); fileService.getScratchesMapping().setMapping(file, Language.findLanguageByID("JSON")); final PsiFile psiFile = PsiManager.getInstance(project).findFile(file); final Document document = psiFile != null ? PsiDocumentManager.getInstance(project).getDocument(psiFile) : null; if (document == null) { return null; } document.insertString(document.getTextLength(), request); PsiDocumentManager.getInstance(project).commitDocument(document); return psiFile; }; return writeCommandAction(project) .withName(StatisticsBundle.message("stats.creating.temp.json.file.for.event.log")) .withGlobalUndo().shouldRecordActionForActiveDocument(false) .withUndoConfirmationPolicy(UndoConfirmationPolicy.REQUEST_CONFIRMATION) .compute(computable); } catch (Exception e) { // ignore } return null; }
createTempFile
273,892
void () { configEditorPanel(myProject, myEventsSchemePanel, myEventsSchemeEditor); configEditorPanel(myProject, myResultPanel, myResultEditor); myInputDataSplitPane.setDividerLocation(IN_DIVIDER_LOCATION); myInputOutputSplitPane.setDividerLocation(IN_OUT_DIVIDER_LOCATION); super.init(); }
init
273,893
void (@NotNull Project project, @NotNull JPanel panel, @NotNull EditorEx editor) { panel.setLayout(new BorderLayout()); panel.add(editor.getComponent(), BorderLayout.CENTER); editor.getSettings().setFoldingOutlineShown(false); final FileType fileType = FileTypeManager.getInstance().findFileTypeByName("JSON"); final LightVirtualFile lightFile = new LightVirtualFile("Dummy.json", fileType, ""); EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(project, lightFile); try { editor.setHighlighter(highlighter); } catch (Throwable e) { LOG.warn(e); } }
configEditorPanel
273,894
String () { return TestParseEventsSchemeDialog.class.getCanonicalName(); }
getDimensionServiceKey
273,895
void () { myEventsSchemeEditor.getSelectionModel().removeSelection(); myResultEditor.getSelectionModel().removeSelection(); updateResultRequest("{}"); try { EventGroupRemoteDescriptors groups = EventLogMetadataUtils.parseGroupRemoteDescriptors(myEventsSchemeEditor.getDocument().getText()); EventGroupsFilterRules<EventLogBuild> scheme = EventGroupsFilterRules.create(groups, EventLogBuild.EVENT_LOG_BUILD_PRODUCER); String parsed = parseLogAndFilter(new LogEventMetadataFilter(scheme), myEventLogPanel.getText()); updateResultRequest(parsed.trim()); } catch (EventLogMetadataParseException e) { Messages.showErrorDialog(myProject, e.getMessage(), "Failed Parsing Events Scheme"); } catch (IOException | ParseEventLogMetadataException e) { Messages.showErrorDialog(myProject, e.getMessage(), "Failed Applying Events Scheme to Event Log"); } }
doOKAction
273,896
void (@NotNull String text) { writeCommandAction(myProject).run(() -> { final DocumentEx document = myResultEditor.getDocument(); document.setText(text); PsiDocumentManager.getInstance(myProject).commitDocument(myResultEditor.getDocument()); }); }
updateResultRequest
273,897
JComponent () { return myMainPanel; }
createCenterPanel
273,898
JComponent () { return myEventLogPanel; }
getPreferredFocusedComponent
273,899
void () { writeCommandAction(myProject).run(() -> { for (PsiFile file : myTempFiles) { try { file.delete(); } catch (IncorrectOperationException e) { LOG.warn(e); } } }); if (!myEventsSchemeEditor.isDisposed()) { EditorFactory.getInstance().releaseEditor(myEventsSchemeEditor); } if (!myResultEditor.isDisposed()) { EditorFactory.getInstance().releaseEditor(myResultEditor); } super.dispose(); }
dispose