Java Code Examples for com.intellij.openapi.components.ServiceManager#getService()

The following examples show how to use com.intellij.openapi.components.ServiceManager#getService() . 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: CommitMessage.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a text editor appropriate for creating commit messages.
 *
 * @param project project this commit message editor is intended for
 * @param forceSpellCheckOn if false, {@link com.intellij.openapi.vcs.VcsConfiguration#CHECK_COMMIT_MESSAGE_SPELLING} will control
 *                          whether or not the editor has spell check enabled
 * @return a commit message editor
 */
public static EditorTextField createCommitTextEditor(final Project project, boolean forceSpellCheckOn) {
  Set<EditorCustomization> features = new HashSet<EditorCustomization>();

  final SpellCheckerCustomization spellChecker = SpellCheckerCustomization.getInstance();
  VcsConfiguration configuration = VcsConfiguration.getInstance(project);
  if (configuration != null) {
    boolean enableSpellChecking = forceSpellCheckOn || configuration.CHECK_COMMIT_MESSAGE_SPELLING;
    if(spellChecker.isEnabled()) {
      features.add(spellChecker.getCustomization(enableSpellChecking));
    }
    features.add(new RightMarginEditorCustomization(configuration.USE_COMMIT_MESSAGE_MARGIN, configuration.COMMIT_MESSAGE_MARGIN_SIZE));
    features.add(WrapWhenTypingReachesRightMarginCustomization.getInstance(configuration.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN));
  } else {
    if(spellChecker.isEnabled()) {
      features.add(spellChecker.getCustomization(true));
    }
    features.add(new RightMarginEditorCustomization(false, -1));
  }

  features.add(SoftWrapsEditorCustomization.ENABLED);
  features.add(AdditionalPageAtBottomEditorCustomization.DISABLED);

  EditorTextFieldProvider service = ServiceManager.getService(project, EditorTextFieldProvider.class);
  return service.getEditorField(PlainTextLanguage.INSTANCE, project, features);
}
 
Example 2
Source File: ProjectOpenCloseListener.java    From intellij-sdk-docs with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked on project close.
 *
 * @param project closing project
 */
@Override
public void projectClosed(@NotNull Project project) {
  // Ensure this isn't part of testing
  if (ApplicationManager.getApplication().isUnitTestMode()) return;
  // Get the counting service
  ProjectCountingService projectCountingService = ServiceManager.getService(ProjectCountingService.class);
  // Decrement the count because a project just closed
  projectCountingService.decrProjectCount();
}
 
Example 3
Source File: QueryAction.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 5 votes vote down vote up
private Map<String, Object> getParametersFromQuery(PsiElement query, Project project, Editor editor) {
    try { // support parameters for PsiElement only
        ParametersService service = ServiceManager.getService(project, ParametersService.class);
        return service.getParameters(query);
    } catch (Exception exception) {
        sendParametersRetrievalErrorEvent(project.getMessageBus(), exception, editor);
        return Collections.emptyMap();
    }
}
 
Example 4
Source File: CamelEndpointAnnotator.java    From camel-idea-plugin with Apache License 2.0 4 votes vote down vote up
private static IdeaUtils getIdeaUtils() {
    return ServiceManager.getService(IdeaUtils.class);
}
 
Example 5
Source File: LaravelSettings.java    From Thinkphp5-Plugin with MIT License 4 votes vote down vote up
public static LaravelSettings getInstance(Project project) {
    return ServiceManager.getService(project, LaravelSettings.class);
}
 
Example 6
Source File: BlazeConsoleService.java    From intellij with Apache License 2.0 4 votes vote down vote up
static BlazeConsoleService getInstance(Project project) {
  return ServiceManager.getService(project, BlazeConsoleService.class);
}
 
Example 7
Source File: PackagingElementFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static PackagingElementFactory getInstance(@Nonnull Project project) {
  return ServiceManager.getService(project, PackagingElementFactory.class);
}
 
Example 8
Source File: ExceptionRenderer.java    From GitLink with MIT License 4 votes vote down vote up
public ExceptionRenderer() {
    this.plugin = ServiceManager.getService(Plugin.class);
}
 
Example 9
Source File: CodeFoldingManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static CodeFoldingManager getInstance(Project project) {
  return ServiceManager.getService(project, CodeFoldingManager.class);
}
 
Example 10
Source File: CodeStyleFacade.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static CodeStyleFacade getInstance(@Nullable Project project) {
  if (project == null) return getInstance();
  return ServiceManager.getService(project, ProjectCodeStyleFacade.class);
}
 
Example 11
Source File: RepositoryContextManager.java    From azure-devops-intellij with MIT License 4 votes vote down vote up
public static RepositoryContextManager getInstance() {
    return ServiceManager.getService(RepositoryContextManager.class);
}
 
Example 12
Source File: RincewindProcess.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
public static RincewindProcess getInstance(@NotNull Project project) {
    return ServiceManager.getService(project, RincewindProcess.class);
}
 
Example 13
Source File: FreeUIManager.java    From freeline with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static FreeUIManager getInstance(Project project) {
    return ServiceManager.getService(project, FreeUIManager.class);
}
 
Example 14
Source File: ModuleCompilerPathsManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static ModuleCompilerPathsManager getInstance(@Nonnull Module module) {
  return ServiceManager.getService(module, ModuleCompilerPathsManager.class);
}
 
Example 15
Source File: BrowserLauncher.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static BrowserLauncher getInstance() {
  return ServiceManager.getService(BrowserLauncher.class);
}
 
Example 16
Source File: CamelEndpointAnnotator.java    From camel-idea-plugin with Apache License 2.0 4 votes vote down vote up
private static CamelPreferenceService getCamelPreferenceService() {
    return ServiceManager.getService(CamelPreferenceService.class);
}
 
Example 17
Source File: YamlDocumentationProvider.java    From intellij-spring-assistant with MIT License 4 votes vote down vote up
@Nullable
@Override
public PsiElement getCustomDocumentationElement(@NotNull Editor editor, @NotNull PsiFile file,
    @Nullable PsiElement element) {
  if (element != null) {
    List<SuggestionNode> matchedNodesFromRootTillLeaf;
    boolean requestedForTargetValue = false;

    SuggestionService suggestionService =
        ServiceManager.getService(element.getProject(), SuggestionService.class);

    Project project = element.getProject();
    Module module = findModule(element);

    List<String> ancestralKeys = null;
    PsiElement elementContext = element.getContext();
    PsiElement context = elementContext;
    do {
      if (context instanceof YAMLKeyValue) {
        if (ancestralKeys == null) {
          ancestralKeys = new ArrayList<>();
        }
        ancestralKeys.add(0, truncateIdeaDummyIdentifier(((YAMLKeyValue) context).getKeyText()));
      }
      context = requireNonNull(context).getParent();
    } while (context != null);

    String value = null;
    if (elementContext instanceof YAMLKeyValue) {
      value = truncateIdeaDummyIdentifier(((YAMLKeyValue) elementContext).getKeyText());
      requestedForTargetValue = false;
    } else if (elementContext instanceof YAMLPlainTextImpl) {
      value = truncateIdeaDummyIdentifier(element.getText());
      requestedForTargetValue = true;
    }

    if (ancestralKeys != null) {
      matchedNodesFromRootTillLeaf =
          suggestionService.findMatchedNodesRootTillEnd(project, module, ancestralKeys);
      if (matchedNodesFromRootTillLeaf != null) {
        SuggestionNode target =
            matchedNodesFromRootTillLeaf.get(matchedNodesFromRootTillLeaf.size() - 1);
        String targetNavigationPathDotDelimited =
            matchedNodesFromRootTillLeaf.stream().map(v -> v.getNameForDocumentation(module))
                .collect(joining("."));
        return new DocumentationProxyElement(file.getManager(), file.getLanguage(),
            targetNavigationPathDotDelimited, target, requestedForTargetValue, value);
      }
    }
  }
  return super.getCustomDocumentationElement(editor, file, element);
}
 
Example 18
Source File: DiffRequestFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static DiffRequestFactory getInstance() {
  return ServiceManager.getService(DiffRequestFactory.class);
}
 
Example 19
Source File: RunDashboardManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
static RunDashboardManager getInstance(Project project) {
  return ServiceManager.getService(project, RunDashboardManager.class);
}
 
Example 20
Source File: KeymapGroupFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static KeymapGroupFactory getInstance() {
  return ServiceManager.getService(KeymapGroupFactory.class);
}