com.intellij.psi.impl.FakePsiElement Java Examples

The following examples show how to use com.intellij.psi.impl.FakePsiElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VirtualFileTestContextProvider.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public RunConfigurationContext getTestContext(ConfigurationContext context) {
  PsiElement psi = context.getPsiLocation();
  if (!(psi instanceof PsiFileSystemItem) || !(psi instanceof FakePsiElement)) {
    return null;
  }
  VirtualFile vf = ((PsiFileSystemItem) psi).getVirtualFile();
  if (vf == null) {
    return null;
  }
  WorkspacePath path = getWorkspacePath(context.getProject(), vf);
  if (path == null) {
    return null;
  }
  return CachedValuesManager.getCachedValue(
      psi,
      () ->
          CachedValueProvider.Result.create(
              doFindTestContext(context, vf, psi, path),
              PsiModificationTracker.MODIFICATION_COUNT,
              BlazeSyncModificationTracker.getInstance(context.getProject())));
}
 
Example #2
Source File: UnityScriptGotoClassContributor.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Override
public void processElementsWithName(@Nonnull String name, @Nonnull final Processor<NavigationItem> processor, @Nonnull FindSymbolParameters parameters)
{
	StubIndex.getInstance().processElements(UnityScriptIndexKeys.FILE_BY_NAME_INDEX, name, parameters.getProject(), parameters.getSearchScope(), parameters.getIdFilter(), JSFile.class,
			new Processor<JSFile>()
	{
		@Override
		public boolean process(final JSFile file)
		{
			return processor.process(new FakePsiElement()
			{
				@Override
				public String getName()
				{
					return FileUtil.getNameWithoutExtension(file.getName());
				}

				@Nonnull
				@Override
				public Project getProject()
				{
					return file.getProject();
				}

				@Nullable
				@Override
				public Image getIcon()
				{
					IconDescriptor descriptor = new IconDescriptor(AllIcons.Nodes.Class);
					descriptor.addLayerIcon(Unity3dIcons.Js);
					descriptor.setRightIcon(AllIcons.Nodes.C_public);
					return descriptor.toIcon();
				}

				@Override
				public PsiElement getParent()
				{
					return file;
				}
			});
		}
	});
}