本文整理汇总了Java中com.intellij.util.ConstantFunction类的典型用法代码示例。如果您正苦于以下问题:Java ConstantFunction类的具体用法?Java ConstantFunction怎么用?Java ConstantFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConstantFunction类属于com.intellij.util包,在下文中一共展示了ConstantFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllowedNamespaces
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
/**
* Consider using {@link DomService#getXmlFileHeader(com.intellij.psi.xml.XmlFile)} when implementing this.
*/
@SuppressWarnings({"MethodMayBeStatic"})
@NotNull
public List<String> getAllowedNamespaces(@NotNull String namespaceKey, @NotNull XmlFile file) {
final NotNullFunction<XmlTag, List<String>> function = myNamespacePolicies.get(namespaceKey);
if (function instanceof ConstantFunction) {
return function.fun(null);
}
if (function != null) {
final XmlDocument document = file.getDocument();
if (document != null) {
final XmlTag tag = document.getRootTag();
if (tag != null) {
return function.fun(tag);
}
}
} else {
return Collections.singletonList(namespaceKey);
}
return Collections.emptyList();
}
示例2: getRelatedPopover
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
@NotNull
private LineMarkerInfo getRelatedPopover(@NotNull String singleItemTitle, @NotNull String singleItemTooltipPrefix, @NotNull PsiElement lineMarkerTarget, @NotNull Collection<GotoRelatedItem> gotoRelatedItems, @NotNull Icon icon) {
// single item has no popup
String title = singleItemTitle;
if(gotoRelatedItems.size() == 1) {
String customName = gotoRelatedItems.iterator().next().getCustomName();
if(customName != null) {
title = String.format(singleItemTooltipPrefix, customName);
}
}
return new LineMarkerInfo<>(
lineMarkerTarget,
lineMarkerTarget.getTextRange(),
icon,
6,
new ConstantFunction<>(title),
new RelatedPopupGotoLineMarker.NavigationHandler(gotoRelatedItems),
GutterIconRenderer.Alignment.RIGHT
);
}
示例3: getRelatedPopover
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
private LineMarkerInfo getRelatedPopover(String singleItemTitle, String singleItemTooltipPrefix, PsiElement lineMarkerTarget, List<GotoRelatedItem> gotoRelatedItems) {
// single item has no popup
String title = singleItemTitle;
if(gotoRelatedItems.size() == 1) {
String customName = gotoRelatedItems.get(0).getCustomName();
if(customName != null) {
title = String.format(singleItemTooltipPrefix, customName);
}
}
return new LineMarkerInfo<>(
lineMarkerTarget,
lineMarkerTarget.getTextRange(),
ShopwarePluginIcons.SHOPWARE_LINEMARKER,
6,
new ConstantFunction<>(title),
new fr.adrienbrault.idea.symfony2plugin.dic.RelatedPopupGotoLineMarker.NavigationHandler(gotoRelatedItems),
GutterIconRenderer.Alignment.RIGHT
);
}
示例4: createMarker
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
@Nullable
@RequiredReadAction
private static LineMarkerInfo createMarker(final PsiElement element)
{
CSharpMethodDeclaration methodDeclaration = CSharpLineMarkerUtil.getNameIdentifierAs(element, CSharpMethodDeclaration.class);
if(methodDeclaration != null)
{
Unity3dModuleExtension extension = ModuleUtilCore.getExtension(element, Unity3dModuleExtension.class);
if(extension == null)
{
return null;
}
UnityFunctionManager.FunctionInfo magicMethod = findMagicMethod(methodDeclaration);
if(magicMethod != null)
{
return new LineMarkerInfo<>(element, element.getTextRange(), Unity3dIcons.EventMethod, Pass.LINE_MARKERS, new ConstantFunction<>(magicMethod.getDescription()), null,
GutterIconRenderer.Alignment.LEFT);
}
}
return null;
}
示例5: createLineMarkerInfo
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
public RelatedItemLineMarkerInfo<PsiElement> createLineMarkerInfo(@NotNull PsiElement element) {
final MyNavigationGutterIconRenderer renderer = createGutterIconRenderer(element.getProject());
final String tooltip = renderer.getTooltipText();
NotNullLazyValue<Collection<? extends GotoRelatedItem>> gotoTargets = new NotNullLazyValue<Collection<? extends GotoRelatedItem>>() {
@NotNull
@Override
protected Collection<? extends GotoRelatedItem> compute() {
if (myGotoRelatedItemProvider != null) {
return ContainerUtil.concat(myTargets.getValue(), myGotoRelatedItemProvider);
}
return Collections.emptyList();
}
};
return new RelatedItemLineMarkerInfo<PsiElement>(element, element.getTextRange(), renderer.getIcon(), Pass.UPDATE_OVERRIDEN_MARKERS,
tooltip == null ? null : new ConstantFunction<PsiElement, String>(tooltip),
renderer.isNavigateAction() ? renderer : null, renderer.getAlignment(),
gotoTargets);
}
示例6: getRelatedPopover
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
private LineMarkerInfo getRelatedPopover(String singleItemTitle, String singleItemTooltipPrefix, PsiElement lineMarkerTarget, List<GotoRelatedItem> gotoRelatedItems, Icon icon) {
// single item has no popup
String title = singleItemTitle;
if(gotoRelatedItems.size() == 1) {
String customName = gotoRelatedItems.get(0).getCustomName();
if(customName != null) {
title = String.format(singleItemTooltipPrefix, customName);
}
}
return new LineMarkerInfo<>(
lineMarkerTarget,
lineMarkerTarget.getTextRange(),
icon,
6,
new ConstantFunction<>(title),
new RelatedPopupGotoLineMarker.NavigationHandler(gotoRelatedItems),
GutterIconRenderer.Alignment.RIGHT
);
}
示例7: createLineMarkerInfo
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
public RelatedItemLineMarkerInfo<PsiElement> createLineMarkerInfo(@Nonnull PsiElement element) {
final MyNavigationGutterIconRenderer renderer = createGutterIconRenderer(element.getProject());
final String tooltip = renderer.getTooltipText();
NotNullLazyValue<Collection<? extends GotoRelatedItem>> gotoTargets = new NotNullLazyValue<Collection<? extends GotoRelatedItem>>() {
@Nonnull
@Override
protected Collection<? extends GotoRelatedItem> compute() {
if (myGotoRelatedItemProvider != null) {
return ContainerUtil.concat(myTargets.getValue(), myGotoRelatedItemProvider);
}
return Collections.emptyList();
}
};
return new RelatedItemLineMarkerInfo<PsiElement>(element, element.getTextRange(), renderer.getIcon(), Pass.LINE_MARKERS,
tooltip == null ? null : new ConstantFunction<PsiElement, String>(tooltip),
renderer.isNavigateAction() ? renderer : null, renderer.getAlignment(),
gotoTargets);
}
示例8: createLineMakerInfo
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
@NotNull
private LineMarkerInfo<PsiElement> createLineMakerInfo(@NotNull PsiElement psiElement, @NotNull Icon icon) {
return new LineMarkerInfo<>(
psiElement,
psiElement.getTextRange(),
icon,
6,
new ConstantFunction<>("Run Test"),
new MyProgramRunnerGutterIconNavigationHandler(),
GutterIconRenderer.Alignment.LEFT
);
}
示例9: extractExpectedLineMarkerSet
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
private void extractExpectedLineMarkerSet(Document document) {
String text = document.getText();
@NonNls String pat = ".*?((<" + LINE_MARKER + ")(?: descr=\"((?:[^\"\\\\]|\\\\\")*)\")?>)(.*)";
final Pattern p = Pattern.compile(pat, Pattern.DOTALL);
final Pattern pat2 = Pattern.compile("(.*?)(</" + LINE_MARKER + ">)(.*)", Pattern.DOTALL);
while (true) {
Matcher m = p.matcher(text);
if (!m.matches()) break;
int startOffset = m.start(1);
final String descr = m.group(3) != null ? m.group(3) : ANY_TEXT;
String rest = m.group(4);
document.replaceString(startOffset, m.end(1), "");
final Matcher matcher2 = pat2.matcher(rest);
LOG.assertTrue(matcher2.matches(), "Cannot find closing </" + LINE_MARKER + ">");
String content = matcher2.group(1);
int endOffset = startOffset + matcher2.start(3);
String endTag = matcher2.group(2);
document.replaceString(startOffset, endOffset, content);
endOffset -= endTag.length();
LineMarkerInfo markerInfo = new LineMarkerInfo<PsiElement>(myFile, new TextRange(startOffset, endOffset), null, Pass.LINE_MARKERS,
new ConstantFunction<PsiElement, String>(descr), null,
GutterIconRenderer.Alignment.RIGHT);
lineMarkerInfos.put(document.createRangeMarker(startOffset, endOffset), markerInfo);
text = document.getText();
}
}
示例10: createLineMarkerInfo
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
public RelatedItemLineMarkerInfo<PsiElement> createLineMarkerInfo(@NotNull PsiElement element) {
final MyNavigationGutterIconRenderer renderer = createGutterIconRenderer(element.getProject());
final String tooltip = renderer.getTooltipText();
NotNullLazyValue<Collection<? extends GotoRelatedItem>> gotoTargets = createGotoTargetsThunk(myLazy, myGotoRelatedItemProvider,
evaluateAndForget(myTargets));
return new RelatedItemLineMarkerInfo<PsiElement>(element, element.getTextRange(), renderer.getIcon(), Pass.UPDATE_OVERRIDEN_MARKERS,
tooltip == null ? null : new ConstantFunction<PsiElement, String>(tooltip),
renderer.isNavigateAction() ? renderer : null, renderer.getAlignment(),
gotoTargets);
}
示例11: doGetLineMarkerInfo
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
private static LineMarkerInfo doGetLineMarkerInfo(PsiElement element) {
final MyMarkerInfo info = getMarkerInfo(element);
if (info == null) {
return null;
}
final PsiElement anchor = info.myElement;
final String tooltip = info.myTooltip;
return new LineMarkerInfo<PsiElement>(
anchor, anchor.getTextOffset(), info.myIcon, Pass.UPDATE_OVERRIDEN_MARKERS,
new ConstantFunction<PsiElement, String>(tooltip), new MyNavigationHandler(info));
}
示例12: getRelatedPopover
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
private LineMarkerInfo getRelatedPopover(String singleItemTitle, String singleItemTooltipPrefix, PsiElement lineMarkerTarget, List<GotoRelatedItem> gotoRelatedItems) {
// single item has no popup
String title = singleItemTitle;
if(gotoRelatedItems.size() == 1) {
String customName = gotoRelatedItems.get(0).getCustomName();
if(customName != null) {
title = String.format(singleItemTooltipPrefix, customName);
}
}
return new LineMarkerInfo<PsiElement>(lineMarkerTarget, lineMarkerTarget.getTextOffset(), OxidPluginIcons.OXID_LINEMARKER, 6, new ConstantFunction<PsiElement, String>(title), new fr.adrienbrault.idea.symfony2plugin.dic.RelatedPopupGotoLineMarker.NavigationHandler(gotoRelatedItems));
}
示例13: getLineMarkerInfo
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
@RequiredReadAction
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element)
{
if(element.getNode().getElementType() == JSTokenTypes.IDENTIFIER && element.getParent() instanceof JSReferenceExpression && element.getParent().getParent() instanceof JSFunction)
{
UnityFunctionManager functionManager = UnityFunctionManager.getInstance();
Map<String, UnityFunctionManager.FunctionInfo> map = functionManager.getFunctionsByType().get(Unity3dTypes.UnityEngine.MonoBehaviour);
if(map == null)
{
return null;
}
UnityFunctionManager.FunctionInfo functionInfo = map.get(element.getText());
if(functionInfo == null)
{
return null;
}
Unity3dModuleExtension extension = ModuleUtilCore.getExtension(element, Unity3dModuleExtension.class);
if(extension == null)
{
return null;
}
JSFunction jsFunction = (JSFunction) element.getParent().getParent();
if(jsFunction.getParent() instanceof JSFile)
{
if(!isEqualParameters(functionInfo.getParameters(), jsFunction))
{
return null;
}
return new LineMarkerInfo<>(element, element.getTextRange(), Unity3dIcons.EventMethod, Pass.LINE_MARKERS, new ConstantFunction<>(functionInfo.getDescription()), null,
GutterIconRenderer.Alignment.LEFT);
}
}
return null;
}
示例14: collectSlowLineMarkers
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
for(PsiElement psiElement : elements) {
List<GotoRelatedItem> gotoRelatedItems = new ArrayList<GotoRelatedItem>();
List<PsiFile> psiFiles = new ArrayList<PsiFile>();
// android studio provide line marker with xml targets only on root classes not on class inside classes like fragments
// we support all of them :)
if(psiElement instanceof PsiIdentifier && psiElement.getParent() instanceof PsiClass && !(psiElement.getParent().getParent() instanceof PsiFile)) {
// simple hack activity provide this on core
if(isFragmentClass((PsiClass) psiElement.getParent())) {
Collection<PsiMethodCallExpression> PsiMethodCallExpressions = PsiTreeUtil.collectElementsOfType(psiElement.getParent(), PsiMethodCallExpression.class);
for(PsiMethodCallExpression methodCallExpression: PsiMethodCallExpressions) {
PsiMethod psiMethod = methodCallExpression.resolveMethod();
if(psiMethod != null && psiMethod.getName().equals("inflate")) {
PsiExpression[] expressions = methodCallExpression.getArgumentList().getExpressions();
if(expressions.length > 0 && expressions[0] instanceof PsiReferenceExpression) {
PsiFile xmlFile = AndroidUtils.findXmlResource((PsiReferenceExpression) expressions[0]);
if(xmlFile != null && !psiFiles.contains(xmlFile)) {
psiFiles.add(xmlFile);
gotoRelatedItems.add(new GotoRelatedItem(xmlFile));
}
}
}
}
}
}
if(gotoRelatedItems.size() > 0) {
result.add(new LineMarkerInfo<PsiElement>(psiElement, psiElement.getTextOffset(), AndroidIcons.AndroidToolWindow, 6, new ConstantFunction<PsiElement, String>("Related Files"), new RelatedPopupGotoLineMarker.NavigationHandler(gotoRelatedItems)));
}
}
}
示例15: getLineMarkerInfo
import com.intellij.util.ConstantFunction; //导入依赖的package包/类
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement)
{
PlayBaseTemplateFile templateFile = findTemplateFile(psiElement);
if(templateFile != null)
{
return new LineMarkerInfo<>(psiElement, psiElement.getTextRange(), PlayJavaIcons.PlayLineMarker, Pass.LINE_MARKERS,
new ConstantFunction<>("Navigate to template"), GUTTER_ICON_NAVIGATION_HANDLER, GutterIconRenderer.Alignment.LEFT);
}
return null;
}