本文整理汇总了Java中com.intellij.psi.PsiFile.getProject方法的典型用法代码示例。如果您正苦于以下问题:Java PsiFile.getProject方法的具体用法?Java PsiFile.getProject怎么用?Java PsiFile.getProject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiFile
的用法示例。
在下文中一共展示了PsiFile.getProject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeSystemMeta
import com.intellij.psi.PsiFile; //导入方法依赖的package包/类
@Override
public synchronized TSMetaModel getTypeSystemMeta(@Nullable final PsiFile contextFile) {
if (contextFile == null || !TSMetaModelBuilder.isTsFile(contextFile)) {
return myCachedValue.getValue();
}
final TSMetaModelImpl externalModel = doGetExternalModel(contextFile);
final Project project = contextFile.getProject();
CachedValue<TSMetaModelImpl> fileModelCache = contextFile.getUserData(FILE_MODEL_CACHE_KEY);
if (fileModelCache == null) {
fileModelCache = CachedValuesManager.getManager(project).createCachedValue(
() -> ApplicationManager.getApplication().runReadAction(
(Computable<CachedValueProvider.Result<TSMetaModelImpl>>) () -> {
final TSMetaModelBuilder builder = new TSMetaModelBuilder(project);
final TSMetaModelImpl modelForFile = builder.buildModelForFile(contextFile);
return CachedValueProvider.Result.create(modelForFile, contextFile);
}), false);
contextFile.putUserData(FILE_MODEL_CACHE_KEY, fileModelCache);
}
final TSMetaModelImpl fileModel = fileModelCache.getValue();
return new TSMetaModelImpl(Arrays.asList(externalModel, fileModel));
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:25,代码来源:TSMetaModelAccessImpl.java
示例2: doGetExternalModel
import com.intellij.psi.PsiFile; //导入方法依赖的package包/类
@NotNull
private TSMetaModelImpl doGetExternalModel(final @NotNull PsiFile contextFile) {
final PsiFile originalFile = contextFile.getOriginalFile();
final VirtualFile vFile = originalFile.getVirtualFile();
final Project project = originalFile.getProject();
CachedValue<TSMetaModelImpl> externalModelCache = originalFile.getUserData(EXTERNAL_MODEL_CACHE_KEY);
if (externalModelCache == null) {
externalModelCache = CachedValuesManager.getManager(project).createCachedValue(
() -> ApplicationManager.getApplication().runReadAction(
(Computable<CachedValueProvider.Result<TSMetaModelImpl>>) () -> {
final List<VirtualFile> excludes = vFile == null
? Collections.emptyList()
: Collections.singletonList(vFile);
final TSMetaModelBuilder builder = new TSMetaModelBuilder(project, excludes);
final TSMetaModelImpl model = builder.buildModel();
return CachedValueProvider.Result.create(model, builder.getFiles());
}), false);
originalFile.putUserData(EXTERNAL_MODEL_CACHE_KEY, externalModelCache);
}
return externalModelCache.getValue();
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:TSMetaModelAccessImpl.java
示例3: ignoreUnresolvedReference
import com.intellij.psi.PsiFile; //导入方法依赖的package包/类
@Override
public boolean ignoreUnresolvedReference(@NotNull PyElement element, @NotNull PsiReference reference) {
final PsiFile file = element.getContainingFile();
final Project project = file.getProject();
if (StudyTaskManager.getInstance(project).getCourse() == null) {
return false;
}
TaskFile taskFile = StudyUtils.getTaskFile(project, file.getVirtualFile());
if (taskFile == null || taskFile.isUserCreated() || taskFile.isHighlightErrors()) {
return false;
}
if (PsiTreeUtil.getParentOfType(element, PyImportStatementBase.class) != null) {
return false;
}
return true;
}
示例4: tryToRenameTaskFile
import com.intellij.psi.PsiFile; //导入方法依赖的package包/类
private static void tryToRenameTaskFile(PsiFile file, String oldName) {
final PsiDirectory taskDir = file.getContainingDirectory();
final Project project = file.getProject();
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
if (taskDir == null || !taskDir.getName().contains(EduNames.TASK)) {
return;
}
PsiDirectory lessonDir = taskDir.getParent();
if (lessonDir == null || !lessonDir.getName().contains(EduNames.LESSON)) {
return;
}
Lesson lesson = course.getLesson(lessonDir.getName());
if (lesson == null) {
return;
}
Task task = lesson.getTask(taskDir.getName());
if (task == null) {
return;
}
Map<String, TaskFile> taskFiles = task.getTaskFiles();
TaskFile taskFile = task.getTaskFile(oldName);
if (taskFile == null) {
return;
}
taskFiles.remove(oldName);
taskFiles.put(StudyUtils.pathRelativeToTask(file.getVirtualFile()), taskFile);
}