当前位置: 首页>>代码示例>>Java>>正文


Java Alignment.Anchor方法代码示例

本文整理汇总了Java中com.intellij.formatting.Alignment.Anchor方法的典型用法代码示例。如果您正苦于以下问题:Java Alignment.Anchor方法的具体用法?Java Alignment.Anchor怎么用?Java Alignment.Anchor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.formatting.Alignment的用法示例。


在下文中一共展示了Alignment.Anchor方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAlignment

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
@Nullable
public Alignment getAlignment(@NotNull PsiElement e) {
  final Set<PsiElement> set = myTree.get(e);
  if (set == null) {
    return null;
  }

  Alignment alignment = myAlignments.get(set);
  if (alignment != null) return alignment;

  Alignment.Anchor anchor = myAnchor.get(set);
  if (anchor == null) {
    myAnchor.put(set, Alignment.Anchor.LEFT);
    anchor = Alignment.Anchor.LEFT;
  }
  alignment = Alignment.createAlignment(myAllowBackwardShift.get(set), anchor);
  myAlignments.put(set, alignment);
  return alignment;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AlignmentProvider.java

示例2: AlignmentPerTypeStrategy

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
AlignmentPerTypeStrategy(Collection<IElementType> targetElementTypes,
                         IElementType parentType,
                         boolean allowBackwardShift,
                         Alignment.Anchor anchor) {
  myParentType = parentType;
  myAllowBackwardShift = allowBackwardShift;
  for (IElementType elementType : targetElementTypes) {
    myAlignments.put(elementType, Alignment.createAlignment(myAllowBackwardShift, anchor));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:AlignmentStrategy.java

示例3: addPair

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
public void addPair(@NotNull PsiElement e1, @NotNull PsiElement e2, @Nullable Boolean allowBackwardShift, @Nullable Alignment.Anchor anchor) {
  assert e1 != e2;

  final Set<PsiElement> set1 = myTree.get(e1);
  final Set<PsiElement> set2 = myTree.get(e2);

  if (set1 != null && set2 != null) {
    assert (!myAlignments.containsKey(set1) || !myAlignments.containsKey(set2));
    assert(myAllowBackwardShift.get(set1).booleanValue() == myAllowBackwardShift.get(set2).booleanValue());
    assert(myAnchor.get(set1) == myAnchor.get(set2));
    if (allowBackwardShift != null) {
      assert(myAllowBackwardShift.get(set1).booleanValue() == allowBackwardShift.booleanValue());
    }
    if (anchor != null) {
      assert(myAnchor.get(set1) == anchor);
    }

    if (myAlignments.containsKey(set2)) {
      addSet(set1, set2);
    }
    else {
      set1.addAll(set2);
      addSet(set2, set1);
    }
  }
  else if (set1 != null) {
    addElement(e2, allowBackwardShift, anchor, set1);
  }
  else if (set2 != null) {
    addElement(e1, allowBackwardShift, anchor, set2);
  }
  else {
    final HashSet<PsiElement> set = createHashSet();
    addInternal(set, e1);
    addInternal(set, e2);
    myAllowBackwardShift.put(set, allowBackwardShift);
    myAnchor.put(set, anchor);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:AlignmentProvider.java

示例4: addElement

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
private void addElement(PsiElement e, Boolean allowBackwardShift, Alignment.Anchor anchor, Set<PsiElement> set) {
  if (allowBackwardShift != null) {
    assert myAllowBackwardShift.get(set).booleanValue() == allowBackwardShift.booleanValue();
  }
  if (anchor != null) {
    assert myAnchor.get(set) == anchor;
  }
  addInternal(set, e);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:AlignmentProvider.java

示例5: add

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
private void add(@NotNull PsiElement element, boolean allowBackwardShift, @NotNull Alignment.Anchor anchor) {
  if (myTree.get(element) != null) return;

  final HashSet<PsiElement> set = createHashSet();
  set.add(element);
  myTree.put(element, set);
  myAllowBackwardShift.put(set, allowBackwardShift);
  myAnchor.put(set, anchor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:AlignmentProvider.java

示例6: AlignmentPerTypeStrategy

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
AlignmentPerTypeStrategy(Collection<IElementType> targetElementTypes,
                         IElementType parentType,
                         boolean allowBackwardShift,
                         Alignment.Anchor anchor)
{
  myParentType = parentType;
  myAllowBackwardShift = allowBackwardShift;
  for (IElementType elementType : targetElementTypes) {
    myAlignments.put(elementType, Alignment.createAlignment(myAllowBackwardShift, anchor));
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:AlignmentStrategy.java

示例7: createAligner

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
@NotNull
public Aligner createAligner(PsiElement element, boolean allowBackwardShift, Alignment.Anchor anchor) {
  final Aligner aligner = new Aligner(allowBackwardShift, anchor);
  aligner.append(element);
  return aligner;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:AlignmentProvider.java

示例8: Aligner

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
private Aligner(boolean allowBackwardShift, @NotNull Alignment.Anchor anchor) {
  this.allowBackwardShift = allowBackwardShift;
  myAnchor = anchor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:AlignmentProvider.java

示例9: addPair

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
public void addPair(@NotNull PsiElement e1, @NotNull PsiElement e2, @Nullable Boolean allowBackwardShift, @Nullable Alignment.Anchor anchor) {
  assert e1 != e2;

  final Set<PsiElement> set1 = myTree.get(e1);
  final Set<PsiElement> set2 = myTree.get(e2);

  if (set1 != null && set2 != null) {
    assert (!myAlignments.containsKey(set1) || !myAlignments.containsKey(set2));
    assert(myAllowBackwardShift.get(set1).booleanValue() == myAllowBackwardShift.get(set2).booleanValue());
    assert(myAnchor.get(set1) == myAnchor.get(set2));
    if (allowBackwardShift != null) {
      assert(myAllowBackwardShift.get(set1).booleanValue() == allowBackwardShift.booleanValue());
    }
    if (anchor != null) {
      assert(myAnchor.get(set1) == anchor);
    }

    if (myAlignments.containsKey(set2)) {
      for (Iterator<PsiElement> iterator = set1.iterator(); iterator.hasNext(); ) {
        PsiElement element = iterator.next();
        iterator.remove();

        addInternal(set2, element);
      }
    }
    else {
      set1.addAll(set2);
      for (Iterator<PsiElement> iterator = set2.iterator(); iterator.hasNext(); ) {
        PsiElement element = iterator.next();
        iterator.remove();

        addInternal(set1, element);
      }
    }
  }
  else if (set1 != null) {
    if (allowBackwardShift != null) {
      assert myAllowBackwardShift.get(set1).booleanValue() == allowBackwardShift.booleanValue();
    }
    if (anchor != null) {
      assert myAnchor.get(set1) == anchor;
    }
    addInternal(set1, e2);
  }
  else if (set2 != null) {
    if (allowBackwardShift != null) {
      assert(myAllowBackwardShift.get(set2).booleanValue() == allowBackwardShift.booleanValue());
    }
    if (anchor != null) {
      assert(myAnchor.get(set2) == anchor);
    }
    addInternal(set2, e1);
  }
  else {
    final HashSet<PsiElement> set = createHashSet();
    addInternal(set, e1);
    addInternal(set, e2);
    myAllowBackwardShift.put(set, allowBackwardShift);
    myAnchor.put(set, anchor);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:62,代码来源:AlignmentProvider.java

示例10: createAlignmentPerTypeStrategy

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
/**
 * Creates strategy that creates and caches one alignment per given type internally and returns it on subsequent calls
 * to {@link #getAlignment(IElementType, IElementType)} for elements which type is listed at the given collection and parent type
 * (if defined) is the same as the given one; <code>null</code> is returned from {@link #getAlignment(IElementType, IElementType)} for all
 * other elements.
 * <p/>
 * This strategy is assumed to be used at following situations - suppose we want to align code blocks that doesn't belong
 * to the same parent but have similar structure, e.g. variable declaration assignments like the one below:
 * <pre>
 *     int start  = 1;
 *     int finish = 2;
 * </pre>
 * We can provide parent blocks of that target blocks with the same instance of this alignment strategy and let them eventually
 * reuse the same alignment objects for target sub-blocks of the same type.
 *
 * @param targetTypes        target types for which cached alignment should be returned
 * @param parentType         target parent type
 * @param allowBackwardShift flag that specifies if former aligned element may be shifted to right in order to align
 *                           to subsequent element (e.g. <code>'='</code> block of <code>'int start  = 1'</code> statement
 *                           below is shifted one symbol right in order to align to the <code>'='</code> block
 *                           of <code>'int finish  = 1'</code> statement)
 * @return                   alignment retrieval strategy that follows the rules described above
 */
public static AlignmentPerTypeStrategy createAlignmentPerTypeStrategy(
  @NotNull Collection<IElementType> targetTypes, @Nullable IElementType parentType, boolean allowBackwardShift,
  @NotNull Alignment.Anchor anchor)
{
  return new AlignmentPerTypeStrategy(targetTypes, parentType, allowBackwardShift, anchor);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:AlignmentStrategy.java

示例11: createAlignmentPerTypeStrategy

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
/**
 * Creates strategy that creates and caches one alignment per given type internally and returns it on subsequent calls
 * to {@link #getAlignment(IElementType, IElementType)} for elements which type is listed at the given collection and parent type
 * (if defined) is the same as the given one; <code>null</code> is returned from {@link #getAlignment(IElementType, IElementType)} for all
 * other elements.
 * <p/>
 * This strategy is assumed to be used at following situations - suppose we want to align code blocks that doesn't belong
 * to the same parent but have similar structure, e.g. variable declaration assignments like the one below:
 * <pre>
 *     int start  = 1;
 *     int finish = 2;
 * </pre>
 * We can provide parent blocks of that target blocks with the same instance of this alignment strategy and let them eventually
 * reuse the same alignment objects for target sub-blocks of the same type.
 *
 * @param targetTypes        target types for which cached alignment should be returned
 * @param parentType         target parent type
 * @param allowBackwardShift flag that specifies if former aligned element may be shifted to right in order to align
 *                           to subsequent element (e.g. <code>'='</code> block of <code>'int start  = 1'</code> statement
 *                           below is shifted one symbol right in order to align to the <code>'='</code> block
 *                           of <code>'int finish  = 1'</code> statement)
 * @return                   alignment retrieval strategy that follows the rules described above
 */
public static AlignmentPerTypeStrategy createAlignmentPerTypeStrategy(
        @Nonnull Collection<IElementType> targetTypes, @Nullable IElementType parentType, boolean allowBackwardShift,
        @Nonnull Alignment.Anchor anchor)
{
  return new AlignmentPerTypeStrategy(targetTypes, parentType, allowBackwardShift, anchor);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:30,代码来源:AlignmentStrategy.java

示例12: createAlignmentPerTypeStrategy

import com.intellij.formatting.Alignment; //导入方法依赖的package包/类
/**
 * Creates strategy that creates and caches one alignment per given type internally and returns it on subsequent calls
 * to {@link #getAlignment(IElementType, IElementType)} for elements which type is listed at the given collection and parent type
 * (if defined) is the same as the given one; <code>null</code> is returned from {@link #getAlignment(IElementType, IElementType)} for all
 * other elements.
 * <p/>
 * This strategy is assumed to be used at following situations - suppose we want to align code blocks that doesn't belong
 * to the same parent but have similar structure, e.g. variable declaration assignments like the one below:
 * <pre>
 *     int start  = 1;
 *     int finish = 2;
 * </pre>
 * We can provide parent blocks of that target blocks with the same instance of this alignment strategy and let them eventually
 * reuse the same alignment objects for target sub-blocks of the same type.
 *
 * @param targetTypes        target types for which cached alignment should be returned
 * @param parentType         target parent type
 * @param allowBackwardShift flag that specifies if former aligned element may be shifted to right in order to align
 *                           to subsequent element (e.g. <code>'='</code> block of <code>'int start  = 1'</code> statement
 *                           below is shifted one symbol right in order to align to the <code>'='</code> block
 *                           of <code>'int finish  = 1'</code> statement)
 * @return                   alignment retrieval strategy that follows the rules described above
 */
public static AlignmentPerTypeStrategy createAlignmentPerTypeStrategy(
  @NotNull Collection<IElementType> targetTypes, @Nullable IElementType parentType, boolean allowBackwardShift,
  @NotNull Alignment.Anchor anchor) {
  return new AlignmentPerTypeStrategy(targetTypes, parentType, allowBackwardShift, anchor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:AlignmentStrategy.java


注:本文中的com.intellij.formatting.Alignment.Anchor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。