com.intellij.codeHighlighting.Pass Java Examples

The following examples show how to use com.intellij.codeHighlighting.Pass. 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: DefaultHighlightInfoProcessor.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void killAbandonedHighlightsUnder(@Nonnull PsiFile psiFile,
                                                 @Nonnull final TextRange range,
                                                 @Nullable final List<? extends HighlightInfo> infos,
                                                 @Nonnull final HighlightingSession highlightingSession) {
  final Project project = psiFile.getProject();
  final Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
  if (document == null) return;
  DaemonCodeAnalyzerEx.processHighlights(document, project, null, range.getStartOffset(), range.getEndOffset(), existing -> {
    if (existing.isBijective() && existing.getGroup() == Pass.UPDATE_ALL && range.equalsToRange(existing.getActualStartOffset(), existing.getActualEndOffset())) {
      if (infos != null) {
        for (HighlightInfo created : infos) {
          if (existing.equalsByActualOffset(created)) return true;
        }
      }
      // seems that highlight info "existing" is going to disappear
      // remove it earlier
      ((HighlightingSessionImpl)highlightingSession).queueDisposeHighlighterFor(existing);
    }
    return true;
  });
}
 
Example #3
Source File: NavigationGutterIconBuilder.java    From consulo with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: RecursiveCallCollector.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@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);
			}
		}
	}
}
 
Example #5
Source File: UnityEventCSharpMethodLineMarkerProvider.java    From consulo-unity3d with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #6
Source File: FileStatusMap.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void markWholeFileDirty(@Nonnull Project project) {
  setDirtyScope(Pass.UPDATE_ALL, WHOLE_FILE_DIRTY_MARKER);
  setDirtyScope(Pass.EXTERNAL_TOOLS, WHOLE_FILE_DIRTY_MARKER);
  setDirtyScope(Pass.LOCAL_INSPECTIONS, WHOLE_FILE_DIRTY_MARKER);
  setDirtyScope(Pass.LINE_MARKERS, WHOLE_FILE_DIRTY_MARKER);
  TextEditorHighlightingPassManager registrar = TextEditorHighlightingPassManager.getInstance(project);
  for(DirtyScopeTrackingHighlightingPassFactory factory: registrar.getDirtyScopeTrackingFactories()) {
    setDirtyScope(factory.getPassId(), WHOLE_FILE_DIRTY_MARKER);
  }
}
 
Example #7
Source File: CppOverridenHighlightingPassFactory.java    From CppTools with Apache License 2.0 5 votes vote down vote up
protected void register(TextEditorHighlightingPassRegistrar instance) {
  instance.registerTextEditorHighlightingPass(
    this,
    TextEditorHighlightingPassRegistrar.BEFORE,
    Pass.LOCAL_INSPECTIONS
  );
}
 
Example #8
Source File: LineMarkersPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static LineMarkerInfo<PsiElement> createMethodSeparatorLineMarker(@Nonnull PsiElement startFrom, @Nonnull EditorColorsManager colorsManager) {
  LineMarkerInfo<PsiElement> info = new LineMarkerInfo<>(startFrom, startFrom.getTextRange(), null, Pass.LINE_MARKERS, FunctionUtil.<Object, String>nullConstant(), null, GutterIconRenderer.Alignment.RIGHT);
  EditorColorsScheme scheme = colorsManager.getGlobalScheme();
  info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
  info.separatorPlacement = SeparatorPlacement.TOP;
  return info;
}
 
Example #9
Source File: ShowAutoImportPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
ShowAutoImportPass(@Nonnull Project project, @Nonnull final PsiFile file, @Nonnull Editor editor) {
  super(project, editor.getDocument(), false);
  ApplicationManager.getApplication().assertIsDispatchThread();

  myEditor = editor;

  TextRange range = VisibleHighlightingPassFactory.calculateVisibleRange(myEditor);
  myStartOffset = range.getStartOffset();
  myEndOffset = range.getEndOffset();

  myFile = file;

  hasDirtyTextRange = FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL) != null;
}
 
