2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.lang
.folding
;
18 import com
.intellij
.lang
.ASTNode
;
19 import com
.intellij
.lang
.Language
;
20 import com
.intellij
.openapi
.editor
.Document
;
21 import org
.jetbrains
.annotations
.Nullable
;
24 * Allows a custom language plugin to define rules for folding code in the language handled
28 * @see LanguageFolding#forLanguage(Language)
31 public interface FoldingBuilder
{
33 * Builds the folding regions for the specified node in the AST tree and its children.
35 * @param node the node for which folding is requested.
36 * @param document the document for which folding is built. Can be used to retrieve line
37 * numbers for folding regions.
38 * @return the array of folding descriptors.
40 FoldingDescriptor
[] buildFoldRegions(ASTNode node
, Document document
);
43 * Returns the text which is displayed in the editor for the folding region related to the
44 * specified node when the folding region is collapsed.
46 * @param node the node for which the placeholder text is requested.
47 * @return the placeholder text.
50 String
getPlaceholderText(ASTNode node
);
53 * Returns the default collapsed state for the folding region related to the specified node.
55 * @param node the node for which the collapsed state is requested.
56 * @return true if the region is collapsed by default, false otherwise.
58 boolean isCollapsedByDefault(ASTNode node
);