本文整理汇总了Java中com.intellij.psi.PsiDirectory.getProject方法的典型用法代码示例。如果您正苦于以下问题:Java PsiDirectory.getProject方法的具体用法?Java PsiDirectory.getProject怎么用?Java PsiDirectory.getProject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiDirectory
的用法示例。
在下文中一共展示了PsiDirectory.getProject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isLessonDir
import com.intellij.psi.PsiDirectory; //导入方法依赖的package包/类
public static boolean isLessonDir(PsiDirectory sourceDirectory) {
if (sourceDirectory == null) {
return false;
}
Project project = sourceDirectory.getProject();
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course != null && isCourseCreator(project) && course.getLesson(sourceDirectory.getName()) != null) {
return true;
}
return false;
}
示例2: isTaskDir
import com.intellij.psi.PsiDirectory; //导入方法依赖的package包/类
private static boolean isTaskDir(PsiDirectory sourceDirectory) {
if (sourceDirectory == null) {
return false;
}
Project project = sourceDirectory.getProject();
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null || !CCUtils.isCourseCreator(project)) {
return false;
}
return EduUtils.getTask(sourceDirectory, course) != null;
}
示例3: doCreate
import com.intellij.psi.PsiDirectory; //导入方法依赖的package包/类
private PsiFile doCreate( PsiDirectory dir, String className, String fqnExtended ) throws IncorrectOperationException
{
Project project = dir.getProject();
String fileName = className + ".java";
VirtualFile srcRoot = ProjectRootManager.getInstance( project ).getFileIndex().getSourceRootForFile( dir.getVirtualFile() );
dir = getPsiDirectoryForExtensionClass( dir, fqnExtended, srcRoot );
final PsiPackage pkg = JavaDirectoryService.getInstance().getPackage( dir );
if( pkg == null )
{
throw new IncorrectOperationException( ManBundle.message( "error.new.artifact.nopackage" ) );
}
String text =
"package " + pkg.getQualifiedName() + ";\n" +
"\n" +
"import manifold.ext.api.Extension;\n" +
"import manifold.ext.api.This;\n" +
"import " + fqnExtended + ";\n" +
"\n" +
"@Extension\n" +
"public class " + className + " {\n" +
" public static " + processTypeVars( dir, fqnExtended, StubBuilder::makeTypeVar ) + "void helloWorld(@This " + ClassUtil.extractClassName( fqnExtended ) + processTypeVars( dir, fqnExtended, PsiNamedElement::getName ) + " thiz) {\n" +
" System.out.println(\"hello world!\");\n" +
" }\n" +
"}";
dir.checkCreateFile( fileName );
final PsiFile file = dir.createFile( fileName );
try
{
new CharSink()
{
public Writer openStream() throws IOException
{
return new OutputStreamWriter( file.getVirtualFile().getOutputStream( null ) );
}
}.write( text );
}
catch( IOException e )
{
throw new IncorrectOperationException( e.getMessage(), (Throwable)e );
}
return file;
}