Java 类com.intellij.psi.impl.JavaPsiImplementationHelper 实例源码

项目:intellij-ce-playground    文件:ClsFileImpl.java   
@SuppressWarnings("deprecation")
@Override
@NotNull
public PsiElement getNavigationElement() {
  for (ClsCustomNavigationPolicy customNavigationPolicy : Extensions.getExtensions(ClsCustomNavigationPolicy.EP_NAME)) {
    if (customNavigationPolicy instanceof ClsCustomNavigationPolicyEx) {
      PsiFile navigationElement = ((ClsCustomNavigationPolicyEx)customNavigationPolicy).getFileNavigationElement(this);
      if (navigationElement != null) {
        return navigationElement;
      }
    }
  }

  return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiElement>() {
    @Nullable
    @Override
    public Result<PsiElement> compute() {
      PsiElement target = JavaPsiImplementationHelper.getInstance(getProject()).getClsFileNavigationElement(ClsFileImpl.this);
      ModificationTracker tracker = FileIndexFacade.getInstance(getProject()).getRootModificationTracker();
      return Result.create(target, ClsFileImpl.this, target.getContainingFile(), tracker);
    }
  });
}
项目:intellij-ce-playground    文件:PsiJavaFileBaseImpl.java   
private LanguageLevel getLanguageLevelInner() {
  if (myOriginalFile instanceof PsiJavaFile) {
    return ((PsiJavaFile)myOriginalFile).getLanguageLevel();
  }

  LanguageLevel forcedLanguageLevel = getUserData(PsiUtil.FILE_LANGUAGE_LEVEL_KEY);
  if (forcedLanguageLevel != null) return forcedLanguageLevel;

  VirtualFile virtualFile = getVirtualFile();
  if (virtualFile == null) virtualFile = getUserData(IndexingDataKeys.VIRTUAL_FILE);

  final Project project = getProject();
  if (virtualFile == null) {
    final PsiFile originalFile = getOriginalFile();
    if (originalFile instanceof PsiJavaFile && originalFile != this) {
      return ((PsiJavaFile)originalFile).getLanguageLevel();
    }
    return LanguageLevelProjectExtension.getInstance(project).getLanguageLevel();
  }

  return JavaPsiImplementationHelper.getInstance(project).getEffectiveLanguageLevel(virtualFile);
}
项目:intellij-ce-playground    文件:JavaCoreProjectEnvironment.java   
public JavaCoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
  super(parentDisposable, applicationEnvironment);

  myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
  myProject.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
  myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
  myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
  myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
  myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
  myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());

  myPackageIndex = createCorePackageIndex();
  myProject.registerService(PackageIndex.class, myPackageIndex);

  myFileManager = createCoreFileManager();
  myProject.registerService(JavaFileManager.class, myFileManager);

  JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, myPsiManager, myFileManager, myMessageBus);
  myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
}
项目:tools-idea    文件:JavaCoreProjectEnvironment.java   
public JavaCoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
  super(parentDisposable, applicationEnvironment);

  myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
  myProject.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
  myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
  myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
  myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
  myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
  myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
  registerProjectExtensionPoint(PsiElementFinder.EP_NAME, PsiElementFinder.class);

  myPackageIndex = createCorePackageIndex();
  myProject.registerService(PackageIndex.class, myPackageIndex);

  myFileManager = createCoreFileManager();
  myProject.registerService(JavaFileManager.class, myFileManager);

  JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, myPsiManager, myFileManager, myMessageBus);
  registerProjectComponent(JavaPsiFacade.class, javaPsiFacade);
  myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
}
项目:consulo-java    文件:ImportListElement.java   
@Override
public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before)
{
    if(before == null)
    {
        if(first == last && (first.getElementType() == JavaElementType.IMPORT_STATEMENT || first.getElementType() == JavaElementType.IMPORT_STATIC_STATEMENT))
        {
            final PsiImportList list = (PsiImportList) SourceTreeToPsiMap.treeElementToPsi(this);
            final PsiImportStatementBase statement = (PsiImportStatementBase) SourceTreeToPsiMap.treeElementToPsi(first);
            final JavaPsiImplementationHelper instance = JavaPsiImplementationHelper.getInstance(list.getProject());
            if(instance != null)
            {
                anchor = instance.getDefaultImportAnchor(list, statement);
            }
            before = Boolean.TRUE;
        }
    }
    return super.addInternal(first, last, anchor, before);
}
项目:consulo-java    文件:JavaCoreProjectEnvironment.java   
public JavaCoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
   super(parentDisposable, applicationEnvironment);

   myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
   myProject.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
   myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
   myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
   myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
   myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
   registerProjectExtensionPoint(PsiElementFinder.EP_NAME, PsiElementFinder.class);

