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

项目:tools-idea    文件:MavenUrlPsiReference.java   
public PsiElement resolve() {
  return new FakePsiElement() {
    public PsiElement getParent() {
      return myElement;
    }

    @Override
    public String getName() {
      return myText;
    }

    @Override
    public void navigate(boolean requestFocus) {
      BrowserUtil.launchBrowser(myText);
    }
  };
}
项目:intellij-ce-playground    文件:MavenModelDocumentationProvider.java   
@Nullable
private static String getMavenElementDescription(PsiElement e, DescKind kind, boolean html) {
  e = getMavenElement(e);
  if (e == null) return null;

  if (e instanceof FakePsiElement) {
    return ((FakePsiElement)e).getPresentableText();
  }

  boolean property = MavenDomUtil.isMavenProperty(e);

  String type = property ? "Property" : "Model Property";
  if (kind == DescKind.TYPE) return type;

  String name = buildPropertyName(e, property);
  if (kind == DescKind.NAME) return name;

  if (kind == DescKind.TYPE_NAME_VALUE) {
    String br = html ? "<br>" : "\n ";
    String[] bold = html ? new String[]{"<b>", "</b>"} : new String[]{"", ""};
    String valueSuffix = "";
    if (e instanceof XmlTag) {
      valueSuffix = ": " + bold[0] + ((XmlTag)e).getValue().getTrimmedText() + bold[1];
    }
    return type + br + name + valueSuffix;
  }

  MavenLog.LOG.error("unexpected desc kind: " + kind);
  return null;
}
项目:consulo-unity3d    文件:UnityScriptGotoClassContributor.java   
@Override
public void processElementsWithName(@NotNull String name, @NotNull final Processor<NavigationItem> processor, @NotNull 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());
                }

                @Nullable
                @Override
                public Icon getIcon(boolean open)
                {
                    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;
                }
            });
        }
    });
}
项目:tools-idea    文件:MavenModelDocumentationProvider.java   
@Nullable
private static String getMavenElementDescription(PsiElement e, DescKind kind, boolean html) {
  e = getMavenElement(e);
  if (e == null) return null;

  if (e instanceof FakePsiElement) {
    return ((FakePsiElement)e).getPresentableText();
  }

  boolean property = MavenDomUtil.isMavenProperty(e);

  String type = property ? "Property" : "Model Property";
  if (kind == DescKind.TYPE) return type;

  String name = buildPropertyName(e, property);
  if (kind == DescKind.NAME) return name;

  if (kind == DescKind.TYPE_NAME_VALUE) {
    String br = html ? "<br>" : "\n ";
    String[] bold = html ? new String[]{"<b>", "</b>"} : new String[]{"", ""};
    String valueSuffix = "";
    if (e instanceof XmlTag) {
      valueSuffix = ": " + bold[0] + ((XmlTag)e).getValue().getTrimmedText() + bold[1];
    }
    return type + br + name + valueSuffix;
  }

  MavenLog.LOG.error("unexpected desc kind: " + kind);
  return null;
}