com.intellij.openapi.vfs.pointers.VirtualFilePointerManager Java Examples

The following examples show how to use com.intellij.openapi.vfs.pointers.VirtualFilePointerManager. 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: HistoryEntry.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static HistoryEntry createHeavy(@Nonnull Project project,
                                       @Nonnull VirtualFile file,
                                       @Nonnull FileEditorProvider[] providers,
                                       @Nonnull FileEditorState[] states,
                                       @Nonnull FileEditorProvider selectedProvider) {
  if (project.isDisposed()) return createLight(file, providers, states, selectedProvider);

  Disposable disposable = Disposable.newDisposable();
  VirtualFilePointer pointer = VirtualFilePointerManager.getInstance().create(file, disposable, null);

  HistoryEntry entry = new HistoryEntry(pointer, selectedProvider, disposable);
  for (int i = 0; i < providers.length; i++) {
    FileEditorProvider provider = providers[i];
    FileEditorState state = states[i];
    if (provider != null && state != null) {
      entry.putState(provider, state);
    }
  }
  return entry;
}
 
Example #2
Source File: CompilerConfigurationImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void setCompilerOutputUrl(@Nullable String compilerOutputUrl) {
  myOutputDirPointer = compilerOutputUrl == null ? null : VirtualFilePointerManager.getInstance().create(compilerOutputUrl, myProject, null);

  myCompilerOutputWatchRequest =
          compilerOutputUrl == null ? null : LocalFileSystem.getInstance().replaceWatchedRoot(myCompilerOutputWatchRequest, ProjectRootManagerImpl.extractLocalPath(compilerOutputUrl), true);
}
 
Example #3
Source File: BackgroundTaskByVfsChangeManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void loadState(Element state) {
  for (Element element : state.getChildren("task")) {
    String url = element.getAttributeValue("url");
    String name = element.getAttributeValue("name");
    String providerName = element.getAttributeValue("provider-name");
    boolean enabled = Boolean.valueOf(element.getAttributeValue("enabled"));

    VirtualFilePointer virtualFilePointer = VirtualFilePointerManager.getInstance().create(url, this, null);

    BackgroundTaskByVfsParametersImpl parameters = new BackgroundTaskByVfsParametersImpl(myProject);

    BackgroundTaskByVfsChangeTaskImpl task = new BackgroundTaskByVfsChangeTaskImpl(myProject, virtualFilePointer, providerName, name, parameters, this);
    task.setEnabled(enabled);

    Element parametersElement = element.getChild("parameters");
    if (parametersElement != null) {
      ReplacePathToMacroMap replaceMacroToPathMap = task.createReplaceMacroToPathMap();

      replaceMacroToPathMap.substitute(parametersElement, false, true);

      XmlSerializer.deserializeInto(parameters, parametersElement);
    }

    registerTask(task);
  }
}
 
Example #4
Source File: BackgroundTaskByVfsChangeTaskImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public BackgroundTaskByVfsChangeTaskImpl(@Nonnull Project project,
                                         @Nonnull VirtualFile virtualFile,
                                         @Nonnull BackgroundTaskByVfsChangeManagerImpl manager,
                                         @Nonnull BackgroundTaskByVfsChangeProvider provider,
                                         @Nonnull String name,
                                         @Nonnull BackgroundTaskByVfsParameters parameters) {
  this(project, VirtualFilePointerManager.getInstance().create(virtualFile, manager, null), parameters, provider.getTemplateName(), name, provider, manager);

}
 
Example #5
Source File: FileOrDirectoryTreeNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected FileOrDirectoryTreeNode(@Nonnull String path,
                                  @Nonnull SimpleTextAttributes invalidAttributes,
                                  @Nonnull Project project,
                                  @javax.annotation.Nullable String parentPath) {
  String preparedPath = path.replace(File.separatorChar, '/');
  String url = VirtualFileManager.constructUrl(LocalFileSystem.getInstance().getProtocol(), preparedPath);
  setUserObject(VirtualFilePointerManager.getInstance().create(url, this, this));
  myFile = new File(getFilePath());
  myInvalidAttributes = invalidAttributes;
  myProject = project;
  myName = parentPath == null ? myFile.getAbsolutePath() : myFile.getName();
}
 
