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

项目:intellij-ce-playground    文件:NavigationUtil.java   
public static boolean openFileWithPsiElement(PsiElement element, boolean searchForOpen, boolean requestFocus) {
  boolean openAsNative = false;
  if (element instanceof PsiFile) {
    VirtualFile virtualFile = ((PsiFile)element).getVirtualFile();
    if (virtualFile != null) {
      openAsNative = ElementBase.isNativeFileType(virtualFile.getFileType());
    }
  }

  if (searchForOpen) {
    element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, null);
  }
  else {
    element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, true);
  }

  if (openAsNative || !activatePsiElementIfOpen(element, searchForOpen, requestFocus)) {
    final NavigationItem navigationItem = (NavigationItem)element;
    if (!navigationItem.canNavigate()) return false;
    navigationItem.navigate(requestFocus);
    return true;
  }

  element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, null);
  return false;
}
项目:intellij-ce-playground    文件:XmlIconProvider.java   
@Override
@Nullable
public Icon getIcon(@NotNull final PsiElement element, final int _flags) {
  if (element instanceof XmlFile) {
    final VirtualFile vf = ((XmlFile)element).getVirtualFile();
    if (vf != null) {
      final String extension = vf.getExtension();

      if (XSD_FILE_EXTENSION.equals(extension)) {
        return ElementBase.createLayeredIcon(element, AllIcons.FileTypes.XsdFile, ElementBase.transformFlags(element, _flags));
      }
      if (WSDL_FILE_EXTENSION.equals(extension)) {
        return ElementBase.createLayeredIcon(element, AllIcons.FileTypes.WsdlFile, ElementBase.transformFlags(element, _flags));
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:GroovyFileIconProvider.java   
@Nullable
@Override
public Icon getIcon(@NotNull VirtualFile virtualFile, @Iconable.IconFlags int flags, @Nullable Project project) {
  if (project == null || virtualFile.getFileType() != GroovyFileType.GROOVY_FILE_TYPE) return null;
  final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
  if (!(psiFile instanceof GroovyFile)) return null;
  final GroovyFile file = (GroovyFile)psiFile;
  final Icon icon;
  if (file.isScript()) {
    icon = GroovyScriptTypeDetector.getIcon(file);
  }
  else if (GrFileIndexUtil.isGroovySourceFile(file)) {
    final GrTypeDefinition[] typeDefinitions = file.getTypeDefinitions();
    icon = typeDefinitions.length > 0
           ? typeDefinitions[0].getIcon(flags)
           : JetgroovyIcons.Groovy.Groovy_16x16;
  }
  else {
    icon = JetgroovyIcons.Groovy.Groovy_outsideSources;
  }
  return ElementBase.createLayeredIcon(psiFile, icon, ElementBase.transformFlags(psiFile, flags));
}
项目:tools-idea    文件:NavigationUtil.java   
public static boolean openFileWithPsiElement(PsiElement element, boolean searchForOpen, boolean requestFocus) {
  boolean openAsNative = false;
  if (element instanceof PsiFile) {
    VirtualFile virtualFile = ((PsiFile)element).getVirtualFile();
    if (virtualFile != null) {
      openAsNative = ElementBase.isNativeFileType(virtualFile.getFileType());
    }
  }

  if (searchForOpen) {
    element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, null);
  }
  else {
    element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, true);
  }

  if (openAsNative || !activatePsiElementIfOpen(element, searchForOpen, requestFocus)) {
    ((NavigationItem)element).navigate(requestFocus);
    return true;
  }

  element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, null);
  return false;
}
项目:tools-idea    文件:XmlIconProvider.java   
@Nullable
public Icon getIcon(@NotNull final PsiElement element, final int _flags) {
  if (element instanceof XmlFile) {
    final VirtualFile vf = ((XmlFile)element).getVirtualFile();
    if (vf != null) {
      final String extension = vf.getExtension();

      if (XSD_FILE_EXTENSION.equals(extension)) {
        return ElementBase.createLayeredIcon(element, AllIcons.FileTypes.XsdFile, ElementBase.transformFlags(element, _flags));
      }
      if (WSDL_FILE_EXTENSION.equals(extension)) {
        return ElementBase.createLayeredIcon(element, AllIcons.FileTypes.WsdlFile, ElementBase.transformFlags(element, _flags));
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:PsiClassObjectAccessExpressionImpl.java   
@Override
@NotNull
public Icon getElementIcon(final int flags) {
  final RowIcon rowIcon = ElementBase.createLayeredIcon(this, PlatformIcons.FIELD_ICON, 0);
  rowIcon.setIcon(PlatformIcons.PUBLIC_ICON, 1);
  return rowIcon;
}
项目:intellij-ce-playground    文件:SharedImplUtil.java   
public static FileASTNode findFileElement(@NotNull ASTNode element) {
  if (CHECK_FOR_READ_ACTION && element instanceof ElementBase) {
    ApplicationManager.getApplication().assertReadAccessAllowed();
  }
  ASTNode parent = element.getTreeParent();
  while (parent != null) {
    element = parent;
    parent = parent.getTreeParent();
  }

  if (element instanceof FileASTNode) {
    return (FileASTNode)element;
  }
  return null;
}
项目:intellij-ce-playground    文件:DomFileIconProvider.java   
@Override
public Icon getIcon(@NotNull PsiElement element, int flags) {
  if (element instanceof XmlFile) {
    DomFileDescription<?> description = DomManager.getDomManager(element.getProject()).getDomFileDescription((XmlFile)element);
    if (description == null) {
      return null;
    }
    final Icon fileIcon = description.getFileIcon(flags);
    if (fileIcon != null) {
      return ElementBase.createLayeredIcon(element, fileIcon, ElementBase.transformFlags(element, flags));
    }
  }
  return null;
}
项目:material-theme-jetbrains    文件:MTFileIconProvider.java   
/**
 * Return correct instance of directory icon (taken straight from the source code)
 *
 * @param element
 */
private Icon getDirectoryIcon(final PsiDirectory element) {
  final VirtualFile vFile = element.getVirtualFile();
  final Project project = element.getProject();

  final SourceFolder sourceFolder;
  Icon symbolIcon = null;

  if (vFile.getParent() == null && vFile.getFileSystem() instanceof ArchiveFileSystem) {
    symbolIcon = PlatformIcons.JAR_ICON;
  } else if (ProjectRootsUtil.isModuleContentRoot(vFile, project)) {
    final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vFile);
    symbolIcon = module != null ? ModuleType.get(module).getIcon() : PlatformIcons.CONTENT_ROOT_ICON_CLOSED;
  } else if ((sourceFolder = ProjectRootsUtil.getModuleSourceRoot(vFile, project)) != null) {
    symbolIcon = SourceRootPresentation.getSourceRootIcon(sourceFolder);
  } else if (hasJFS && JrtFileSystem.isModuleRoot(vFile)) {
    symbolIcon = AllIcons.Nodes.JavaModuleRoot;
  } else if (hasJDS && JavaDirectoryService.getInstance().getPackage(element) != null) {
    symbolIcon = PlatformIcons.PACKAGE_ICON;
  } else if (!Registry.is("ide.hide.excluded.files") && ProjectRootManager.getInstance(project).getFileIndex().isExcluded(vFile)) {
    symbolIcon = AllIcons.Modules.ExcludeRoot;
  }

  try {
    if (ProjectRootsUtil.findUnloadedModuleByContentRoot(vFile, project) != null) {
      symbolIcon = AllIcons.Modules.UnloadedModule;
    }
  } catch (NoSuchMethodError e) {
    // till android studio implements this shit;
  }

  if (symbolIcon != null) {
    return ElementBase.createLayeredIcon(element, symbolIcon, 0);
  } else {
    return TintedIconsService.getIcon("/icons/nodes/folderClosed.png", "ff00cc");
  }
}
项目:tools-idea    文件:PsiClassObjectAccessExpressionImpl.java   
@Override
@NotNull
public Icon getElementIcon(final int flags) {
  final RowIcon rowIcon = ElementBase.createLayeredIcon(this, PlatformIcons.FIELD_ICON, 0);
  rowIcon.setIcon(PlatformIcons.PUBLIC_ICON, 1);
  return rowIcon;
}
项目:tools-idea    文件:DomFileIconProvider.java   
@Override
public Icon getIcon(@NotNull PsiElement element, int flags) {
  if (element instanceof XmlFile) {
    DomFileDescription<?> description = DomManager.getDomManager(element.getProject()).getDomFileDescription((XmlFile)element);
    if (description == null) {
      return null;
    }
    final Icon fileIcon = description.getFileIcon(flags);
    if (fileIcon != null) {
      return ElementBase.createLayeredIcon(element, fileIcon, ElementBase.transformFlags(element, flags));
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:ClsClassObjectAccessExpressionImpl.java   
@Override
public Icon getElementIcon(final int flags) {
  final RowIcon rowIcon = ElementBase.createLayeredIcon(this, PlatformIcons.FIELD_ICON, 0);
  rowIcon.setIcon(PlatformIcons.PUBLIC_ICON, 1);
  return rowIcon;
}
项目:intellij-ce-playground    文件:SharedImplUtil.java   
public static PsiElement getParent(ASTNode thisElement) {
  if (CHECK_FOR_READ_ACTION && thisElement instanceof ElementBase) {
    ApplicationManager.getApplication().assertReadAccessAllowed();
  }
  return SourceTreeToPsiMap.treeElementToPsi(thisElement.getTreeParent());
}
项目:tools-idea    文件:ClsClassObjectAccessExpressionImpl.java   
@Override
public Icon getElementIcon(final int flags) {
  final RowIcon rowIcon = ElementBase.createLayeredIcon(this, PlatformIcons.FIELD_ICON, 0);
  rowIcon.setIcon(PlatformIcons.PUBLIC_ICON, 1);
  return rowIcon;
}
项目:tools-idea    文件:NativeFileIconProvider.java   
protected boolean isNativeFileType(VirtualFile file) {
  return ElementBase.isNativeFileType(file.getFileType());
}
项目:tools-idea    文件:GroovyFileImpl.java   
@Nullable
public Icon getIcon(int flags) {
  final Icon baseIcon = isScript() ? GroovyScriptTypeDetector.getScriptType(this).getScriptIcon() : JetgroovyIcons.Groovy.Groovy_16x16;
  return ElementBase.createLayeredIcon(this, baseIcon, ElementBase.transformFlags(this, flags));
}