类com.intellij.psi.impl.source.tree.java.PsiJavaTokenImpl源码实例Demo

下面列出了怎么用com.intellij.psi.impl.source.tree.java.PsiJavaTokenImpl的API类实例代码及写法,或者点击链接到github查看源代码。

@Override
protected void collectNavigationMarkers( @NotNull PsiElement element,
                                         @NotNull Collection< ? super RelatedItemLineMarkerInfo > result ) {
  // This must be an element with a literal expression as a parent
  if ( !(element instanceof PsiJavaTokenImpl) || !(element.getParent() instanceof PsiLiteralExpression) ) return;
  
  // The literal expression must start with the Simple language literal expression
  PsiLiteralExpression literalExpression = (PsiLiteralExpression) element.getParent();
  String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
  if ( ( value == null ) || !value.startsWith( SimpleAnnotator.SIMPLE_PREFIX_STR + SimpleAnnotator.SIMPLE_SEPARATOR_STR ) ) return;

  // Get the Simple language property usage
  Project project = element.getProject();
  String possibleProperties = value.substring( SimpleAnnotator.SIMPLE_PREFIX_STR.length()+ SimpleAnnotator.SIMPLE_SEPARATOR_STR.length() );
  final List<SimpleProperty> properties = SimpleUtil.findProperties( project, possibleProperties );
  if ( properties.size() > 0 ) {
    // Add the property to a collection of line marker info
    NavigationGutterIconBuilder< PsiElement > builder =
          NavigationGutterIconBuilder.create( SimpleIcons.FILE )
                                     .setTargets( properties )
                                     .setTooltipText( "Navigate to Simple language property" );
    result.add( builder.createLineMarkerInfo( element ) );
  }
}
 
 类所在包
 同包方法