Example #6
Source File: CoreApplicationEnvironment.java    From consulo with Apache License 2.0 5 votes vote down vote up
public CoreApplicationEnvironment(@Nonnull Disposable parentDisposable) {
  myParentDisposable = parentDisposable;

  myFileTypeRegistry = new CoreFileTypeRegistry();

  myApplication = createApplication(myParentDisposable);
  ApplicationManager.setApplication(myApplication, myParentDisposable);
  myLocalFileSystem = createLocalFileSystem();
  myJarFileSystem = createJarFileSystem();

  final InjectingContainer appContainer = myApplication.getInjectingContainer();
  registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(DocumentImpl::new, null));

  VirtualFileSystem[] fs = {myLocalFileSystem, myJarFileSystem};
  VirtualFileManagerImpl virtualFileManager = new VirtualFileManagerImpl(myApplication, fs);
  registerComponentInstance(appContainer, VirtualFileManager.class, virtualFileManager);

  registerApplicationExtensionPoint(ASTLazyFactory.EP.getExtensionPointName(), ASTLazyFactory.class);
  registerApplicationExtensionPoint(ASTLeafFactory.EP.getExtensionPointName(), ASTLeafFactory.class);
  registerApplicationExtensionPoint(ASTCompositeFactory.EP.getExtensionPointName(), ASTCompositeFactory.class);

  addExtension(ASTLazyFactory.EP.getExtensionPointName(), new DefaultASTLazyFactory());
  addExtension(ASTLeafFactory.EP.getExtensionPointName(), new DefaultASTLeafFactory());
  addExtension(ASTCompositeFactory.EP.getExtensionPointName(), new DefaultASTCompositeFactory());

  registerApplicationService(EncodingManager.class, new CoreEncodingRegistry());
  registerApplicationService(VirtualFilePointerManager.class, createVirtualFilePointerManager());
  registerApplicationService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
  registerApplicationService(ReferenceProvidersRegistry.class, new MockReferenceProvidersRegistry());
  registerApplicationService(StubTreeLoader.class, new CoreStubTreeLoader());
  registerApplicationService(PsiReferenceService.class, new PsiReferenceServiceImpl());
  registerApplicationService(MetaDataRegistrar.class, new MetaRegistry());

  registerApplicationService(ProgressManager.class, createProgressIndicatorProvider());

  registerApplicationService(JobLauncher.class, createJobLauncher());
  registerApplicationService(CodeFoldingSettings.class, new CodeFoldingSettings());
  registerApplicationService(CommandProcessor.class, new CoreCommandProcessor());
}
 
Example #7
Source File: VirtualFilePointerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void dispose() {
  FilePointerPartNode node = checkDisposed(myNode);
  if (node.incrementUsageCount(-1) == 0) {
    myTraceableDisposable.kill("URL when die: " + this);
    VirtualFilePointerManager pointerManager = VirtualFilePointerManager.getInstance();
    if (pointerManager instanceof VirtualFilePointerManagerImpl) {
      ((VirtualFilePointerManagerImpl)pointerManager).removeNodeFrom(this);
    }
  }
}
 
Example #8
Source File: HistoryEntry.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static HistoryEntry createHeavy(@Nonnull Project project, @Nonnull Element e) throws InvalidDataException {
  if (project.isDisposed()) return createLight(project, e);

  EntryData entryData = parseEntry(project, e);

  Disposable disposable = Disposable.newDisposable();
  VirtualFilePointer pointer = VirtualFilePointerManager.getInstance().create(entryData.url, disposable, null);

  HistoryEntry entry = new HistoryEntry(pointer, entryData.selectedProvider, disposable);
  for (Pair<FileEditorProvider, FileEditorState> state : entryData.providerStates) {
    entry.putState(state.first, state.second);
  }
  return entry;
}
 
Example #9
Source File: ModuleCompilerPathsManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void loadState(Element element) {
  myInheritOutput = false;
  myExcludeOutput = Boolean.valueOf(element.getAttributeValue(EXCLUDE, "true"));
  for (Element child2 : element.getChildren()) {
    final String moduleUrl = child2.getAttributeValue(URL);
    final String type = child2.getAttributeValue(TYPE);

    myVirtualFilePointers.put(type, VirtualFilePointerManager.getInstance().create(moduleUrl, this, null));
  }
}
 
Example #10
Source File: ModuleCompilerPathsManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void setCompilerOutputUrl(@Nonnull ContentFolderTypeProvider contentFolderType, @Nullable String compilerOutputUrl) {
  if (myInheritOutput) {
    throw new IllegalArgumentException();
  }
  if (compilerOutputUrl == null) {
    return;
  }

  myVirtualFilePointers.put(contentFolderType.getId(), VirtualFilePointerManager.getInstance().create(compilerOutputUrl, this, null));
}
 
Example #11
Source File: VirtualFilePointerTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();
  myVirtualFilePointerManager = (VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance();
  numberOfPointersBefore = myVirtualFilePointerManager.numberOfPointers();
  numberOfListenersBefore = myVirtualFilePointerManager.numberOfListeners();
}
 
Example #12
Source File: OrderRootsCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
public VirtualFilePointerContainer setCachedRoots(OrderRootType rootType, int flags, Collection<String> urls) {
  final VirtualFilePointerContainer container = VirtualFilePointerManager.getInstance().createContainer(myParentDisposable);
  for (String url : urls) {
    container.add(url);
  }
  myRoots.put(new CacheKey(rootType, flags), container);
  return container;
}
 
Example #13
Source File: LibraryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private VirtualFilePointerContainer getOrCreateExcludedRoots() {
  VirtualFilePointerContainer excludedRoots = myExcludedRoots;
  if (excludedRoots == null) {
    myExcludedRoots = excludedRoots = VirtualFilePointerManager.getInstance().createContainer(myPointersDisposable);
  }
  return excludedRoots;
}
 