Example #10
Source File: LineMarkersPassFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@Nonnull PsiFile file, @Nonnull final Editor editor) {
  TextRange restrictRange = FileStatusMap.getDirtyTextRange(editor, Pass.LINE_MARKERS);
  Document document = editor.getDocument();
  if (restrictRange == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(file.getProject(), document);
  ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
  return new LineMarkersPass(file.getProject(), file, document, expandRangeToCoverWholeLines(document, visibleRange), expandRangeToCoverWholeLines(document, restrictRange));
}
 
Example #11
Source File: ExternalToolPassFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@Nonnull PsiFile file, @Nonnull final Editor editor) {
  TextRange textRange = FileStatusMap.getDirtyTextRange(editor, Pass.EXTERNAL_TOOLS) == null ? null : file.getTextRange();
  if (textRange == null || !externalAnnotatorsDefined(file)) {
    return null;
  }
  return new ExternalToolPass(this, file, editor, textRange.getStartOffset(), textRange.getEndOffset());
}
 
Example #12
Source File: InjectedGeneralHighlightingPassFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@Nonnull PsiFile file, @Nonnull final Editor editor) {
  Project project = file.getProject();
  TextRange textRange = FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL);
  if (textRange == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(project, editor.getDocument());
  ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
  return new InjectedGeneralHighlightingPass(project, file, editor.getDocument(), textRange.getStartOffset(), textRange.getEndOffset(), true, visibleRange, editor,
                                             new DefaultHighlightInfoProcessor());
}
 
Example #13
Source File: WidgetIndentsHighlightingPassFactory.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public WidgetIndentsHighlightingPassFactory(@NotNull Project project) {
  this.project = project;
  flutterDartAnalysisService = FlutterDartAnalysisServer.getInstance(project);
  this.editorOutlineService = ActiveEditorsOutlineService.getInstance(project);
  this.inspectorGroupManagerService = InspectorGroupManagerService.getInstance(project);
  this.editorEventService = EditorMouseEventService.getInstance(project);
  this.editorPositionService = EditorPositionService.getInstance(project);
  this.settingsListener = new SettingsListener();
  this.outlineListener = this::updateEditor;

  TextEditorHighlightingPassRegistrar.getInstance(project)
    .registerTextEditorHighlightingPass(this, TextEditorHighlightingPassRegistrar.Anchor.AFTER, Pass.UPDATE_FOLDING, false, false);

  syncSettings(FlutterSettings.getInstance());
  FlutterSettings.getInstance().addListener(settingsListener);

  final EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
  eventMulticaster.addCaretListener(new CaretListener() {
    @Override
    public void caretPositionChanged(@NotNull CaretEvent event) {
      final Editor editor = event.getEditor();
      if (editor.getProject() != project) return;
      if (editor.isDisposed() || project.isDisposed()) return;
      if (!(editor instanceof EditorEx)) return;
      final EditorEx editorEx = (EditorEx)editor;
      WidgetIndentsHighlightingPass.onCaretPositionChanged(editorEx, event.getCaret());
    }
  }, this);
  editorOutlineService.addListener(outlineListener);
}
 
Example #14
Source File: FileStatusMap.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void markFileUpToDate(@Nonnull Document document, int passId) {
  synchronized (myDocumentToStatusMap) {
    FileStatus status = myDocumentToStatusMap.computeIfAbsent(document, __ -> new FileStatus(myProject));
    status.defensivelyMarked = false;
    if (passId == Pass.WOLF) {
      status.wolfPassFinished = true;
    }
    else if (status.dirtyScopes.containsKey(passId)) {
      status.setDirtyScope(passId, null);
    }
  }
}
 
Example #15
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 #16
Source File: ExpectedHighlightingData.java    From consulo with Apache License 2.0 5 votes vote down vote up
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();
  }
}
 
