本文整理汇总了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);
}
}
示例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;
}
};
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
}
示例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();
}