Java Code Examples for com.intellij.psi.util.CachedValuesManager#getManager()
The following examples show how to use
com.intellij.psi.util.CachedValuesManager#getManager() .
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: HaxeHierarchyUtils.java From intellij-haxe with Apache License 2.0 | 6 votes |
/** * Retrieve the list of classes implemented in the given File. * * @param psiRoot - File to search. * @return A List of found classes, or an empty array if none. */ @NotNull public static List<HaxeClass> getClassList(@NotNull HaxeFile psiRoot) { CachedValuesManager manager = CachedValuesManager.getManager(psiRoot.getProject()); ArrayList<HaxeClass> classList = manager.getCachedValue(psiRoot, () -> { ArrayList<HaxeClass> classes = new ArrayList<>(); for (PsiElement child : psiRoot.getChildren()) { if (child instanceof HaxeClass) { classes.add((HaxeClass)child); } } return new CachedValueProvider.Result<>(classes, psiRoot); }); return classList; }
Example 2
Source File: WeaveEditor.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
protected void runPreview(boolean forceRefresh) { if (!isAutoSync() && !forceRefresh) return; final Map<String, Object> payload = new HashMap<String, Object>(); Map<String, Map<String, Object>> flowVars = new HashMap<String, Map<String, Object>>(); /* 1. Get input from tabs - if payload exists, use payload, otherwise put in the Map 2. Get text from DW 3. Run preview, put the output to the output tab */ int count = inputTabs.getTabCount(); for (int index = 0; index < count; index++) { String title = inputTabs.getTitleAt(index); Editor editor = editors.get(title); Document document = editor.getDocument(); String text = document.getText(); String contentType = contentTypes.get(title); Map<String, Object> content = WeavePreview.createContent(contentType, text); if ("payload".equalsIgnoreCase(title)) { payload.clear(); payload.putAll(content); } else { flowVars.put(title, content); } } final CachedValuesManager manager = CachedValuesManager.getManager(project); List<String> melFunctions = manager.getCachedValue(psiFile, MEL_STRINGS_KEY, new MelStringsCachedProvider()); String dwScript = this.textEditor.getEditor().getDocument().getText(); String output = WeavePreview.runPreview(module, dwScript, payload, flowVars, flowVars, flowVars, flowVars, flowVars, melFunctions); if (output != null) editors.get("output").getDocument().setText(output); }
Example 3
Source File: PsiErrorElementUtil.java From consulo with Apache License 2.0 | 5 votes |
private static boolean hasErrors(@Nonnull final PsiFile psiFile) { CachedValuesManager cachedValuesManager = CachedValuesManager.getManager(psiFile.getProject()); return cachedValuesManager.getCachedValue(psiFile, CONTAINS_ERROR_ELEMENT, () -> { boolean error = hasErrorElements(psiFile); return CachedValueProvider.Result.create(error, psiFile); }, false); }
Example 4
Source File: HaxeImportModel.java From intellij-haxe with Apache License 2.0 | 4 votes |
public HaxeImportModel(@NotNull HaxeImportStatement importStatement) { this.basePsi = importStatement; this.cacheManager = CachedValuesManager.getManager(importStatement.getProject()); }
Example 5
Source File: MakefileIdentifierReference.java From CppTools with Apache License 2.0 | 4 votes |
private CachedValue<Map<String, Object>> getDeclarationsMap() { PsiFile containingFile = myElement.getContainingFile(); PsiFile originalFile = containingFile.getOriginalFile(); if (originalFile != null) containingFile = originalFile; final PsiFile psiFile = containingFile; CachedValue<Map<String, Object>> mapCachedValue = psiFile.getUserData(ourTargets); if (mapCachedValue == null) { CachedValuesManager cachedValuesManager = CachedValuesManager.getManager(psiFile.getManager().getProject()); psiFile.putUserData(ourTargets, mapCachedValue = cachedValuesManager.createCachedValue(new CachedValueProvider<Map<String, Object>>() { public Result<Map<String, Object>> compute() { final Map<String, Object> result = new THashMap<String, Object>(); psiFile.acceptChildren(new PsiElementVisitor() { @Override public void visitElement(PsiElement element) { if (element instanceof MakefileNamedElement) { PsiElement name = ((MakefileNamedElement) element).findNameElement(); if (name == null) return; String key = name.getText(); Object o = result.get(key); if (o == null) result.put(key, element); else if (o instanceof PsiElement) { result.put(key, new Object[]{element, o}); } else { Object[] prevArr = (Object[]) o; Object[] arr = new Object[prevArr.length + 1]; System.arraycopy(prevArr, 0, arr, 0, prevArr.length); arr[prevArr.length] = element; result.put(key, arr); } } else { element.acceptChildren(this); } } public void visitReferenceExpression(PsiReferenceExpression expression) { } }); return new Result<Map<String, Object>>(result, psiFile); } }, false)); } return mapCachedValue; }
Example 6
Source File: ClasspathUtils.java From mule-intellij-plugins with Apache License 2.0 | 3 votes |
private static List<URL> getURLsForModule(Module module) throws Exception { final CachedValuesManager manager = CachedValuesManager.getManager(module.getProject()); List<URL> loaderUrls = manager.getParameterizedCachedValue(module, URLS_KEY, new ClasspathUtils.UrlsCachedProvider(), false, module); return loaderUrls; }