Example #17
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 #18
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 #19
Source File: GeneralHighlightingPassFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public TextEditorHighlightingPass createHighlightingPass(@Nonnull PsiFile file, @Nonnull final Editor editor) {
  TextRange textRange = FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL);
  if (textRange == null) return new EmptyPass(file.getProject(), editor.getDocument());
  ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor);
  return new GeneralHighlightingPass(file.getProject(), file, editor.getDocument(), textRange.getStartOffset(), textRange.getEndOffset(), true, visibleRange, editor, new DefaultHighlightInfoProcessor());
}
 
Example #20
Source File: WidgetIndentsHighlightingPassFactory.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public WidgetIndentsHighlightingPassFactory(@NotNull Project project) {
  this.project = project;
  flutterDartAnalysisService = FlutterDartAnalysisServer.getInstance(project);
  this.editorOutlineService = ActiveEditorsOutlineService.getInstance(project);
  this.inspectorGroupManagerService = InspectorGroupManagerService.getInstance(project);
  this.editorEventService = EditorMouseEventService.getInstance(project);
  this.editorPositionService = EditorPositionService.getInstance(project);
  this.settingsListener = new SettingsListener();
  this.outlineListener = this::updateEditor;

  TextEditorHighlightingPassRegistrar.getInstance(project)
    .registerTextEditorHighlightingPass(this, TextEditorHighlightingPassRegistrar.Anchor.AFTER, Pass.UPDATE_FOLDING, false, false);

  syncSettings(FlutterSettings.getInstance());
  FlutterSettings.getInstance().addListener(settingsListener);

  final EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster();
  eventMulticaster.addCaretListener(new CaretListener() {
    @Override
    public void caretPositionChanged(@NotNull CaretEvent event) {
      final Editor editor = event.getEditor();
      if (editor.getProject() != project) return;
      if (editor.isDisposed() || project.isDisposed()) return;
      if (!(editor instanceof EditorEx)) return;
      final EditorEx editorEx = (EditorEx)editor;
      WidgetIndentsHighlightingPass.onCaretPositionChanged(editorEx, event.getCaret());
    }
  }, this);
  editorOutlineService.addListener(outlineListener);
}
 
Example #21
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 #22
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 #23
Source File: UnitySceneCSharpTypeLineMarkerProvider.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #24
Source File: UnityScriptEventFunctionLineMarkerProvider.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #25
Source File: InjectedGeneralHighlightingPassFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void register(@Nonnull Registrar registrar) {
  registrar.registerTextEditorHighlightingPass(this, null, new int[]{Pass.UPDATE_ALL}, false, -1);
}
 
Example #26
Source File: IndentsPassFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void register(@Nonnull Registrar registrar) {
  registrar.registerTextEditorHighlightingPass(this, Registrar.Anchor.BEFORE, Pass.UPDATE_FOLDING, false);
}
 
Example #27
Source File: GeneralHighlightingPassFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void register(@Nonnull Registrar registrar) {
  registrar.registerTextEditorHighlightingPass(this, null, new int[]{Pass.UPDATE_FOLDING}, false, Pass.UPDATE_ALL);
}
 
Example #28
Source File: InjectedCodeFoldingPassFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void register(@Nonnull Registrar registrar) {
  registrar.registerTextEditorHighlightingPass(this, new int[]{Pass.UPDATE_ALL}, null, false, -1);
}
 
Example #29
Source File: ExternalToolPassFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void register(@Nonnull Registrar registrar) {
  registrar.registerTextEditorHighlightingPass(this, new int[]{Pass.UPDATE_ALL}, null, true, Pass.EXTERNAL_TOOLS);
}
 
Example #30
Source File: LineMarkersPassFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void register(@Nonnull Registrar registrar) {
  registrar.registerTextEditorHighlightingPass(this, null, new int[]{Pass.UPDATE_ALL}, false, Pass.LINE_MARKERS);
}