下面列出了com.intellij.psi.SmartPointerManager#com.intellij.openapi.editor.markup.GutterIconRenderer 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void extractRelatedExpressions(@Nullable PsiElement element, @NotNull Collection<? super RelatedItemLineMarkerInfo<?>> result,
@NotNull FileBase containingFile) {
if (element == null) {
return;
}
FileBase psiRelatedFile = PsiFinder.getInstance(containingFile.getProject()).findRelatedFile(containingFile);
if (psiRelatedFile != null) {
Collection<PsiNameIdentifierOwner> expressions = psiRelatedFile.getExpressions(element.getText());
if (expressions.size() == 1) {
PsiNameIdentifierOwner relatedElement = expressions.iterator().next();
PsiElement nameIdentifier = relatedElement.getNameIdentifier();
if (nameIdentifier != null) {
String tooltip = GutterIconTooltipHelper
.composeText(new PsiElement[]{psiRelatedFile}, "", "Implements method <b>" + nameIdentifier.getText() + "</b> in <b>{0}</b>");
result.add(NavigationGutterIconBuilder.
create(containingFile.isInterface() ? ORIcons.IMPLEMENTED : ORIcons.IMPLEMENTING).
setTooltipText(tooltip).
setAlignment(GutterIconRenderer.Alignment.RIGHT).
setTargets(Collections.singleton(nameIdentifier instanceof PsiLowerSymbol ? nameIdentifier.getFirstChild() : nameIdentifier)).
createLineMarkerInfo(element));
}
}
}
}
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement) {
try {
PsiField psiFiled = this.getPsiFiled(psiElement);
PsiAnnotation psiAnnotation = this.getPsiAnnotation(psiFiled);
if (psiFiled != null && psiAnnotation != null) {
GlobalSearchScope moduleScope = psiElement.getResolveScope();
PsiTypeElementImpl psiTypeElement = this.getPsiTypeElement(psiAnnotation);
PsiClass psiClass = PsiTypesUtil.getPsiClass(psiTypeElement.getType());
String name = psiClass.getName();
List<PsiElement> list = this.getImplListElements(name, psiClass.getQualifiedName(), psiElement, moduleScope);
if (CollectionUtils.isNotEmpty(list)) {
return new LineMarkerInfo<>(psiTypeElement, psiTypeElement.getTextRange(), icon,
new FunctionTooltip(MessageFormat.format("快速跳转至 {0} 的 @IocBean 实现类", name)),
new IocBeanInterfaceNavigationHandler(name, list),
GutterIconRenderer.Alignment.LEFT);
}
}
} catch (Exception e) {
}
return null;
}
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement) {
try {
PsiAnnotation psiAnnotation = this.getPsiAnnotation(psiElement);
if (psiAnnotation != null) {
PsiLiteralExpression literalExpression = (PsiLiteralExpression) psiAnnotation.findAttributeValue("value");
String value = String.valueOf(literalExpression.getValue());
if (value.startsWith(JSON_PREFIX)) {
return new LineMarkerInfo<>(psiAnnotation, psiAnnotation.getTextRange(), NutzCons.NUTZ,
new FunctionTooltip("快速配置"),
new OkJsonUpdateNavigationHandler(value),
GutterIconRenderer.Alignment.LEFT);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@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
);
}
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
);
}
@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;
}
@RequiredReadAction
@Override
public void collect(PsiElement psiElement, @Nonnull Consumer<LineMarkerInfo> consumer)
{
if(psiElement.getNode().getElementType() == CSharpTokens.IDENTIFIER && psiElement.getParent() instanceof CSharpReferenceExpression &&
psiElement.getParent().getParent() instanceof CSharpMethodCallExpressionImpl)
{
PsiElement resolvedElement = ((CSharpReferenceExpression) psiElement.getParent()).resolve();
if(resolvedElement instanceof CSharpMethodDeclaration)
{
CSharpMethodDeclaration methodDeclaration = PsiTreeUtil.getParentOfType(psiElement, CSharpMethodDeclaration.class);
if(resolvedElement.isEquivalentTo(methodDeclaration))
{
LineMarkerInfo<PsiElement> lineMarkerInfo = new LineMarkerInfo<PsiElement>(psiElement, psiElement.getTextRange(), AllIcons.Gutter.RecursiveMethod, Pass.LINE_MARKERS,
FunctionUtil.constant("Recursive call"), null, GutterIconRenderer.Alignment.CENTER);
consumer.consume(lineMarkerInfo);
}
}
}
}
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
);
}
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
final GutterIconNavigationHandler<PsiElement> navHandler =
new GutterIconNavigationHandler<PsiElement>() {
@Override
public void navigate(MouseEvent e, PsiElement elt) {
System.out.println("don't click on me");
}
};
if ( element instanceof RuleSpecNode ) {
return new LineMarkerInfo<PsiElement>(element, element.getTextRange(), Icons.FILE,
Pass.UPDATE_ALL, null, navHandler,
GutterIconRenderer.Alignment.LEFT);
}
return null;
}
private AnAction findActionAtCaretWithText(Predicate<String> textMatcher) {
List<GutterMark> gutterMarks = myFixture.findGuttersAtCaret();
for (GutterMark gutterMark : gutterMarks) {
if (!(gutterMark instanceof GutterIconRenderer)) {
continue;
}
GutterIconRenderer renderer = (GutterIconRenderer) gutterMark;
ActionGroup group = renderer.getPopupMenuActions();
for (AnAction action : group.getChildren(new TestActionEvent())) {
TestActionEvent actionEvent = new TestActionEvent();
action.update(actionEvent);
String actualText = actionEvent.getPresentation().getText();
if (actualText == null) {
actualText = action.getTemplatePresentation().getText();
if (actualText == null) {
continue;
}
}
if (textMatcher.test(actualText)) {
return action;
}
}
}
return null;
}
@Nullable
private GutterIconRenderer createIconRenderer(@Nonnull final Side sourceSide,
@Nonnull final String tooltipText,
@Nonnull final Image icon) {
return new DiffGutterRenderer(icon, tooltipText) {
@Override
protected void performAction(AnActionEvent e) {
if (myViewer.isStateIsOutOfDate()) return;
if (!myViewer.isEditable(sourceSide.other(), true)) return;
final Project project = e.getProject();
final Document document = myViewer.getDocument(sourceSide.other());
DiffUtil.executeWriteCommand(document, project, "Replace change", () -> {
myViewer.replaceChange(UnifiedDiffChange.this, sourceSide);
myViewer.scheduleRediff();
});
// applyChange() will schedule rediff, but we want to try to do it in sync
// and we can't do it inside write action
myViewer.rediff();
}
};
}
@javax.annotation.Nullable
public GutterIconRenderer createRenderer() {
myCtrlPressed = myViewer.getModifierProvider().isCtrlPressed();
boolean isOtherEditable = DiffUtil.isEditable(myViewer.getEditor(mySide.other()));
boolean isAppendable = myFragment.getStartLine1() != myFragment.getEndLine1() &&
myFragment.getStartLine2() != myFragment.getEndLine2();
if (isOtherEditable) {
if (myCtrlPressed && isAppendable) {
return createAppendRenderer(mySide);
}
else {
return createApplyRenderer(mySide);
}
}
return null;
}
@Nullable
private GutterIconRenderer createIconRenderer(@Nonnull final Side sourceSide,
@Nonnull final String tooltipText,
@Nonnull final Image icon,
@Nonnull final Runnable perform) {
if (!DiffUtil.isEditable(myViewer.getEditor(sourceSide.other()))) return null;
return new DiffGutterRenderer(icon, tooltipText) {
@Override
protected void performAction(AnActionEvent e) {
if (!myIsValid) return;
final Project project = e.getProject();
final Document document = myViewer.getEditor(sourceSide.other()).getDocument();
DiffUtil.executeWriteCommand(document, project, "Replace change", perform);
}
};
}
/**
* Creates a line marker info for the element.
*
* @param element the element for which the line marker is created.
* @param range the range (relative to beginning of file) with which the marker is associated
* @param icon the icon to show in the gutter for the line marker
* @param updatePass the ID of the daemon pass during which the marker should be recalculated
* @param tooltipProvider the callback to calculate the tooltip for the gutter icon
* @param navHandler the handler executed when the gutter icon is clicked
*/
public LineMarkerInfo(@Nonnull T element,
@Nonnull TextRange range,
Image icon,
int updatePass,
@Nullable Function<? super T, String> tooltipProvider,
@Nullable GutterIconNavigationHandler<T> navHandler,
@Nonnull GutterIconRenderer.Alignment alignment) {
myIcon = icon;
myTooltipProvider = tooltipProvider;
myIconAlignment = alignment;
elementRef = SmartPointerManager.getInstance(element.getProject()).createSmartPsiElementPointer(element);
myNavigationHandler = navHandler;
startOffset = range.getStartOffset();
endOffset = range.getEndOffset();
this.updatePass = 11; //Pass.LINE_MARKERS;
}
@Nonnull
public static Pair<GutterIconRenderer, Object> findSelectedBreakpoint(@Nonnull final Project project, @Nonnull final Editor editor) {
int offset = editor.getCaretModel().getOffset();
Document editorDocument = editor.getDocument();
List<DebuggerSupport> debuggerSupports = DebuggerSupport.getDebuggerSupports();
for (DebuggerSupport debuggerSupport : debuggerSupports) {
final BreakpointPanelProvider<?> provider = debuggerSupport.getBreakpointPanelProvider();
final int textLength = editor.getDocument().getTextLength();
if (offset > textLength) {
offset = textLength;
}
Object breakpoint = provider.findBreakpoint(project, editorDocument, offset);
if (breakpoint != null) {
final GutterIconRenderer iconRenderer = provider.getBreakpointGutterIconRenderer(breakpoint);
return Pair.create(iconRenderer, breakpoint);
}
}
return Pair.create(null, null);
}
private static void addActions(@Nonnull Project project,
@Nonnull RangeHighlighterEx info,
@Nonnull List<? super HighlightInfo.IntentionActionDescriptor> descriptors,
@Nonnull DataContext dataContext) {
final GutterIconRenderer r = info.getGutterIconRenderer();
if (r == null || DumbService.isDumb(project) && !DumbService.isDumbAware(r)) {
return;
}
List<HighlightInfo.IntentionActionDescriptor> list = new ArrayList<>();
AtomicInteger order = new AtomicInteger();
AnAction[] actions = new AnAction[]{r.getClickAction(), r.getMiddleButtonClickAction(), r.getRightButtonClickAction()};
if (r.getPopupMenuActions() != null) {
actions = ArrayUtil.mergeArrays(actions, r.getPopupMenuActions().getChildren(null));
}
for (AnAction action : actions) {
if (action != null) {
addActions(action, list, r, order, dataContext);
}
}
descriptors.addAll(list);
}
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(PsiElement element) {
final List<PsiReferenceExpression> methodCalls = new ArrayList<>();
final List<Collection<String>> missingPropNames = new ArrayList<>();
// One annotation per statement
RequiredPropAnnotator.annotate(
element,
(missingRequiredPropNames, createMethodCall) -> {
methodCalls.add(createMethodCall);
missingPropNames.add(missingRequiredPropNames);
},
generatedClassResolver);
if (methodCalls.isEmpty()) {
return null;
}
PsiElement leaf = methodCalls.get(0);
final Collection<String> missingProps = missingPropNames.get(0);
while (leaf.getFirstChild() != null) {
leaf = leaf.getFirstChild();
}
return new LineMarkerInfo<>(
leaf,
leaf.getTextRange(),
LithoPluginIcons.ERROR_ACTION,
0,
ignored -> RequiredPropAnnotator.createErrorMessage(missingProps),
null,
GutterIconRenderer.Alignment.CENTER);
}
@Override
protected void collectNavigationMarkers(@NotNull PsiElement element, @NotNull Collection<? super RelatedItemLineMarkerInfo> result) {
PsiElement parent = element.getParent();
FileBase containingFile = (FileBase) element.getContainingFile();
if (element instanceof PsiTypeConstrName) {
FileBase psiRelatedFile = PsiFinder.getInstance(containingFile.getProject()).findRelatedFile(containingFile);
if (psiRelatedFile != null) {
Collection<PsiType> expressions = psiRelatedFile.getExpressions(element.getText(), PsiType.class);
if (expressions.size() == 1) {
PsiType relatedType = expressions.iterator().next();
PsiElement symbol = PsiTreeUtil.findChildOfType(element, PsiLowerSymbol.class);
PsiElement relatedSymbol = PsiTreeUtil.findChildOfType(relatedType, PsiLowerSymbol.class);
if (symbol != null && relatedSymbol != null) {
result.add(NavigationGutterIconBuilder.
create(containingFile.isInterface() ? ORIcons.IMPLEMENTED : ORIcons.IMPLEMENTING).
setAlignment(GutterIconRenderer.Alignment.RIGHT).
setTargets(Collections.singleton(relatedSymbol.getFirstChild())).
createLineMarkerInfo(symbol.getFirstChild()));
}
}
}
} else if (element instanceof PsiLowerSymbol && parent instanceof PsiLet && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) {
extractRelatedExpressions(element.getFirstChild(), result, containingFile);
} else if (element instanceof PsiLowerSymbol && parent instanceof PsiVal && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) {
extractRelatedExpressions(element.getFirstChild(), result, containingFile);
} else if (element instanceof PsiLowerSymbol && parent instanceof PsiExternal && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) {
extractRelatedExpressions(element.getFirstChild(), result, containingFile);
} else if (element instanceof PsiUpperSymbol && parent instanceof PsiInnerModule && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) {
extractRelatedExpressions(element.getFirstChild(), result, containingFile);
} else if (element instanceof PsiUpperSymbol && parent instanceof PsiException && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) {
extractRelatedExpressions(element.getFirstChild(), result, containingFile);
}
}
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement bindingElement) {
try {
if (NutzLineUtil.isAtOk(bindingElement)) {
JavaNutzTemplateVO vo = NutzLineUtil.getTemplateFilePathAndName(bindingElement);
Icon icon = NutzLineUtil.getTemplateIcon(vo.getFileExtension().split(";")[0]);
return new LineMarkerInfo<>(bindingElement, bindingElement.getTextRange(), icon,
new FunctionTooltip(), new NutzNavigationHandler(), GutterIconRenderer.Alignment.LEFT);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement) {
try {
if (SqlsXmlUtil.isSqsXmlFile(psiElement)) {
Icon icon = AllIcons.FileTypes.Java;
return new LineMarkerInfo<>(psiElement, psiElement.getTextRange(), icon,
new FunctionTooltip(), new Sqls2XmlNavigationHandler(),
GutterIconRenderer.Alignment.LEFT);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement psiElement) {
try {
if (SqlsXmlUtil.isSqlsXml(psiElement)) {
Icon icon = AllIcons.FileTypes.Xml;
return new LineMarkerInfo<>(psiElement, psiElement.getTextRange(), icon,
new FunctionTooltip(), new SqlsXmlNavigationHandler(),
GutterIconRenderer.Alignment.LEFT);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement bindingElement) {
try {
if (HtmlTemplateLineUtil.isRes(bindingElement)) {
return new LineMarkerInfo<>(bindingElement, bindingElement.getTextRange(), HtmlTemplateLineUtil.getTemplateIcon(bindingElement),
new FunctionTooltip(), new HtmlTemplateNavigationHandler(),
GutterIconRenderer.Alignment.LEFT);
}
} catch (Exception e) {
}
return null;
}
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) {
PsiElement queryElement = PsiTraversalUtilities.Cypher.getCypherStatement(element);
PsiElement lastQueryChild = isNull(queryElement) ? null : getFirstLeaf(queryElement);
if (element == lastQueryChild) {
return new LineMarkerInfo<PsiElement>(element,
element.getTextRange(),
AllIcons.Actions.Execute,
element1 -> "Execute Query",
(mouseEvent, psiElement) ->
getDataContext().ifPresent(c ->
ActionUtil.invokeAction(new ExecuteQueryAction(queryElement), c, "", mouseEvent, null)),
GutterIconRenderer.Alignment.CENTER) {
@Override
public GutterIconRenderer createGutterRenderer() {
return new LineMarkerGutterIconRenderer<PsiElement>(this) {
@Override
public AnAction getClickAction() {
return new ExecuteQueryAction(queryElement);
}
@Override
public boolean isNavigateAction() {
return true;
}
};
}
};
}
return null;
}
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
if (!GraphQLConfigManager.GRAPHQLCONFIG.equals(element.getContainingFile().getName())) {
return null;
}
if (element instanceof JsonProperty) {
final JsonProperty jsonProperty = (JsonProperty) element;
final Ref<String> urlRef = Ref.create();
if (isEndpointUrl(jsonProperty, urlRef) && !hasErrors(jsonProperty.getContainingFile())) {
return new LineMarkerInfo<>(jsonProperty, jsonProperty.getTextRange(), AllIcons.RunConfigurations.TestState.Run, Pass.UPDATE_ALL, o -> "Run introspection query to generate GraphQL SDL schema file", (evt, jsonUrl) -> {
String introspectionUtl;
if (jsonUrl.getValue() instanceof JsonStringLiteral) {
introspectionUtl = ((JsonStringLiteral) jsonUrl.getValue()).getValue();
} else {
return;
}
final GraphQLConfigVariableAwareEndpoint endpoint = getEndpoint(introspectionUtl, jsonProperty);
if (endpoint == null) {
return;
}
String schemaPath = getSchemaPath(jsonProperty, true);
if (schemaPath == null || schemaPath.trim().isEmpty()) {
return;
}
final Project project = element.getProject();
final VirtualFile introspectionSourceFile = element.getContainingFile().getVirtualFile();
GraphQLIntrospectionHelper.getService(project).performIntrospectionQueryAndUpdateSchemaPathFile(endpoint, schemaPath, introspectionSourceFile);
}, GutterIconRenderer.Alignment.CENTER);
}
}
return null;
}
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
if (element.getNode().getElementType() == BashTokenTypes.WORD && element.getParent() instanceof BashFunctionDefName && element.getParent().getParent() instanceof BashFunctionDef) {
return new LineMarkerInfo<>(element, element.getTextRange(), PlatformIcons.METHOD_ICON, Pass.UPDATE_ALL, null, null, GutterIconRenderer.Alignment.LEFT);
}
return null;
}
@RequiredReadAction
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@Nonnull 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;
}
@RequiredReadAction
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@Nonnull PsiElement element)
{
for(Unity3dAssetCSharpLineMarker marker : Unity3dAssetCSharpLineMarker.values())
{
Class<? extends PsiElement> clazz = marker.getElementClass();
PsiElement declaration = CSharpLineMarkerUtil.getNameIdentifierAs(element, clazz);
if(declaration != null)
{
String uuid = Unity3dAssetUtil.getGUID(element.getProject(), PsiUtilCore.getVirtualFile(declaration));
if(uuid == null )
{
return null;
}
if(marker.isAvailable(declaration))
{
return new LineMarkerInfo<>(element, element.getTextRange(), marker.getIcon(), Pass.LINE_MARKERS, marker.createTooltipFunction(), marker.createNavigationHandler(),
GutterIconRenderer.Alignment.LEFT);
}
}
}
return null;
}
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement expr) {
//todo: add navigation support for guttericons and tooltips
if (expr instanceof GLSLFunctionDefinitionImpl) {
//todo: check if a prototype exists
return new LineMarkerInfo<>((GLSLFunctionDefinitionImpl) expr, expr.getTextRange(),
implementing, Pass.UPDATE_ALL, null, null, GutterIconRenderer.Alignment.RIGHT);
} else if (expr instanceof GLSLFunctionDeclarationImpl) {
//todo: check if it is implemented
return new LineMarkerInfo<>((GLSLFunctionDeclarationImpl) expr, expr.getTextRange(),
implemented, Pass.UPDATE_ALL, null, null, GutterIconRenderer.Alignment.RIGHT);
}
return null;
}
public MarkerInfo(@Nonnull PsiElement element,
@Nonnull TextRange textRange,
Image icon,
int updatePass,
@Nullable Function<? super PsiElement, String> tooltipProvider,
@Nullable GutterIconNavigationHandler<PsiElement> navHandler,
@Nonnull GutterIconRenderer.Alignment alignment)
{
super(element, textRange, icon, updatePass, tooltipProvider, navHandler, alignment);
}
/**
* Returns {@link LineMarkerInfo} with set {@link PlatformIcons#FOLDER_ICON} if entry points to the directory.
*
* @param element current element
* @return <code>null</code> if entry is not a directory
*/
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) {
if (!(element instanceof IgnoreEntryFile)) {
return null;
}
boolean isDirectory = element instanceof IgnoreEntryDirectory;
if (!isDirectory) {
final String key = element.getText();
if (cache.containsKey(key)) {
isDirectory = cache.get(key);
} else {
final IgnoreEntryFile entry = (IgnoreEntryFile) element;
final VirtualFile parent = element.getContainingFile().getVirtualFile().getParent();
if (parent == null) {
return null;
}
final Project project = element.getProject();
final Module module = Utils.getModuleForFile(parent, project);
if (module == null) {
return null;
}
final MatcherUtil matcher = IgnoreManager.getInstance(project).getMatcher();
final VirtualFile file = Glob.findOne(parent, entry, matcher);
cache.put(key, isDirectory = file != null && file.isDirectory());
}
}
if (isDirectory) {
return new LineMarkerInfo<>(element.getFirstChild(), element.getTextRange(),
PlatformIcons.FOLDER_ICON, null, null, GutterIconRenderer.Alignment.CENTER);
}
return null;
}