Java Code Examples for com.intellij.openapi.vfs.VirtualFile#putUserDataIfAbsent()
The following examples show how to use
com.intellij.openapi.vfs.VirtualFile#putUserDataIfAbsent() .
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: LightFileDocumentManager.java From consulo with Apache License 2.0 | 5 votes |
@Override public Document getDocument(@Nonnull VirtualFile file) { Document document = file.getUserData(MOCK_DOC_KEY); if (document == null) { if (file.isDirectory() || isBinaryWithoutDecompiler(file)) return null; CharSequence text = LoadTextUtil.loadText(file); document = myFactory.apply(text); document.putUserData(MOCK_VIRTUAL_FILE_KEY, file); document = file.putUserDataIfAbsent(MOCK_DOC_KEY, document); } return document; }
Example 2
Source File: LazyRangeMarkerFactoryImpl.java From consulo with Apache License 2.0 | 5 votes |
private static void addToLazyMarkersList(@Nonnull LazyMarker marker, @Nonnull VirtualFile file) { WeakList<LazyMarker> markers = getMarkers(file); if (markers == null) { markers = file.putUserDataIfAbsent(LAZY_MARKERS_KEY, new WeakList<>()); } markers.add(marker); }
Example 3
Source File: MockFileDocumentManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public Document getDocument(@Nonnull VirtualFile file) { Document document = file.getUserData(MOCK_DOC_KEY); if (document == null) { if (file.isDirectory() || isBinaryWithoutDecompiler(file)) return null; CharSequence text = LoadTextUtil.loadText(file); document = myFactory.fun(text); document.putUserData(MOCK_VIRTUAL_FILE_KEY, file); document = file.putUserDataIfAbsent(MOCK_DOC_KEY, document); } return document; }
Example 4
Source File: SmartPointerManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
private <E extends PsiElement> void trackPointer(@Nonnull SmartPsiElementPointerImpl<E> pointer, @Nonnull VirtualFile containingFile) { SmartPointerElementInfo info = pointer.getElementInfo(); if (!(info instanceof SelfElementInfo)) return; SmartPointerTracker.PointerReference reference = new SmartPointerTracker.PointerReference(pointer, containingFile, POINTERS_KEY); while (true) { SmartPointerTracker pointers = getTracker(containingFile); if (pointers == null) { pointers = containingFile.putUserDataIfAbsent(POINTERS_KEY, new SmartPointerTracker()); } if (pointers.addReference(reference, pointer)) { break; } } }