Java Code Examples for com.intellij.codeInsight.folding.CodeFoldingSettings#getInstance()

The following examples show how to use com.intellij.codeInsight.folding.CodeFoldingSettings#getInstance() . These examples are extracted from open source projects. 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
@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
@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
@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 Project: CppTools   File: CppFoldingBuilder.java    License: 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 5
@RequiredReadAction
@Override
public boolean isCollapsedByDefault(@Nonnull ASTNode node)
{
	return CodeFoldingSettings.getInstance().COLLAPSE_DOC_COMMENTS;
}