/*   myPackageIndex = createCorePackageIndex();
   myProject.registerService(PackageIndex.class, myPackageIndex);     */

   myFileManager = createCoreFileManager();
   myProject.registerService(JavaFileManager.class, myFileManager);

   PsiPackageManager manager = new PsiPackageManagerImpl(getProject(), DirectoryIndex.getInstance(getProject()));

   myProject.registerService(PsiPackageManager.class, manager);

   JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, manager);
   registerProjectComponent(JavaPsiFacade.class, javaPsiFacade);
   myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
 }
项目:intellij-ce-playground    文件:ImportListElement.java   
@Override
public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before){
  if (before == null){
    if (first == last && (first.getElementType() == JavaElementType.IMPORT_STATEMENT || first.getElementType() == JavaElementType.IMPORT_STATIC_STATEMENT)){
      final PsiImportList list = (PsiImportList)SourceTreeToPsiMap.treeElementToPsi(this);
      final PsiImportStatementBase statement = (PsiImportStatementBase)SourceTreeToPsiMap.treeElementToPsi(first);
      final JavaPsiImplementationHelper instance = JavaPsiImplementationHelper.getInstance(list.getProject());
      if (instance != null) {
        anchor = instance.getDefaultImportAnchor(list, statement);
      }
      before = Boolean.TRUE;
    }
  }
  return super.addInternal(first, last, anchor, before);
}
项目:tools-idea    文件:ClsFileImpl.java   
@Override
@NotNull
public PsiElement getNavigationElement() {
  for (ClsCustomNavigationPolicy customNavigationPolicy : Extensions.getExtensions(ClsCustomNavigationPolicy.EP_NAME)) {
    if (customNavigationPolicy instanceof ClsCustomNavigationPolicyEx) {
      PsiFile navigationElement = ((ClsCustomNavigationPolicyEx)customNavigationPolicy).getFileNavigationElement(this);
      if (navigationElement != null) {
        return navigationElement;
      }
    }
  }

  return JavaPsiImplementationHelper.getInstance(getProject()).getClsFileNavigationElement(this);
}
项目:tools-idea    文件:ImportListElement.java   
@Override
public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before){
  if (before == null){
    if (first == last && (first.getElementType() == JavaElementType.IMPORT_STATEMENT || first.getElementType() == JavaElementType.IMPORT_STATIC_STATEMENT)){
      final PsiImportList list = (PsiImportList)SourceTreeToPsiMap.treeElementToPsi(this);
      final PsiImportStatementBase statement = (PsiImportStatementBase)SourceTreeToPsiMap.treeElementToPsi(first);
      final JavaPsiImplementationHelper instance = JavaPsiImplementationHelper.getInstance(list.getProject());
      if (instance != null) {
        anchor = instance.getDefaultImportAnchor(list, statement);
      }
      before = Boolean.TRUE;
    }
  }
  return super.addInternal(first, last, anchor, before);
}
项目:tools-idea    文件:PsiJavaFileBaseImpl.java   
private LanguageLevel getLanguageLevelInner() {
  if (myOriginalFile instanceof PsiJavaFile) {
    return ((PsiJavaFile)myOriginalFile).getLanguageLevel();
  }

  LanguageLevel forcedLanguageLevel = getUserData(PsiUtil.FILE_LANGUAGE_LEVEL_KEY);
  if (forcedLanguageLevel != null) return forcedLanguageLevel;

  VirtualFile virtualFile = getVirtualFile();
  if (virtualFile == null) virtualFile = getUserData(IndexingDataKeys.VIRTUAL_FILE);

  final Project project = getProject();
  if (virtualFile == null) {
    final PsiFile originalFile = getOriginalFile();
    if (originalFile instanceof PsiJavaFile && originalFile != this) {
      return ((PsiJavaFile)originalFile).getLanguageLevel();
    }
    return LanguageLevelProjectExtension.getInstance(project).getLanguageLevel();
  }

  final VirtualFile folder = virtualFile.getParent();
  if (folder != null) {
    final LanguageLevel level = folder.getUserData(LanguageLevel.KEY);
    if (level != null) return level;
  }

  final LanguageLevel classesLanguageLevel = JavaPsiImplementationHelper.getInstance(project).getClassesLanguageLevel(virtualFile);
  if (classesLanguageLevel != null) {
    return classesLanguageLevel;
  }

  return PsiUtil.getLanguageLevel(project);
}
项目:consulo-java    文件:ClsFileImpl.java   
@Override
@NotNull
@SuppressWarnings("deprecation")
public PsiElement getNavigationElement()
{
    for(ClsCustomNavigationPolicy customNavigationPolicy : Extensions.getExtensions(ClsCustomNavigationPolicy.EP_NAME))
    {
        if(customNavigationPolicy instanceof ClsCustomNavigationPolicyEx)
        {
            try
            {
                PsiFile navigationElement = ((ClsCustomNavigationPolicyEx) customNavigationPolicy).getFileNavigationElement(this);
                if(navigationElement != null)
                {
                    return navigationElement;
                }
            }
            catch(IndexNotReadyException ignore)
            {
            }
        }
    }

    return CachedValuesManager.getCachedValue(this, () ->
    {
        PsiElement target = JavaPsiImplementationHelper.getInstance(getProject()).getClsFileNavigationElement(this);
        ModificationTracker tracker = FileIndexFacade.getInstance(getProject()).getRootModificationTracker();
        return CachedValueProvider.Result.create(target, this, target.getContainingFile(), tracker);
    });
}
项目:consulo-java    文件:PsiClassImpl.java   
@Override
public PsiElement getOriginalElement()
{
    return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiClass>()
    {
        @Nullable
        @Override
        public Result<PsiClass> compute()
        {
            final JavaPsiImplementationHelper helper = JavaPsiImplementationHelper.getInstance(getProject());
            final PsiClass result = helper != null ? helper.getOriginalClass(PsiClassImpl.this) : PsiClassImpl.this;
            return Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
        }
    });
}
项目:intellij-ce-playground    文件:JavaSyntaxHighlighterFactory.java   
/**
 * SyntaxHighlighterFactory implementation (for Java source files).
 */
