com.intellij.codeInsight.folding.CodeFoldingSettings Java Examples

The following examples show how to use com.intellij.codeInsight.folding.CodeFoldingSettings. 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: HaxeFoldingBuilder.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isCollapsedByDefault(@NotNull ASTNode node) {
  final PsiElement psiElement = node.getPsi();

  final CodeFoldingSettings settings = CodeFoldingSettings.getInstance();
  final HaxeFoldingSettings haxeSettings = HaxeFoldingSettings.getInstance();

  if (psiElement instanceof HaxeImportStatement || psiElement instanceof HaxeUsingStatement) {
    return settings.COLLAPSE_IMPORTS;
  }

  if (isDocComment(node) && !hasRegionMarker(node)) return settings.COLLAPSE_DOC_COMMENTS;

  RegionDefinition regionType = node.getUserData(REGION_DEFINITION_KEY);
  if (regionType == C_SHARP_STYLE) return haxeSettings.isCollapseCSharpStyleRegions();
  if (regionType == FD_STYLE) return haxeSettings.isCollapseFlashDevelopStyleRegions();
  if (regionType == PLUGIN_STYLE) return haxeSettings.isCollapseHaxePluginStyleRegions();
  if (regionType == CC_REGION) {
    return haxeSettings.isCollapseUnusedConditionallyCompiledCode()
        && isUnusedCCRegion(node);
  }

  return false;
}
 
Example #2
Source File: GeneralCodeFoldingConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Nonnull
@Override
protected Component createLayout(PropertyBuilder propertyBuilder) {
  VerticalLayout verticalLayout = VerticalLayout.create();

  CodeFoldingSettings settings = CodeFoldingSettings.getInstance();

  CheckBox fileHeaderBox = CheckBox.create(ApplicationBundle.message("checkbox.collapse.file.header"));
  verticalLayout.add(fileHeaderBox);
  propertyBuilder.add(fileHeaderBox, () -> settings.COLLAPSE_FILE_HEADER, val -> settings.COLLAPSE_FILE_HEADER = val);

  CheckBox importsBox = CheckBox.create(ApplicationBundle.message("checkbox.collapse.title.imports"));
  verticalLayout.add(importsBox);
  propertyBuilder.add(importsBox, () -> settings.COLLAPSE_IMPORTS, val -> settings.COLLAPSE_IMPORTS = val);

  CheckBox docCommentsBox = CheckBox.create(ApplicationBundle.message("checkbox.collapse.javadoc.comments"));
  verticalLayout.add(docCommentsBox);
  propertyBuilder.add(docCommentsBox, () -> settings.COLLAPSE_DOC_COMMENTS, val -> settings.COLLAPSE_DOC_COMMENTS = val);

  CheckBox methodsBox = CheckBox.create(ApplicationBundle.message("checkbox.collapse.method.bodies"));
  verticalLayout.add(methodsBox);
  propertyBuilder.add(methodsBox, () -> settings.COLLAPSE_METHODS, val -> settings.COLLAPSE_METHODS = val);

  return verticalLayout;
}
 
Example #3
Source File: CSharpFoldingBuilder.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean isRegionCollapsedByDefault(@Nonnull ASTNode node)
{
	PsiElement psi = node.getPsi();
	if(psi instanceof CSharpUsingListChild)
	{
		return true;
	}
	else if(psi instanceof PsiComment)
	{
		return CodeFoldingSettings.getInstance().COLLAPSE_FILE_HEADER;
	}

	return false;
}
 
Example #4
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 #5
Source File: CppFoldingBuilder.java    From CppTools with Apache License 2.0 5 votes vote down vote up
public boolean isCollapsedByDefault(ASTNode astNode) {
  if (astNode.getElementType() == CppSupportLoader.CPP_FILE ||
      (astNode.getTreeParent().getElementType() == CppSupportLoader.CPP_FILE &&
       astNode.getTreePrev() == null &&
       astNode.getPsi() instanceof PsiComment
      )
     ) {
    return CodeFoldingSettings.getInstance().COLLAPSE_FILE_HEADER;
  }
  return false;
}
 
Example #6
Source File: CSharpDocFoldingBuilder.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
@Override
public boolean isCollapsedByDefault(@Nonnull ASTNode node)
{
	return CodeFoldingSettings.getInstance().COLLAPSE_DOC_COMMENTS;
}