com.intellij.psi.impl.AnyPsiChangeListener Java Examples

The following examples show how to use com.intellij.psi.impl.AnyPsiChangeListener. 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: CSharpPartialElementManager.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Inject
public CSharpPartialElementManager(@Nonnull Project project)
{
	myProject = project;
	project.getMessageBus().connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener.Adapter()
	{
		@Override
		public void beforePsiChanged(boolean isPhysical)
		{
			myCache.clear();
		}
	});

	project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter()
	{
		@Override
		public void rootsChanged(ModuleRootEvent event)
		{
			myCache.clear();
		}
	});
}
 
Example #2
Source File: GraphQLPsiSearchHelper.java    From js-graphql-intellij-plugin with MIT License 5 votes vote down vote up
public GraphQLPsiSearchHelper(@NotNull final Project project) {
    myProject = project;
    mySettings = GraphQLSettings.getSettings(project);
    psiManager = PsiManager.getInstance(myProject);
    graphQLInjectionSearchHelper = ServiceManager.getService(GraphQLInjectionSearchHelper.class);
    injectedLanguageManager = InjectedLanguageManager.getInstance(myProject);
    graphQLConfigManager = GraphQLConfigManager.getService(myProject);
    pluginDescriptor = PluginManager.getPlugin(PluginId.getId("com.intellij.lang.jsgraphql"));

    final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(myProject);
    defaultProjectFile = (GraphQLFile) psiFileFactory.createFileFromText("Default schema file", GraphQLLanguage.INSTANCE, "");

    GlobalSearchScope defaultProjectFileScope = GlobalSearchScope.fileScope(defaultProjectFile);
    GlobalSearchScope builtInSchemaScope = GlobalSearchScope.fileScope(project, getBuiltInSchema().getVirtualFile());
    GlobalSearchScope builtInRelaySchemaScope = GlobalSearchScope.fileScope(project, getRelayModernDirectivesSchema().getVirtualFile());
    allBuiltInSchemaScopes = builtInSchemaScope
            .union(new ConditionalGlobalSearchScope(builtInRelaySchemaScope, mySettings::isEnableRelayModernFrameworkSupport))
            .union(defaultProjectFileScope)
    ;

    final FileType[] searchScopeFileTypes = GraphQLFindUsagesUtil.getService().getIncludedFileTypes().toArray(FileType.EMPTY_ARRAY);
    searchScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(myProject), searchScopeFileTypes).union(allBuiltInSchemaScopes);
    project.getMessageBus().connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener.Adapter() {
        @Override
        public void beforePsiChanged(boolean isPhysical) {
            // clear the cache on each PSI change
            fileNameToSchemaScope.clear();
        }
    });
}
 
Example #3
Source File: GraphQLReferenceService.java    From js-graphql-intellij-plugin with MIT License 5 votes vote down vote up
public GraphQLReferenceService(@NotNull final Project project) {
    psiSearchHelper = GraphQLPsiSearchHelper.getService(project);
    project.getMessageBus().connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener.Adapter() {
        @Override
        public void beforePsiChanged(boolean isPhysical) {
            // clear the cache on each PSI change
            logicalTypeNameToReference.clear();
        }
    });
}
 
Example #4
Source File: ResolveCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Inject
public ResolveCache(@Nonnull Project project) {
  project.getMessageBus().connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener.Adapter() {
    @Override
    public void beforePsiChanged(boolean isPhysical) {
      clearCache(isPhysical);
    }
  });
}