Java Code Examples for com.intellij.codeHighlighting.Pass#UPDATE_ALL

The following examples show how to use com.intellij.codeHighlighting.Pass#UPDATE_ALL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ANTLRv4LineMarkerProvider.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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;
}
 
Example 2
Source File: GraphQLIntrospectEndpointUrlLineMarkerProvider.java    From js-graphql-intellij-plugin with MIT License 5 votes vote down vote up
@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;
}
 
Example 3
Source File: BashLineMarkerProvider.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 4
Source File: GLSLLineMarkerProvider.java    From glsl4idea with GNU Lesser General Public License v3.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: HaxeLineMarkerProvider.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Nullable
private static LineMarkerInfo createImplementationMarker(final HaxeClass componentWithDeclarationList,
                                                         final List<HaxeClass> items) {
  final HaxeComponentName componentName = componentWithDeclarationList.getComponentName();
  if (componentName == null) {
    return null;
  }
  final PsiElement element = componentName.getIdentifier().getFirstChild();
  return new LineMarkerInfo<>(
    element,
    element.getTextRange(),
    componentWithDeclarationList instanceof HaxeInterfaceDeclaration
    ? AllIcons.Gutter.ImplementedMethod
    : AllIcons.Gutter.OverridenMethod,
    Pass.UPDATE_ALL,
    item -> DaemonBundle.message("method.is.implemented.too.many"),
    new GutterIconNavigationHandler<PsiElement>() {
      @Override
      public void navigate(MouseEvent e, PsiElement elt) {
        PsiElementListNavigator.openTargets(
          e, HaxeResolveUtil.getComponentNames(items).toArray(new NavigatablePsiElement[items.size()]),
          DaemonBundle.message("navigation.title.subclass", componentWithDeclarationList.getName(), items.size()),
          "Subclasses of " + componentWithDeclarationList.getName(),
          new DefaultPsiElementCellRenderer()
        );
      }
    },
    GutterIconRenderer.Alignment.RIGHT
  );
}
 
Example 6
Source File: ThriftLineMarkerProvider.java    From intellij-thrift with Apache License 2.0 5 votes vote down vote up
@Nullable
private LineMarkerInfo findImplementationsAndCreateMarker(final ThriftDefinitionName definitionName) {
  final List<NavigatablePsiElement> implementations = ThriftPsiUtil.findImplementations(definitionName);
  if (implementations.isEmpty()) {
    return null;
  }
  return new LineMarkerInfo<PsiElement>(
    definitionName,
    definitionName.getTextRange(),
    AllIcons.Gutter.ImplementedMethod,
    Pass.UPDATE_ALL,
    new Function<PsiElement, String>() {
      @Override
      public String fun(PsiElement element) {
        return DaemonBundle.message("interface.is.implemented.too.many");
      }
    },
    new GutterIconNavigationHandler<PsiElement>() {
      @Override
      public void navigate(MouseEvent e, PsiElement elt) {
        PsiElementListNavigator.openTargets(
          e,
          implementations.toArray(new NavigatablePsiElement[implementations.size()]),
          DaemonBundle.message("navigation.title.implementation.method", definitionName.getText(), implementations.size()),
          "Implementations of " + definitionName.getText(),
          new DefaultPsiElementCellRenderer()
        );
      }
    },
    GutterIconRenderer.Alignment.RIGHT
  );
}
 
Example 7
Source File: UsageCountLineProvider.java    From Android-Resource-Usage-Count with MIT License 4 votes vote down vote up
public MyLineMarkerInfo(PsiElement element, int count) {
    super(element, element.getTextRange(), new MyIcon(count), Pass.UPDATE_ALL, null, null, GutterIconRenderer.Alignment.RIGHT);
    separatorPlacement = SeparatorPlacement.BOTTOM;
}
 
Example 8
Source File: UsageCountLineProvider.java    From Android-Resource-Usage-Count with MIT License 4 votes vote down vote up
public MyLineMarkerInfo(PsiElement element, int count) {
    super(element, element.getTextRange(), new MyIcon(count), Pass.UPDATE_ALL, null, null, GutterIconRenderer.Alignment.RIGHT);
    separatorPlacement = SeparatorPlacement.BOTTOM;
}
 
Example 9
Source File: LambdaLineMarkerCollector.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
@Override
public void collect(PsiElement psiElement, @Nonnull Consumer<LineMarkerInfo> lineMarkerInfos)
{
	IElementType elementType = PsiUtilCore.getElementType(psiElement);
	if(elementType == CSharpTokens.DARROW)
	{
		PsiElement parent = psiElement.getParent();
		if(!(parent instanceof CSharpLambdaExpressionImpl))
		{
			return;
		}

		MarkerInfo markerInfo = new MarkerInfo(parent, psiElement.getTextRange(), AllIcons.Gutter.ImplementingFunctional, Pass.UPDATE_ALL, new ConstantFunction<>("Navigate to lambda delegate"),
				new GutterIconNavigationHandler<PsiElement>()
		{
			@Override
			@RequiredUIAccess
			public void navigate(MouseEvent e, PsiElement elt)
			{
				if(!(elt instanceof CSharpLambdaExpressionImpl))
				{
					return;
				}
				CSharpLambdaResolveResult lambdaResolveResult = CSharpLambdaExpressionImplUtil.resolveLeftLambdaTypeRef(elt);
				if(lambdaResolveResult == null)
				{
					return;
				}

				PsiElement element = lambdaResolveResult.getElement();
				if(element instanceof Navigatable)
				{
					((Navigatable) element).navigate(true);
				}
			}
		}, GutterIconRenderer.Alignment.RIGHT);
		NavigateAction.setNavigateAction(markerInfo, "Navigate to lambda delegate", IdeActions.ACTION_GOTO_SUPER);
		lineMarkerInfos.consume(markerInfo);
	}
}
 
Example 10
Source File: CSharpLineMarkerProvider.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@RequiredReadAction
@Nullable
@Override
public LineMarkerInfo getLineMarkerInfo(@Nonnull PsiElement element)
{
	if(myDaemonCodeAnalyzerSettings.SHOW_METHOD_SEPARATORS && (element instanceof DotNetQualifiedElement))
	{
		if(element.getNode().getTreeParent() == null)
		{
			return null;
		}

		final PsiElement parent = element.getParent();
		if(!(parent instanceof DotNetMemberOwner))
		{
			return null;
		}

		if(ArrayUtil.getFirstElement(((DotNetMemberOwner) parent).getMembers()) == element)
		{
			return null;
		}

		LineMarkerInfo info = new LineMarkerInfo<PsiElement>(element, element.getTextRange(), null, Pass.UPDATE_ALL, FunctionUtil.<Object, String>nullConstant(), null,
				GutterIconRenderer.Alignment.RIGHT);
		EditorColorsScheme scheme = myEditorColorsManager.getGlobalScheme();
		info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
		info.separatorPlacement = SeparatorPlacement.TOP;
		return info;
	}

	final Ref<LineMarkerInfo> ref = Ref.create();
	Consumer<LineMarkerInfo> consumer = new Consumer<LineMarkerInfo>()
	{
		@Override
		public void consume(LineMarkerInfo markerInfo)
		{
			ref.set(markerInfo);
		}
	};

	//noinspection ForLoopReplaceableByForEach
	for(int j = 0; j < ourSingleCollector.length; j++)
	{
		LineMarkerCollector ourCollector = ourSingleCollector[j];
		ourCollector.collect(element, consumer);
	}

	return ref.get();
}