本文整理汇总了Java中com.intellij.psi.PsiJavaFile.getName方法的典型用法代码示例。如果您正苦于以下问题:Java PsiJavaFile.getName方法的具体用法?Java PsiJavaFile.getName怎么用?Java PsiJavaFile.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiJavaFile
的用法示例。
在下文中一共展示了PsiJavaFile.getName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFix
import com.intellij.psi.PsiJavaFile; //导入方法依赖的package包/类
@Override
@Nullable
protected InspectionGadgetsFix buildFix(Object... infos) {
final PsiJavaFile file = (PsiJavaFile)infos[0];
final String fileName = file.getName();
final int prefixIndex = fileName.indexOf((int)'.');
final String filenameWithoutPrefix = fileName.substring(0, prefixIndex);
final PsiClass[] classes = file.getClasses();
for (PsiClass psiClass : classes) {
final String className = psiClass.getName();
if (filenameWithoutPrefix.equals(className)) {
return null;
}
}
return new RenameFix(filenameWithoutPrefix);
}
示例2: visitClass
import com.intellij.psi.PsiJavaFile; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
// no call to super, so that it doesn't drill down to inner classes
final PsiElement parent = aClass.getParent();
if (!(parent instanceof PsiJavaFile)) {
return;
}
final PsiJavaFile file = (PsiJavaFile)parent;
final String className = aClass.getName();
if (className == null) {
return;
}
final String fileName = file.getName();
final int prefixIndex = fileName.indexOf((int)'.');
if (prefixIndex < 0) {
return;
}
final String filenameWithoutPrefix =
fileName.substring(0, prefixIndex);
if (className.equals(filenameWithoutPrefix)) {
return;
}
registerClassError(aClass, file);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ClassNameDiffersFromFileNameInspectionBase.java
示例3: buildFix
import com.intellij.psi.PsiJavaFile; //导入方法依赖的package包/类
@Override
@Nullable
protected InspectionGadgetsFix buildFix(Object... infos)
{
final PsiJavaFile file = (PsiJavaFile) infos[0];
final String fileName = file.getName();
final int prefixIndex = fileName.indexOf((int) '.');
final String filenameWithoutPrefix = fileName.substring(0, prefixIndex);
final PsiClass[] classes = file.getClasses();
for(PsiClass psiClass : classes)
{
final String className = psiClass.getName();
if(filenameWithoutPrefix.equals(className))
{
return null;
}
}
return new RenameFix(filenameWithoutPrefix);
}
示例4: actionPerformed
import com.intellij.psi.PsiJavaFile; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
try {
com.intellij.openapi.actionSystem.DataContext dataContext = e.getDataContext();
PsiJavaFile javaFile = (PsiJavaFile) ((PsiFile) DataKeys.PSI_FILE.getData(dataContext)).getContainingFile();
String sourceName = javaFile.getName();
Module module = (Module) DataKeys.MODULE.getData(dataContext);
String compileRoot = CompilerModuleExtension.getInstance(module).getCompilerOutputPath().getPath();
getVirtualFile(sourceName, CompilerModuleExtension.getInstance(module).getCompilerOutputPath().getChildren(), compileRoot);
VirtualFileManager.getInstance().syncRefresh();
} catch (Exception ex) {
ex.printStackTrace();
Messages.showErrorDialog("Please build your module or project!!!", "error");
}
}
示例5: getJavaFileName
import com.intellij.psi.PsiJavaFile; //导入方法依赖的package包/类
public static String getJavaFileName(PsiFile value) {
PsiJavaFile javaFile = (PsiJavaFile) value;
if (!javaFile.getPackageName().equals("")) {
return javaFile.getPackageName() + "." + javaFile.getName();
}
return javaFile.getName();
}
示例6: visitClass
import com.intellij.psi.PsiJavaFile; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
// no call to super, so that it doesn't drill down to inner classes
if (FileTypeUtils.isInJsp(aClass)) {
return;
}
final PsiElement parent = aClass.getParent();
if (!(parent instanceof PsiJavaFile)) {
return;
}
final PsiJavaFile file = (PsiJavaFile)parent;
final String className = aClass.getName();
if (className == null) {
return;
}
final String fileName = file.getName();
final int prefixIndex = fileName.indexOf((int)'.');
if (prefixIndex < 0) {
return;
}
final String filenameWithoutPrefix =
fileName.substring(0, prefixIndex);
if (className.equals(filenameWithoutPrefix)) {
return;
}
registerClassError(aClass, file);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:ClassNameDiffersFromFileNameInspection.java
示例7: getPsiFilePath
import com.intellij.psi.PsiJavaFile; //导入方法依赖的package包/类
@NotNull
private String getPsiFilePath(PsiJavaFile psiFile) {
String packageName = psiFile.getPackageName();
String fullName;
if (packageName.isEmpty()) {
fullName = psiFile.getName();
} else {
fullName = packageName.replace(".", "/") + "/" + psiFile.getVirtualFile().getName();
}
return fullName;
}
示例8: visitClass
import com.intellij.psi.PsiJavaFile; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass)
{
final PsiElement parent = aClass.getParent();
if(!(parent instanceof PsiJavaFile))
{
return;
}
final PsiJavaFile file = (PsiJavaFile) parent;
final String className = aClass.getName();
if(className == null)
{
return;
}
final String fileName = file.getName();
final int prefixIndex = fileName.indexOf((int) '.');
if(prefixIndex < 0)
{
return;
}
final String filenameWithoutPrefix = fileName.substring(0, prefixIndex);
if(className.equals(filenameWithoutPrefix))
{
return;
}
registerClassError(aClass, file);
}
示例9: getCloudPathFromJavaFile
import com.intellij.psi.PsiJavaFile; //导入方法依赖的package包/类
/** Utility method that returns the full class name for a file. */
public static String getCloudPathFromJavaFile(PsiJavaFile javaFile) {
return javaFile.getPackageName().replace('.', '/') + "/" + javaFile.getName();
}