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


Java PackageEntryTable.getEntries方法代码示例

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


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

示例1: addLineFeedAfter

import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的package包/类
protected void addLineFeedAfter(@NotNull PsiElement psiFile, GrImportStatement result) {
  final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getInstance(psiFile.getProject()).getCurrentSettings().getCustomSettings(GroovyCodeStyleSettings.class);
  final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
  final PackageEntry[] entries = layoutTable.getEntries();

  PsiElement next = result.getNextSibling();
  if (PsiImplUtil.isWhiteSpaceOrNls(next)) next = next.getNextSibling();
  if (PsiImplUtil.hasElementType(next, GroovyTokenTypes.mSEMI)) next = next.getNextSibling();
  while (PsiImplUtil.isWhiteSpaceOrNls(next)) {
    next = next.getNextSibling();
  }
  if (next instanceof GrImportStatement) {
    final int idx_after = getPackageEntryIdx(entries, (GrImportStatement)next);
    final int idx = getPackageEntryIdx(entries, result);
    final int spaceCount = getMaxSpaceCount(entries, idx, idx_after);


    ASTNode node = psiFile.getNode();
    while (PsiImplUtil.isWhiteSpaceOrNls(next.getPrevSibling())) {
      node.removeChild(next.getPrevSibling().getNode());
    }
    node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), next.getNode());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GroovyCodeStyleManagerImpl.java

示例2: addLineFeedAfter

import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的package包/类
protected void addLineFeedAfter(GrImportStatement result) {
  final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().getCustomSettings(GroovyCodeStyleSettings.class);
  final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
  final PackageEntry[] entries = layoutTable.getEntries();

  PsiElement next = result.getNextSibling();
  if (isWhiteSpace(next)) next = next.getNextSibling();
  if (hasElementType(next, GroovyTokenTypes.mSEMI)) next = next.getNextSibling();
  while (isWhiteSpace(next)) {
    next = next.getNextSibling();
  }
  if (next instanceof GrImportStatement) {
    final int idx_after = getPackageEntryIdx(entries, (GrImportStatement)next);
    final int idx = getPackageEntryIdx(entries, result);
    final int spaceCount = getMaxSpaceCount(entries, idx, idx_after);


    final FileASTNode node = getNode();
    while (isWhiteSpace(next.getPrevSibling())) {
      node.removeChild(next.getPrevSibling().getNode());
    }
    node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), next.getNode());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:GroovyFileBaseImpl.java

示例3: addLineFeedBefore

import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的package包/类
protected void addLineFeedBefore(@NotNull PsiElement psiFile, @NotNull GrImportStatement result) {
  final GroovyCodeStyleSettings settings =
    CodeStyleSettingsManager.getInstance(psiFile.getProject()).getCurrentSettings().getCustomSettings(GroovyCodeStyleSettings.class);
  final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
  final PackageEntry[] entries = layoutTable.getEntries();

  PsiElement prev = result.getPrevSibling();
  while (PsiImplUtil.isWhiteSpaceOrNls(prev)) {
    prev = prev.getPrevSibling();
  }
  if (PsiImplUtil.hasElementType(prev, GroovyTokenTypes.mSEMI)) prev = prev.getPrevSibling();
  if (PsiImplUtil.isWhiteSpaceOrNls(prev)) prev = prev.getPrevSibling();

  if (prev instanceof GrImportStatement) {
    final int idx_before = getPackageEntryIdx(entries, (GrImportStatement)prev);
    final int idx = getPackageEntryIdx(entries, result);
    final int spaceCount = getMaxSpaceCount(entries, idx_before, idx);

    //skip space and semicolon after import
    if (PsiImplUtil.isWhiteSpaceOrNls(prev.getNextSibling()) && PsiImplUtil
      .hasElementType(prev.getNextSibling().getNextSibling(), GroovyTokenTypes.mSEMI)) prev = prev.getNextSibling().getNextSibling();
    ASTNode node = psiFile.getNode();
    while (PsiImplUtil.isWhiteSpaceOrNls(prev.getNextSibling())) {
      node.removeChild(prev.getNextSibling().getNode());
    }
    node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), result.getNode());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:GroovyCodeStyleManagerImpl.java

示例4: addLineFeedBefore

