com.intellij.openapi.util.Key Java Examples
The following examples show how to use
com.intellij.openapi.util.Key.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JSGraphQLEndpointErrorAnnotator.java From js-graphql-intellij-plugin with MIT License | 6 votes |
private void annotateRedeclarations(@NotNull JSGraphQLEndpointNamedTypeDef element, PsiFile importingFile, Key<Multimap<String, JSGraphQLEndpointNamedTypeDefinition>> key, @NotNull AnnotationHolder holder) { final Key<Boolean> annotationKey = Key.create(element.getContainingFile().getName() + ":" + element.getTextOffset()); if (holder.getCurrentAnnotationSession().getUserData(annotationKey) == Boolean.TRUE) { // already annotated about redeclaration return; } Multimap<String, JSGraphQLEndpointNamedTypeDefinition> knownDefinitionsByName = holder.getCurrentAnnotationSession().getUserData(key); if (knownDefinitionsByName == null) { knownDefinitionsByName = HashMultimap.create(); for (JSGraphQLEndpointNamedTypeDefinition definition : JSGraphQLEndpointPsiUtil.getKnownDefinitions(importingFile, JSGraphQLEndpointNamedTypeDefinition.class, true, null)) { if (definition.getNamedTypeDef() != null) { knownDefinitionsByName.put(definition.getNamedTypeDef().getText(), definition); } } } final String typeName = element.getText(); final Collection<JSGraphQLEndpointNamedTypeDefinition> typesWithSameName = knownDefinitionsByName.get(typeName); if (typesWithSameName != null && typesWithSameName.size() > 1) { final Set<String> files = typesWithSameName.stream().map(t -> "'" + t.getContainingFile().getName() + "'").collect(Collectors.toSet()); holder.createErrorAnnotation(element, "'" + typeName + "' is redeclared in " + StringUtils.join(files, ", ")); holder.getCurrentAnnotationSession().putUserData(annotationKey, Boolean.TRUE); } }
Example #2
Source File: LogView.java From logviewer with Apache License 2.0 | 6 votes |
/** * Prints the message to console */ private void printMessageToConsole(String line) { final ConsoleView console = getConsole(); final LogFilterModel.MyProcessingResult processingResult = myLogFilterModel.processLine(line); if (processingResult.isApplicable()) { final Key key = processingResult.getKey(); if (key != null) { ConsoleViewContentType type = ConsoleViewContentType.getConsoleViewType(key); if (type != null) { final String messagePrefix = processingResult.getMessagePrefix(); if (messagePrefix != null) { String formattedPrefix = logFormatter.formatPrefix(messagePrefix); if (console != null) { console.print(formattedPrefix, type); } } String formattedMessage = logFormatter.formatMessage(line); if (console != null) { console.print(formattedMessage + "\n", type); } } } } }
Example #3
Source File: FileIndexCaches.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @param dataHolderKey Main data to cache * @param dataHolderNames Cache extracted name Set */ static public synchronized <T> Map<String, List<T>> getSetDataCache(@NotNull final Project project, @NotNull Key<CachedValue<Map<String, List<T>>>> dataHolderKey, final @NotNull Key<CachedValue<Set<String>>> dataHolderNames, @NotNull final ID<String, T> ID, @NotNull final GlobalSearchScope scope) { return CachedValuesManager.getManager(project).getCachedValue( project, dataHolderKey, () -> { Map<String, List<T>> items = new HashMap<>(); final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance(); getIndexKeysCache(project, dataHolderNames, ID).forEach(service -> items.put(service, fileBasedIndex.getValues(ID, service, scope)) ); return CachedValueProvider.Result.create(items, getModificationTrackerForIndexId(project, ID)); }, false ); }
Example #4
Source File: GaugeOutputToGeneralTestEventsProcessor.java From Intellij-Plugin with Apache License 2.0 | 6 votes |
@Override protected boolean processServiceMessages(String text, Key outputType, ServiceMessageVisitor visitor) throws ParseException { this.outputType = outputType; this.visitor = visitor; if (text.startsWith("{")) { ExecutionEvent event = new GsonBuilder().create().fromJson(text, ExecutionEvent.class); for (EventProcessor processor : processors) if (processor.canProcess(event)) return processor.process(event); } if (text.trim().startsWith("Process finished with exit code") && unexpectedEndProcessor.canProcess(null)) unexpectedEndProcessor.process(new ExecutionEvent() {{ result = new ExecutionResult() {{ status = SUCCESS.equals(handler.getExitCode()) ? ExecutionEvent.SKIP : ExecutionEvent.FAIL; }}; }}); return super.processServiceMessages(text, outputType, visitor); }
Example #5
Source File: CppHighlightingPassFactoryBase.java From CppTools with Apache License 2.0 | 6 votes |
public void doApplyInformationToEditor() { if (command != null && command.isUpToDate()) { // if (!command.hasReadyResult()) { // assert false; // return; // } Key<Long> updateMarkKey = getUpdateMarkKey(); Long integer = editor.getUserData(updateMarkKey); long count = PsiManager.getInstance(psiFile.getProject()).getModificationTracker().getModificationCount(); if (integer != null && integer == count) { return; } addMarkers(); editor.putUserData(updateMarkKey, count); if (HighlightUtils.debug) { HighlightUtils.trace(psiFile, editor, "Applied information:"); } } }
Example #6
Source File: BsProcessHandler.java From reasonml-idea-plugin with MIT License | 5 votes |
@Override public final void notifyTextAvailable(@NotNull final String text, @NotNull final Key outputType) { String cleanedText = SystemInfo.isWindows ? text.replace("┆", "|") : text; StringBuilder sb = new StringBuilder(); m_ansiEscapeDecoder.escapeText(cleanedText, outputType, (chunk, attributes) -> { sb.append(chunk); super.notifyTextAvailable(chunk, attributes); }); if (m_listener != null) { m_listener.onRawTextAvailable(sb.toString()); } }
Example #7
Source File: LogView.java From logviewer with Apache License 2.0 | 5 votes |
@NotNull @Override public MyProcessingResult processLine(String line) { LogCatMessage message = null; String continuation = null; boolean validContinuation = false; try { message = AndroidLogcatFormatter.tryParseMessage(line); continuation = message == null ? AndroidLogcatFormatter.tryParseContinuation(line) : null; validContinuation = continuation != null && this.myPrevHeader != null; } catch (Exception ignored) { } if (message == null && !validContinuation) { return new MyProcessingResult(ProcessOutputTypes.STDOUT, canAcceptMessage(line), null); } else { if (message != null) { this.myPrevHeader = message.getHeader(); this.myCustomApplicable = this.isMessageApplicable(message); this.myMessageSoFar.setLength(0); } boolean isApplicable = this.myCustomApplicable; if (!isApplicable) { this.myMessageSoFar.append(line); this.myMessageSoFar.append('\n'); } Key key = AndroidLogcatUtils.getProcessOutputType(this.myPrevHeader.getLogLevel()); MyProcessingResult result = new MyProcessingResult(key, isApplicable, this.myMessageSoFar.toString()); if (isApplicable) { this.myMessageSoFar.setLength(0); } return result; } }
Example #8
Source File: NodeRunner.java From vue-for-idea with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @param commandLine command line to sdk * @param timeoutInMilliseconds timeout * @return process output * @throws ExecutionException */ @NotNull public static ProcessOutput execute(@NotNull GeneralCommandLine commandLine,ProcessListener listener, int timeoutInMilliseconds) throws ExecutionException { LOG.info("Running node command: " + commandLine.getCommandLineString()); Process process = commandLine.createProcess(); OSProcessHandler processHandler = new ColoredProcessHandler(process, commandLine.getCommandLineString(), Charsets.UTF_8); final ProcessOutput output = new ProcessOutput(); processHandler.addProcessListener(new ProcessAdapter() { public void onTextAvailable(ProcessEvent event, Key outputType) { if (outputType.equals(ProcessOutputTypes.STDERR)) { output.appendStderr(event.getText()); if(listener!=null){ listener.onError(processHandler,event.getText()); } } else if (!outputType.equals(ProcessOutputTypes.SYSTEM)) { output.appendStdout(event.getText()); if(listener!=null){ listener.onOutput(processHandler,event.getText()); } }else if(outputType.equals(ProcessOutputTypes.SYSTEM)){ if(listener!=null){ listener.onCommand(processHandler,event.getText()); } } } }); processHandler.startNotify(); if (processHandler.waitFor(timeoutInMilliseconds)) { output.setExitCode(process.exitValue()); } else { processHandler.destroyProcess(); output.setTimeout(); } if (output.isTimeout()) { throw new ExecutionException("Command '" + commandLine.getCommandLineString() + "' is timed out."); } return output; }
Example #9
Source File: LSPPsiElement.java From lsp4intellij with Apache License 2.0 | 5 votes |
public <T> void putCopyableUserData(Key<T> key, T value) { boolean control = true; while (control) { KeyFMap map = getUserMap(); KeyFMap copyableMap = map.get(COPYABLE_USER_MAP_KEY); if (copyableMap == null) copyableMap = KeyFMap.EMPTY_MAP; KeyFMap newCopyableMap = (value == null) ? copyableMap.minus(key) : copyableMap.plus(key, value); KeyFMap newMap = (newCopyableMap.isEmpty()) ? map.minus(COPYABLE_USER_MAP_KEY) : map.plus(COPYABLE_USER_MAP_KEY, newCopyableMap); if ((newMap.equalsByReference(map)) || changeUserMap(map, newMap)) control = false; } }
Example #10
Source File: PsiElementDelegate.java From intellij-haxe with Apache License 2.0 | 5 votes |
@Override @Nullable @Contract( pure = true ) public <T> T getCopyableUserData(Key<T> key) { return wrappedElement.getCopyableUserData(key); }
Example #11
Source File: BuckCommandHandler.java From buck with Apache License 2.0 | 5 votes |
/** * Notify listeners for each complete line. Note that in the case of stderr, the last line is * saved. */ protected void notifyLines(final Key outputType, final Iterable<String> lines) { if (outputType == ProcessOutputTypes.STDERR) { StringBuilder stderr = new StringBuilder(); for (String line : lines) { // Check if the line has at least one character or digit if (CHARACTER_DIGITS_PATTERN.matcher(line).matches()) { stderr.append(line); } } if (stderr.length() != 0) { buckModule.getBuckEventsConsumer().consumeConsoleEvent(stderr.toString()); } } }
Example #12
Source File: BashFunctionProcessor.java From BashSupport with Apache License 2.0 | 5 votes |
public <T> T getHint(@NotNull Key<T> key) { if (key.equals(Keys.VISITED_SCOPES_KEY)) { return (T) visitedElements; } if (key.equals(Keys.FILE_WALK_GO_DEEP)) { return (T) Boolean.FALSE; } return null; }
Example #13
Source File: DuneOutputListener.java From reasonml-idea-plugin with MIT License | 5 votes |
@Override public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) { String text = event.getText(); /* File "CmtExtractor.ml", line 80, characters 67-70: Error: Unbound value cmt Hint: Did you mean cmtx? */ if (text.startsWith("File")) { m_latestInfo = extractExtendedFilePositions(text); if (m_latestInfo != null) { m_latestInfo.isError = false; } } else if (text.startsWith("Error:")) { if (m_latestInfo != null) { m_latestInfo.isError = true; m_latestInfo.message = text.substring(6); } } else if (text.startsWith("Hint:")) { if (m_latestInfo != null) { m_latestInfo.message += " (" + text + ")"; } } //m_previousText = text; }
Example #14
Source File: CsvTableEditorSwingTest.java From intellij-csv-validator with Apache License 2.0 | 5 votes |
public void testUserDataHolder() { Key<String> testKey = new Key<>("myKey"); String value = "This is just a test"; assertNull(fileEditor.getUserData(testKey)); fileEditor.putUserData(testKey, value); assertEquals(value, fileEditor.getUserData(testKey)); }
Example #15
Source File: ConfigDiscoveryTest.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Before public void setUp() { discovery = new ConfigDiscovery(fileBasedIndex); when(project.getUserData(any(Key.class))).thenReturn(globalSearchScope); when(psiClass.getProject()).thenReturn(project); when(psiClass.getContainingFile()).thenReturn(psiFile); when(psiFile.getVirtualFile()).thenReturn(virtualFile); when(virtualFile.getParent()).thenReturn(parentVirtualFile); when(parentVirtualFile.getCanonicalPath()).thenReturn("/a/b/c/d/e/f"); }
Example #16
Source File: FlutterLogEntryParser.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable FlutterLogEntry parseDaemonEvent(@NotNull ProcessEvent event, @Nullable Key outputType) { // TODO(pq): process outputType final String text = event.getText(); if (text.isEmpty()) return null; return parseDaemonEvent(text); }
Example #17
Source File: ExecutionOutputParser.java From idea-gitignore with MIT License | 5 votes |
/** * Handles single output line. * * @param text execution response * @param outputType output type */ public void onTextAvailable(@NotNull String text, @NotNull Key outputType) { if (outputType == ProcessOutputTypes.SYSTEM) { return; } if (outputType == ProcessOutputTypes.STDERR) { errorsReported = true; return; } ContainerUtil.addIfNotNull(outputs, parseOutput(StringUtil.trimEnd(text, "\n").trim())); }
Example #18
Source File: GitPushRejectedDetector.java From GitToolBox with Apache License 2.0 | 5 votes |
@Override public void onLineAvailable(String line, Key outputType) { Matcher matcher = REJECTED_PATTERN.matcher(line); if (matcher.matches()) { rejectedRefs.add(createRejected(matcher)); } }
Example #19
Source File: HaxeMacroUtil.java From intellij-haxe with Apache License 2.0 | 5 votes |
public static Set<HaxeComponentName> findVariables(@Nullable PsiElement at) { if (at == null) { return Collections.emptySet(); } final Set<HaxeComponentName> result = new THashSet<HaxeComponentName>(); PsiTreeUtil.treeWalkUp(new PsiScopeProcessor() { @Override public boolean execute(@NotNull PsiElement element, ResolveState state) { if (element instanceof HaxeNamedComponent) { final HaxeNamedComponent haxeNamedComponent = (HaxeNamedComponent)element; if (haxeNamedComponent.getComponentName() != null && HaxeComponentType.isVariable(HaxeComponentType.typeOf(haxeNamedComponent))) { result.add(haxeNamedComponent.getComponentName()); } } return true; } @Override public <T> T getHint(@NotNull Key<T> hintKey) { return null; } @Override public void handleEvent(Event event, @Nullable Object associated) { } }, at, null, ResolveState.initial()); return result; }
Example #20
Source File: BazelTestRunner.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Connector(ProcessHandler handler) { listener = new ProcessAdapter() { @Override public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) { if (!outputType.equals(ProcessOutputTypes.STDOUT)) { return; } final String text = event.getText(); if (FlutterSettings.getInstance().isVerboseLogging()) { LOG.info("[<-- " + text.trim() + "]"); } stdoutParser.appendOutput(text); for (String line : stdoutParser.getAvailableLines()) { if (line.startsWith("[{")) { line = line.trim(); final String json = line.substring(1, line.length() - 1); dispatchJson(json); } } } @Override public void processWillTerminate(@NotNull ProcessEvent event, boolean willBeDestroyed) { handler.removeProcessListener(listener); } }; handler.addProcessListener(listener); }
Example #21
Source File: FlutterTestRunner.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Connector(ProcessHandler handler) { listener = new ProcessAdapter() { @Override public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) { if (!outputType.equals(ProcessOutputTypes.STDOUT)) { return; } final String text = event.getText(); if (FlutterSettings.getInstance().isVerboseLogging()) { LOG.info("[<-- " + text.trim() + "]"); } stdoutParser.appendOutput(text); for (String line : stdoutParser.getAvailableLines()) { if (line.startsWith("[{")) { line = line.trim(); final String json = line.substring(1, line.length() - 1); dispatchJson(json); } } } @Override public void processWillTerminate(@NotNull ProcessEvent event, boolean willBeDestroyed) { handler.removeProcessListener(listener); } }; handler.addProcessListener(listener); }
Example #22
Source File: GitRevListLeftRightCounter.java From GitToolBox with Apache License 2.0 | 5 votes |
@Override public void onLineAvailable(String line, Key outputType) { if (aheadLine(line)) { onAheadLine(line); } else if (behindLine(line)) { onBehindLine(line); } }
Example #23
Source File: BuckJsonCommandHandler.java From buck with Apache License 2.0 | 5 votes |
@Override protected void onTextAvailable(String text, Key outputType) { if (ProcessOutputTypes.STDOUT.equals(outputType)) { mStdoutBuilder.append(text); } else if (ProcessOutputTypes.STDERR.equals(outputType)) { mStderrBuilder.append(text); } }
Example #24
Source File: FlutterLogEntryParser.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Nullable FlutterLogEntry parseDaemonEvent(@NotNull ProcessEvent event, @Nullable Key outputType) { // TODO(pq): process outputType final String text = event.getText(); if (text.isEmpty()) return null; return parseDaemonEvent(text); }
Example #25
Source File: JscsRunner.java From jscs-plugin with MIT License | 5 votes |
@NotNull private static ProcessOutput execute(@NotNull GeneralCommandLine commandLine, int timeoutInMilliseconds) throws ExecutionException { LOG.info("Running jscs command: " + commandLine.getCommandLineString()); Process process = commandLine.createProcess(); OSProcessHandler processHandler = new ColoredProcessHandler(process, commandLine.getCommandLineString(), Charsets.UTF_8); final ProcessOutput output = new ProcessOutput(); processHandler.addProcessListener(new ProcessAdapter() { public void onTextAvailable(ProcessEvent event, Key outputType) { if (outputType.equals(ProcessOutputTypes.STDERR)) { output.appendStderr(event.getText()); } else if (!outputType.equals(ProcessOutputTypes.SYSTEM)) { output.appendStdout(event.getText()); } } }); processHandler.startNotify(); if (processHandler.waitFor(timeoutInMilliseconds)) { output.setExitCode(process.exitValue()); } else { processHandler.destroyProcess(); output.setTimeout(); } if (output.isTimeout()) { throw new ExecutionException("Command '" + commandLine.getCommandLineString() + "' is timed out."); } return output; }
Example #26
Source File: PantsIntegrationTestCase.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
@NotNull protected RunResult runWithConfiguration(RunConfiguration configuration) { PantsMakeBeforeRun.replaceDefaultMakeWithPantsMake(configuration); PantsMakeBeforeRun.setRunConfigurationWorkingDirectory(configuration); PantsJUnitRunnerAndConfigurationSettings runnerAndConfigurationSettings = new PantsJUnitRunnerAndConfigurationSettings(configuration); ExecutionEnvironmentBuilder environmentBuilder = ExecutionUtil.createEnvironment(DefaultRunExecutor.getRunExecutorInstance(), runnerAndConfigurationSettings); ExecutionEnvironment environment = environmentBuilder.build(); List<String> output = new ArrayList<>(); List<String> errors = new ArrayList<>(); ProcessAdapter processAdapter = new ProcessAdapter() { @Override public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) { if (outputType == ProcessOutputTypes.STDOUT) { output.add(event.getText()); } else if (outputType == ProcessOutputTypes.STDERR) { errors.add(event.getText()); } } }; ProgramRunnerUtil.executeConfiguration(environment, false, false); OSProcessHandler handler = (OSProcessHandler) environment.getContentToReuse().getProcessHandler(); handler.addProcessListener(processAdapter); assertTrue(handler.waitFor()); return new RunResult(handler.getExitCode(), output, errors); }
Example #27
Source File: ResultCallbackBuckHandler.java From buck with Apache License 2.0 | 5 votes |
@Override protected void notifyLines(Key outputType, Iterable<String> lines) { super.notifyLines(outputType, lines); if (outputType == ProcessOutputTypes.STDOUT) { for (String line : lines) { stdout.append(line); } } }
Example #28
Source File: BlazeConsoleServiceImpl.java From intellij with Apache License 2.0 | 5 votes |
@Override public void print(String text, ConsoleViewContentType contentType) { Key<?> key = contentType == ConsoleViewContentType.ERROR_OUTPUT ? ProcessOutputTypes.STDERR : ProcessOutputTypes.STDOUT; ansiEscapeDecoder.escapeText(text, key, this); }
Example #29
Source File: EditorSettingsManager.java From editorconfig-jetbrains with MIT License | 5 votes |
private static <T> void applyConfigValueToUserData(VirtualFile file, Key<T> userDataKey, String editorConfigKey, String configValue, Map<String, T> configMap) { if (configValue.isEmpty()) { file.putUserData(userDataKey, null); } else { final T data = configMap.get(configValue); if (data == null) { LOG.warn(Utils.invalidConfigMessage(configValue, editorConfigKey, file.getCanonicalPath())); } else { file.putUserData(userDataKey, data); LOG.debug("Applied " + editorConfigKey + " settings for: " + file.getCanonicalPath()); } } }
Example #30
Source File: HaxeCompilerProcessHandler.java From intellij-haxe with Apache License 2.0 | 5 votes |
@Override public void coloredChunksAvailable(@NotNull List<Pair<String, Key>> chunks) { List<String> lines = new ArrayList<String>(); StringBuilder line = new StringBuilder(); for (Pair<String, Key> chunk : chunks) { // TODO: Spit out the colored chunks... somehow... coloredTextAvailable(chunk.getFirst(), chunk.getSecond()); // Combine/split chunks into lines for error processing. String part = chunk.getFirst(); int nl; while (null != part && !part.isEmpty() && (nl = part.indexOf('\n')) >= 0) { line.append(part.substring(0, nl + 1)); lines.add(line.toString()); line.setLength(0); part = part.substring(nl + 1); } if (null != part && !part.isEmpty()) { line.append(part); } } if (0 != line.length()) { lines.add(line.toString()); } context.handleOutput(lines.toArray(new String[0])); }