update copyrights
[fedora-idea.git] / platform / lang-api / src / com / intellij / formatting / Wrap.java
blobfba9333472ba5ac896a57ec3fa5828aa1a555cef
1 /*
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.formatting;
18 import com.intellij.openapi.diagnostic.Logger;
20 /**
21 * The wrap setting for a formatting model block. Indicates the conditions under which a line break
22 * is inserted before the block when formatting, if the block extends beyond the
23 * right margin.
25 * @see com.intellij.formatting.Block#getWrap()
28 public abstract class Wrap {
29 /**
30 * Converts a low-priority wrap setting to a regular wrap setting.
31 * @see #createChildWrap(Wrap, WrapType, boolean)
33 public abstract void ignoreParentWraps();
35 private static final Logger LOG = Logger.getInstance("#com.intellij.formatting.Wrap");
37 private static WrapFactory myFactory;
39 public static WrapType ALWAYS = WrapType.ALWAYS;
40 public static WrapType NORMAL = WrapType.NORMAL;
41 public static WrapType NONE = WrapType.NONE;
42 public static WrapType CHOP_DOWN_IF_LONG = WrapType.CHOP_DOWN_IF_LONG;
44 static void setFactory(WrapFactory factory) {
45 myFactory = factory;
48 /**
49 * Creates a block wrap setting of the specified type.
51 * @param type the type of the wrap setting.
52 * @param wrapFirstElement if true, the first element in a sequence of elements of the same type
53 * is also wrapped.
54 * @return the wrap setting instance.
56 public static Wrap createWrap(final WrapType type, final boolean wrapFirstElement) {
57 return myFactory.createWrap(type, wrapFirstElement);
60 /**
61 * Creates a low priority wrap setting of the specified type. If the formatter detects that
62 * the line should be wrapped at a location of the child wrap, the line is wrapped at the
63 * position of its parent wrap instead.
65 * @param parentWrap the parent for this wrap setting.
66 * @param wrapType the type of the wrap setting.
67 * @param wrapFirstElement if true, the first element in a sequence of elements of the same type
68 * is also wrapped.
69 * @return the wrap setting instance.
70 * @see #ignoreParentWraps()
72 public static Wrap createChildWrap(final Wrap parentWrap, final WrapType wrapType, final boolean wrapFirstElement) {
73 return myFactory.createChildWrap(parentWrap, wrapType, wrapFirstElement);