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


Java PsiPackage.getName方法代码示例

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


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

示例1: run

import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
@Override
protected void run(@NotNull Result<PsiFile> result) throws Throwable {
    final PsiPackage packageElement = directoryService.getPackage(directory);
    if (packageElement == null) {
        throw new InvalidDirectoryException("Target directory does not provide a package");
    }

    final String fileName = Extensions.append(name, StdFileTypes.JAVA);
    final PsiFile found = directory.findFile(fileName);
    if (found != null) {
        throw new ClassAlreadyExistsException("Class '" + name + "'already exists in " + packageElement.getName());
    }

    final String packageName = packageElement.getQualifiedName();
    final String className = Extensions.remove(this.name, StdFileTypes.JAVA);
    try {
        final String java = converter.convert(packageName, className, json);
        final PsiFile classFile = fileFactory.createFileFromText(fileName, JavaFileType.INSTANCE, java);
        CodeStyleManager.getInstance(classFile.getProject()).reformat(classFile);
        JavaCodeStyleManager.getInstance(classFile.getProject()).optimizeImports(classFile);
        final PsiFile created = (PsiFile) directory.add(classFile);
        result.setResult(created);
    } catch (IOException e) {
        throw new ClassCreationException("Failed to create new class from JSON", e);
    }
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:27,代码来源:NewClassCommandAction.java

示例2: getPresentation

import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
@Override
public ItemPresentation getPresentation(@NotNull final PsiPackage aPackage) {
  return new ColoredItemPresentation() {
    @Override
    public TextAttributesKey getTextAttributesKey() {
      return null;
    }

    @Override
    public String getPresentableText() {
      return aPackage.getName();
    }

    @Override
    public String getLocationString() {
      return aPackage.getQualifiedName();
    }

    @Override
    public Icon getIcon(boolean open) {
      return PlatformIcons.PACKAGE_ICON;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PackagePresentationProvider.java

示例3: getLibraryDirNode

import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
private PackageDependenciesNode getLibraryDirNode(PsiPackage aPackage, OrderEntry libraryOrJdk) {
  if (aPackage == null || aPackage.getName() == null) {
    return getLibraryOrJDKNode(libraryOrJdk);
  }

  if (!myShowModules && !myGroupByScopeType) {
    return getModuleDirNode(aPackage, null, ScopeType.LIB);
  }

  Pair<OrderEntry, PsiPackage> descriptor = Pair.create(myShowIndividualLibs ? libraryOrJdk : null, aPackage);
  PackageNode node = getMap(myLibraryPackageNodes, ScopeType.LIB).get(descriptor);
  if (node != null) return node;

  node = new PackageNode(aPackage, myFlattenPackages);
  getMap(myLibraryPackageNodes, ScopeType.LIB).put(descriptor, node);

  if (myFlattenPackages) {
    getLibraryOrJDKNode(libraryOrJdk).add(node);
  }
  else {
    getLibraryDirNode(aPackage.getParentPackage(), libraryOrJdk).add(node);
  }

  return node;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TreeModelBuilder.java

示例4: calcAbbreviatedPackageFQName

import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
@NotNull
public static String calcAbbreviatedPackageFQName(@NotNull PsiPackage aPackage) {
  final StringBuilder name = new StringBuilder(aPackage.getName());
  for (PsiPackage parentPackage = aPackage.getParentPackage(); parentPackage != null; parentPackage = parentPackage.getParentPackage()) {
    final String packageName = parentPackage.getName();
    if (packageName == null || packageName.isEmpty()) {
      break; // reached default package
    }
    name.insert(0, ".");
    if (packageName.length() > 2 && shouldAbbreviateName(parentPackage)) {
      name.insert(0, packageName.substring(0, 1));
    }
    else {
      name.insert(0, packageName);
    }
  }
  return name.toString();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:TreeViewUtil.java

示例5: PackageNode

import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
public PackageNode(PsiPackage aPackage, boolean showFQName) {
  super(aPackage.getProject());
  myPackage = aPackage;
  myPackageName = showFQName ? aPackage.getQualifiedName() : aPackage.getName();
  if (myPackageName == null || myPackageName.length() == 0) {
    myPackageName = CyclicDependenciesPanel.DEFAULT_PACKAGE_ABBREVIATION;
  }
  String packageQName = aPackage.getQualifiedName();
  if (packageQName.length() == 0) {
    packageQName = null;
  }
  myPackageQName = packageQName;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PackageNode.java

示例6: TodoPackageNode

import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
public TodoPackageNode(@NotNull Project project,
                       PackageElement element,
                       TodoTreeBuilder builder,
                       @Nullable String name) {
  super(project, element, ViewSettings.DEFAULT);
  myBuilder = builder;
  myHighlightedRegions = new ArrayList<HighlightedRegion>(2);
  if (element != null && name == null){
    final PsiPackage aPackage = element.getPackage();
    myPresentationName = aPackage.getName();
  }
  else {
    myPresentationName = name;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:TodoPackageNode.java

示例7: expand

import com.intellij.psi.PsiPackage; //导入方法依赖的package包/类
public String expand(DataContext dataContext) {
  PsiPackage aPackage = getFilePackage(dataContext);
  if (aPackage == null) return null;
  return aPackage.getName();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:FilePackageMacro.java


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