本文整理汇总了Java中com.intellij.codeInsight.daemon.LineMarkerInfo类的典型用法代码示例。如果您正苦于以下问题:Java LineMarkerInfo类的具体用法?Java LineMarkerInfo怎么用?Java LineMarkerInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LineMarkerInfo类属于com.intellij.codeInsight.daemon包,在下文中一共展示了LineMarkerInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertLineMarker
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
public void assertLineMarker(@NotNull PsiElement psiElement, @NotNull LineMarker.Assert assertMatch) {
final List<PsiElement> elements = collectPsiElementsRecursive(psiElement);
for (LineMarkerProvider lineMarkerProvider : LineMarkerProviders.INSTANCE.allForLanguage(psiElement.getLanguage())) {
Collection<LineMarkerInfo> lineMarkerInfos = new ArrayList<LineMarkerInfo>();
lineMarkerProvider.collectSlowLineMarkers(elements, lineMarkerInfos);
if(lineMarkerInfos.size() == 0) {
continue;
}
for (LineMarkerInfo lineMarkerInfo : lineMarkerInfos) {
if(assertMatch.match(lineMarkerInfo)) {
return;
}
}
}
fail(String.format("Fail that '%s' matches on of '%s' PsiElements", assertMatch.getClass(), elements.size()));
}
示例2: match
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
@Override
public boolean match(@NotNull LineMarkerInfo markerInfo) {
if(markerInfo.getLineMarkerTooltip() == null || !markerInfo.getLineMarkerTooltip().equals(toolTip)) {
return false;
}
if(!(markerInfo instanceof RelatedItemLineMarkerInfo)) {
return false;
}
for (Object o : ((RelatedItemLineMarkerInfo) markerInfo).createGotoRelatedItems()) {
if(o instanceof GotoRelatedItem && this.pattern.accepts(((GotoRelatedItem) o).getElement())) {
return true;
}
}
return false;
}
示例3: getRelatedFiles
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
@Nullable
private LineMarkerInfo getRelatedFiles(@NotNull PsiFile file, @NotNull String controllerName, @NotNull PsiElement element) {
if (!(element instanceof Method)) {
return null;
}
Method method = (Method)element;
if (!method.getAccess().isPublic()) {
return null;
}
String methodName = method.getName();
PsiDirectory appDir = PsiUtil.getAppDirectoryFromFile(file);
String templatePath = String.format("View/%s/%s.ctp", controllerName, methodName);
VirtualFile relativeFile = VfsUtil.findRelativeFile(appDir, templatePath);
if (relativeFile == null) {
return null;
}
PsiFile targetFile = PsiUtil.convertVirtualFileToPsiFile(method.getProject(), relativeFile);
if (targetFile == null) {
return null;
}
PsiElement targetElement = targetFile.getFirstChild();
NavigationGutterIconBuilder<PsiElement> builder = NavigationGutterIconBuilder.create(CakeIcons.LOGO).setTarget(targetElement);
return builder.createLineMarkerInfo(method);
}
示例4: collectSlowLineMarkers
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> list, @NotNull Collection<LineMarkerInfo> collection) {
for (PsiElement element : list) {
PsiFile file = element.getContainingFile();
if (file == null) {
continue;
}
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
continue;
}
String controllerName = CakeUtil.controllerBaseNameFromControllerFileName(virtualFile.getNameWithoutExtension());
if (controllerName == null) {
continue;
}
LineMarkerInfo info = getRelatedFiles(file, controllerName, element);
addLineMarkerUnique(collection, info);
PsiElement[] children = element.getChildren();
for (PsiElement child : children) {
info = getRelatedFiles(file, controllerName, child);
addLineMarkerUnique(collection, info);
}
}
}
示例5: getLineMarkerInfo
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
/**
* @return a {@link com.intellij.codeInsight.daemon.GutterIconNavigationHandler} if the element
* is a PsiMethod annotated with @SideEffect.
*/
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) {
// Check if expression
if (element instanceof PsiReferenceExpression) {
PsiReferenceExpression referenceExpression = (PsiReferenceExpression) element;
// Check if expression has method
if (referenceExpression.resolve() instanceof PsiMethod) {
PsiMethod method = (PsiMethod) referenceExpression.resolve();
// Does it have a @SideEffect?
if (hasAnnotation(method, CLASS_SIDE_EFFECT)) {
return new LineMarkerInfo<PsiElement>(element, element.getTextRange(), ICON,
UPDATE_ALL, null, null, LEFT);
}
}
}
return null;
}
示例6: collectSlowLineMarkers
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
for (PsiElement el : elements) {
if (!(el instanceof FusionType)
|| !(el.getParent() instanceof FusionPrototypeSignature)
|| (((FusionPrototypeSignature) el.getParent()).isInheritedInDefinition())
|| (el.getParent().getParent().getParent() instanceof FusionPropertyDeletion)) {
continue;
}
FusionType type = (FusionType) el;
Collection<PsiElement> targets = ResolveEngine.getNodeTypeDefinitions(el.getProject(), type);
if (!targets.isEmpty()) {
RelatedItemLineMarkerInfo info = NavigationGutterIconBuilder
.create(NeosIcons.NODE_TYPE)
.setTargets(targets)
.setTooltipText("Go to node type definition")
.createLineMarkerInfo(el);
result.add(info);
}
}
}
示例7: collectSlowLineMarkers
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
for (PsiElement el : elements) {
if (el instanceof Method && ((Method) el).getAccess().isPublic()) {
VirtualFile template = ResolveEngine.findTemplate((Method) el);
if (template != null) {
PsiFile target = PsiManager.getInstance(el.getProject()).findFile(template);
RelatedItemLineMarkerInfo info = NavigationGutterIconBuilder
.create(NeosIcons.NODE_TYPE)
.setTarget(target)
.setTooltipText("Go to template")
.createLineMarkerInfo(el);
result.add(info);
}
}
}
}
示例8: testCamelGutterForVariableAndConstant
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
public void testCamelGutterForVariableAndConstant() {
myFixture.configureByFiles("JavaCamelRouteLineMarkerProviderFromVariableTestData.java");
List<GutterMark> gutters = myFixture.findAllGutters();
assertNotNull(gutters);
//remove first element since it is navigate to super implementation gutter icon
gutters.remove(0);
assertEquals("Should contain 2 Camel gutters", 2, gutters.size());
assertGuttersHasCamelIcon(gutters);
LineMarkerInfo.LineMarkerGutterIconRenderer firstGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(0);
assertTrue(firstGutter.getLineMarkerInfo().getElement() instanceof PsiIdentifier);
assertEquals("The navigation start element doesn't match", "uriVar",
firstGutter.getLineMarkerInfo().getElement().getText());
List<GotoRelatedItem> firstGutterTargets = getGutterNavigationDestinationElements(firstGutter);
assertEquals("Navigation should have two targets", 2, firstGutterTargets.size());
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:21,代码来源:JavaCamelRouteLineMarkerProviderTestIT.java
示例9: testCamelGutterForMethodCallFrom
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
public void testCamelGutterForMethodCallFrom() {
myFixture.configureByFiles("JavaCamelRouteLineMarkerProviderFromMethodCallTestData.java");
List<GutterMark> gutters = myFixture.findAllGutters();
assertNotNull(gutters);
//remove first element since it is navigate to super implementation gutter icon
gutters.remove(0);
// remove last element since it is from method returning route uri
gutters.remove(gutters.size() - 1);
assertEquals("Should contain 1 Camel gutters", 1, gutters.size());
assertGuttersHasCamelIcon(gutters);
LineMarkerInfo.LineMarkerGutterIconRenderer firstGutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(0);
assertTrue(firstGutter.getLineMarkerInfo().getElement() instanceof PsiIdentifier);
assertEquals("The navigation start element doesn't match", "calcEndpoint",
firstGutter.getLineMarkerInfo().getElement().getText());
List<GotoRelatedItem> firstGutterTargets = getGutterNavigationDestinationElements(firstGutter);
assertEquals("Navigation should have two targets", 2, firstGutterTargets.size());
assertEquals("The navigation variable target element doesn't match", "calcEndpoint",
getGuttersWithMethodTarget(firstGutterTargets).get(0).getName());
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:25,代码来源:JavaCamelRouteLineMarkerProviderTestIT.java
示例10: testCamelGutterForToD
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
public void testCamelGutterForToD() {
myFixture.configureByFiles("XmlCamelRouteLineMarkerProviderToDTestData.xml");
List<GutterMark> gutters = myFixture.findAllGutters();
assertNotNull(gutters);
assertEquals("Should contain 1 Camel gutter", 1, gutters.size());
assertSame("Gutter should have the Camel icon", ServiceManager.getService(CamelPreferenceService.class).getCamelIcon(), gutters.get(0).getIcon());
assertEquals("Camel route", gutters.get(0).getTooltipText());
LineMarkerInfo.LineMarkerGutterIconRenderer gutter = (LineMarkerInfo.LineMarkerGutterIconRenderer) gutters.get(0);
assertTrue(gutter.getLineMarkerInfo().getElement() instanceof XmlToken);
assertEquals("The navigation start element doesn't match", "file:inbox",
PsiTreeUtil.getParentOfType(gutter.getLineMarkerInfo().getElement(), XmlTag.class).getAttribute("uri").getValue());
List<GotoRelatedItem> gutterTargets = getGutterNavigationDestinationElements(gutter);
assertEquals("Navigation should have one target", 1, gutterTargets.size());
assertEquals("The navigation target route doesn't match", "file:inbox", gutterTargets.get(0).getElement().getText());
assertEquals("The navigation target tag name doesn't match", "toD",
getGuttersWithXMLTarget(gutterTargets).get(0).getLocalName());
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:24,代码来源:XmlCamelRouteLineMarkerProviderTestIT.java
示例11: createIconLineMarker
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
@Nullable
private static LineMarkerInfo<PsiElement> createIconLineMarker(PsiType type,
@Nullable PsiExpression initializer,
PsiElement bindingElement) {
if (initializer == null) return null;
final Project project = initializer.getProject();
final VirtualFile file = ProjectIconsAccessor.getInstance(project).resolveIconFile(type, initializer);
if (file == null) return null;
final Icon icon = ProjectIconsAccessor.getInstance(project).getIcon(file);
if (icon == null) return null;
final GutterIconNavigationHandler<PsiElement> navHandler = new GutterIconNavigationHandler<PsiElement>() {
@Override
public void navigate(MouseEvent e, PsiElement elt) {
FileEditorManager.getInstance(project).openFile(file, true);
}
};
return new LineMarkerInfo<PsiElement>(bindingElement, bindingElement.getTextRange(), icon,
Pass.UPDATE_ALL, null, navHandler,
GutterIconRenderer.Alignment.LEFT);
}
示例12: collectSlowLineMarkers
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements,
@NotNull Collection<LineMarkerInfo> result) {
final Set<PsiStatement> statements = new HashSet<PsiStatement>();
for (PsiElement element : elements) {
ProgressManager.checkCanceled();
if (element instanceof PsiMethodCallExpression) {
final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)element;
final PsiStatement statement = PsiTreeUtil.getParentOfType(methodCall, PsiStatement.class, true, PsiMethod.class);
if (!statements.contains(statement) && isRecursiveMethodCall(methodCall)) {
statements.add(statement);
result.add(new RecursiveMethodCallMarkerInfo(methodCall));
}
}
}
}
示例13: testLambdaMarker
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
public void testLambdaMarker() throws Exception {
configureByFile(getBasePath() + getTestName(false) + ".java");
int offset = myEditor.getCaretModel().getOffset();
doHighlighting();
Document document = getEditor().getDocument();
List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject());
for (LineMarkerInfo info : markers) {
if (info.endOffset >= offset && info.startOffset <= offset) {
Shortcut shortcut = ActionManager.getInstance().getAction(IdeActions.ACTION_GOTO_SUPER).getShortcutSet().getShortcuts()[0];
assertEquals(
"<html><body>Overrides method in <a href=\"#javaClass/I\">I</a><br><div style='margin-top: 5px'><font size='2'>Click or press " +
KeymapUtil.getShortcutText(shortcut) +
" to navigate</font></div></body></html>",
info.getLineMarkerTooltip());
return;
}
}
fail("Gutter expected");
}
示例14: testSiblingInheritanceLineMarkers
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
public void testSiblingInheritanceLineMarkers() throws Throwable {
configureByFile(getBasePath() + "SiblingInheritance.java");
PsiJavaFile file = (PsiJavaFile)getFile();
PsiClass i = JavaPsiFacade.getInstance(getProject()).findClass("z.I", GlobalSearchScope.fileScope(file));
PsiClass a = JavaPsiFacade.getInstance(getProject()).findClass("z.A", GlobalSearchScope.fileScope(file));
PsiMethod iRun = i.getMethods()[0];
assertEquals("run", iRun.getName());
PsiMethod aRun = a.getMethods()[0];
assertEquals("run", aRun.getName());
doHighlighting();
Document document = getEditor().getDocument();
List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject());
assertTrue(markers.size() >= 2);
LineMarkerInfo iMarker = findMarkerWithElement(markers, iRun.getNameIdentifier());
assertSame(MarkerType.OVERRIDDEN_METHOD.getNavigationHandler(), iMarker.getNavigationHandler());
LineMarkerInfo aMarker = findMarkerWithElement(markers, aRun.getNameIdentifier());
assertSame(MarkerType.SIBLING_OVERRIDING_METHOD.getNavigationHandler(), aMarker.getNavigationHandler());
}
示例15: testDoNotShowSiblingInheritanceLineMarkerIfSubclassImplementsTheSameInterfaceAsTheCurrentClass
import com.intellij.codeInsight.daemon.LineMarkerInfo; //导入依赖的package包/类
public void testDoNotShowSiblingInheritanceLineMarkerIfSubclassImplementsTheSameInterfaceAsTheCurrentClass() throws Throwable {
configureByFile(getBasePath() + "DeceivingSiblingInheritance.java");
PsiJavaFile file = (PsiJavaFile)getFile();
PsiClass OCBaseLanguageFileType = JavaPsiFacade.getInstance(getProject()).findClass("z.OCBaseLanguageFileType", GlobalSearchScope.fileScope(file));
PsiMethod getName = OCBaseLanguageFileType.getMethods()[0];
assertEquals("getName", getName.getName());
doHighlighting();
Document document = getEditor().getDocument();
List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject());
List<LineMarkerInfo> inMyClass = ContainerUtil.filter(markers, info -> {
return OCBaseLanguageFileType.getTextRange().containsRange(info.startOffset, info.endOffset);
});
assertTrue(inMyClass.toString(), inMyClass.size() == 2);
LineMarkerInfo iMarker = findMarkerWithElement(inMyClass, getName.getNameIdentifier());
assertSame(MarkerType.OVERRIDING_METHOD.getNavigationHandler(), iMarker.getNavigationHandler());
LineMarkerInfo aMarker = findMarkerWithElement(inMyClass, OCBaseLanguageFileType.getNameIdentifier());
assertSame(MarkerType.SUBCLASSED_CLASS.getNavigationHandler(), aMarker.getNavigationHandler());
}