Example #14
Source File: LibraryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private VirtualFilePointerContainer getOrCreateContainer(@Nonnull OrderRootType rootType) {
  VirtualFilePointerContainer roots = myRoots.get(rootType);
  if (roots == null) {
    roots = VirtualFilePointerManager.getInstance().createContainer(myPointersDisposable, getListener());
    myRoots.put(rootType, roots);
  }
  return roots;
}
 
Example #15
Source File: ContentFolderImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected ContentFolderImpl(@Nonnull VirtualFilePointer filePointer,
                            @Nullable Map<String, Object> properties,
                            @Nonnull ContentFolderTypeProvider contentFolderType,
                            @Nonnull ContentEntryImpl contentEntry) {
  super(contentEntry.getModuleRootLayer());
  myContentEntry = contentEntry;
  myContentFolderType = contentFolderType;
  myProperties = properties;
  myFilePointer = VirtualFilePointerManager.getInstance().duplicate(filePointer, this, null);
}
 
Example #16
Source File: ContentFolderImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
ContentFolderImpl(@Nonnull String url,
                  @Nonnull ContentFolderTypeProvider contentFolderType,
                  @Nullable Map<String, Object> map,
                  @Nonnull ContentEntryImpl contentEntry) {
  super(contentEntry.getModuleRootLayer());
  myContentEntry = contentEntry;
  myContentFolderType = contentFolderType;
  myProperties = map == null ? null : new HashMap<String, Object>(map);
  myFilePointer = VirtualFilePointerManager.getInstance().create(url, this, null);
}
 
Example #17
Source File: ContentFolderImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
ContentFolderImpl(@Nonnull VirtualFile file,
                  @Nonnull ContentFolderTypeProvider contentFolderType,
                  @Nonnull ContentEntryImpl contentEntry) {
  super(contentEntry.getModuleRootLayer());
  myContentEntry = contentEntry;
  myContentFolderType = contentFolderType;
  myFilePointer = VirtualFilePointerManager.getInstance().create(file, this, null);
}
 
Example #18
Source File: RootsAsVirtualFilePointers.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private VirtualFilePointerContainer getOrCreateContainer(@Nonnull OrderRootType rootType) {
  VirtualFilePointerContainer roots = myRoots.get(rootType);
  if (roots == null) {
    roots = VirtualFilePointerManager.getInstance().createContainer(myParent, myListener);
    myRoots.put(rootType, roots);
  }
  return roots;
}
 
Example #19
Source File: SdkImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public SdkImpl(SdkTable sdkTable, String name, SdkTypeId sdkType) {
  mySdkTable = sdkTable;
  mySdkType = sdkType;
  myName = name;

  myRoots = new RootsAsVirtualFilePointers(true, tellAllProjectsTheirRootsAreGoingToChange, this);
  // register on VirtualFilePointerManager because we want our virtual pointers to be disposed before VFPM to avoid "pointer leaked" diagnostics fired
  Disposer.register((Disposable)VirtualFilePointerManager.getInstance(), this);
}
 
Example #20
Source File: ExcludeEntryDescription.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void setPresentableUrl(String newUrl) {
  myFilePointer = VirtualFilePointerManager.getInstance().create(VfsUtil.pathToUrl(FileUtil.toSystemIndependentName(newUrl)), myParentDisposable, null);
  final VirtualFile file = getVirtualFile();
  if (file != null) {
    myIsFile = !file.isDirectory();
  }
}
 
Example #21
Source File: ExcludeEntryDescription.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ExcludeEntryDescription(String url, boolean includeSubdirectories, boolean isFile, Disposable parent) {
  myParentDisposable = parent;
  myFilePointer = VirtualFilePointerManager.getInstance().create(url, parent, null);
  myIncludeSubdirectories = includeSubdirectories;
  myIsFile = isFile;
}
 
Example #22
Source File: ModuleImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ModuleImpl(@Nonnull String name, @Nullable String dirUrl, @Nonnull Project project) {
  super(project, "Module " + name, ExtensionAreaId.MODULE);
  myName = name;
  myProject = project;
  myDirVirtualFilePointer = dirUrl == null ? null : VirtualFilePointerManager.getInstance().create(dirUrl, this, null);
}
 
Example #23
Source File: VirtualFilePointerContainerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
VirtualFilePointerContainerImpl(@Nonnull VirtualFilePointerManager manager, @Nonnull Disposable parentDisposable, @Nullable VirtualFilePointerListener listener) {
  myTraceableDisposable = TraceableDisposable.newTraceDisposable(TRACE_CREATION && !ApplicationInfoImpl.isInStressTest());
  myVirtualFilePointerManager = manager;
  myParent = parentDisposable;
  myListener = listener;
}
 
Example #24
Source File: ContentEntryImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ContentEntryImpl(@Nonnull String url, @Nonnull ModuleRootLayerImpl m) {
  super(m);
  myRoot = VirtualFilePointerManager.getInstance().create(url, this, null);
}
 
Example #25
Source File: CoreApplicationEnvironment.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
protected VirtualFilePointerManager createVirtualFilePointerManager() {
  return new CoreVirtualFilePointerManager();
}