@Override
@NotNull
public SyntaxHighlighter getSyntaxHighlighter(@Nullable Project project, @Nullable VirtualFile file) {
  return new JavaFileHighlighter(project == null ? LanguageLevel.HIGHEST : JavaPsiImplementationHelper.getInstance(project).getEffectiveLanguageLevel(file));
}
项目:intellij-ce-playground    文件:JavaDirectoryServiceImpl.java   
@Override
public LanguageLevel getLanguageLevel(@NotNull PsiDirectory dir) {
  return JavaPsiImplementationHelper.getInstance(dir.getProject()).getEffectiveLanguageLevel(dir.getVirtualFile());
}
项目:consulo-java    文件:PsiJavaFileBaseImpl.java   
private LanguageLevel getLanguageLevelInner()
{
    if(myOriginalFile instanceof PsiJavaFile)
    {
        return ((PsiJavaFile) myOriginalFile).getLanguageLevel();
    }
    final LanguageLevel forcedLanguageLevel = getUserData(PsiUtil.FILE_LANGUAGE_LEVEL_KEY);
    if(forcedLanguageLevel != null)
    {
        return forcedLanguageLevel;
    }
    VirtualFile virtualFile = getVirtualFile();

    if(virtualFile == null)
    {
        virtualFile = getUserData(IndexingDataKeys.VIRTUAL_FILE);
    }

    final Project project = getProject();
    if(virtualFile == null)
    {
        final PsiFile originalFile = getOriginalFile();
        if(originalFile instanceof PsiJavaFile && originalFile != this)
        {
            return ((PsiJavaFile) originalFile).getLanguageLevel();
        }

        final Module moduleForPsiElement = ModuleUtilCore.findModuleForPsiElement(originalFile);
        if(moduleForPsiElement != null)
        {
            return EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(moduleForPsiElement);
        }
    }
    else
    {
        final VirtualFile folder = virtualFile.getParent();
        if(folder != null)
        {
            final LanguageLevel level = folder.getUserData(LanguageLevel.KEY);
            if(level != null)
            {
                return level;
            }
        }

        final LanguageLevel classesLanguageLevel = JavaPsiImplementationHelper.getInstance(project).getClassesLanguageLevel(virtualFile);
        if(classesLanguageLevel != null)
        {
            return classesLanguageLevel;
        }
    }
    return LanguageLevel.HIGHEST;
}