import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的package包/类
protected void addLineFeedBefore(GrImportStatement result) {
  final GroovyCodeStyleSettings settings =
    CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().getCustomSettings(GroovyCodeStyleSettings.class);
  final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
  final PackageEntry[] entries = layoutTable.getEntries();

  PsiElement prev = result.getPrevSibling();
  while (isWhiteSpace(prev)) {
    prev = prev.getPrevSibling();
  }
  if (hasElementType(prev, GroovyTokenTypes.mSEMI)) prev = prev.getPrevSibling();
  if (isWhiteSpace(prev)) prev = prev.getPrevSibling();

  if (prev instanceof GrImportStatement) {
    final int idx_before = getPackageEntryIdx(entries, (GrImportStatement)prev);
    final int idx = getPackageEntryIdx(entries, result);
    final int spaceCount = getMaxSpaceCount(entries, idx_before, idx);

    //skip space and semicolon after import
    if (isWhiteSpace(prev.getNextSibling()) && hasElementType(prev.getNextSibling().getNextSibling(), GroovyTokenTypes.mSEMI)) prev = prev.getNextSibling().getNextSibling();
    final FileASTNode node = getNode();
    while (isWhiteSpace(prev.getNextSibling())) {
      node.removeChild(prev.getNextSibling().getNode());
    }
    node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), result.getNode());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:GroovyFileBaseImpl.java

示例5: getAnchorToInsertImportAfter

import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的package包/类
@Nullable
private PsiElement getAnchorToInsertImportAfter(@NotNull GroovyFile psiFile, @NotNull GrImportStatement statement) {
  final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getInstance(psiFile.getProject()).getCurrentSettings().getCustomSettings(
    GroovyCodeStyleSettings.class);
  final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
  final PackageEntry[] entries = layoutTable.getEntries();

  GrImportStatement[] importStatements = psiFile.getImportStatements();
  if (importStatements.length == 0) {
    final GrPackageDefinition definition = psiFile.getPackageDefinition();
    if (definition != null) {
      return definition;
    }

    return getShellComment(psiFile);
  }

  final Comparator<GrImportStatement> comparator = GroovyImportOptimizer.getComparator(settings);

  final int idx = getPackageEntryIdx(entries, statement);

  PsiElement anchor = null;

  for (GrImportStatement importStatement : importStatements) {
    final int i = getPackageEntryIdx(entries, importStatement);
    if (i < idx) {
      anchor = importStatement;
    }
    else if (i > idx) {
      break;
    }
    else if (comparator.compare(statement, importStatement) > 0) {
      anchor = importStatement;
    }
    else {
      break;
    }
  }

  if (anchor == null) anchor = psiFile.getPackageDefinition();
  if (anchor == null) anchor = getShellComment(psiFile);
  if (anchor == null && importStatements.length > 0) anchor = importStatements[0].getPrevSibling();
  return anchor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:45,代码来源:GroovyCodeStyleManagerImpl.java

示例6: getAnchorToInsertImportAfter

import com.intellij.psi.codeStyle.PackageEntryTable; //导入方法依赖的package包/类
@Nullable
private PsiElement getAnchorToInsertImportAfter(GrImportStatement statement) {
  final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().getCustomSettings(
    GroovyCodeStyleSettings.class);
  final PackageEntryTable layoutTable = settings.IMPORT_LAYOUT_TABLE;
  final PackageEntry[] entries = layoutTable.getEntries();

  GrImportStatement[] importStatements = getImportStatements();
  if (importStatements.length == 0) {
    final GrPackageDefinition definition = getPackageDefinition();
    if (definition != null) {
      return definition;
    }

    return getShellComment();
  }

  final Comparator<GrImportStatement> comparator = GroovyImportOptimizer.getComparator(settings);

  final int idx = getPackageEntryIdx(entries, statement);

  PsiElement anchor = null;

  for (GrImportStatement importStatement : importStatements) {
    final int i = getPackageEntryIdx(entries, importStatement);
    if (i < idx) {
      anchor = importStatement;
    }
    else if (i > idx) {
      break;
    }
    else if (comparator.compare(statement, importStatement) > 0) {
      anchor = importStatement;
    }
    else {
      break;
    }
  }

  if (anchor == null) anchor = getPackageDefinition();
  if (anchor == null) anchor = getShellComment();
  if (anchor == null && importStatements.length > 0) anchor = importStatements[0].getPrevSibling();
  return anchor;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:45,代码来源:GroovyFileImpl.java


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