• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2023 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.googlejavaformat.intellij;
18 
19 import com.intellij.formatting.service.FormattingNotificationService;
20 import com.intellij.openapi.project.Project;
21 
22 class Notifications {
23 
24   static final String PARSING_ERROR_NOTIFICATION_GROUP = "google-java-format parsing error";
25   static final String PARSING_ERROR_TITLE = PARSING_ERROR_NOTIFICATION_GROUP;
26 
parsingErrorMessage(String filename)27   static String parsingErrorMessage(String filename) {
28     return "google-java-format failed. Does " + filename + " have syntax errors?";
29   }
30 
displayParsingErrorNotification(Project project, String filename)31   static void displayParsingErrorNotification(Project project, String filename) {
32     FormattingNotificationService.getInstance(project)
33         .reportError(
34             Notifications.PARSING_ERROR_NOTIFICATION_GROUP,
35             Notifications.PARSING_ERROR_TITLE,
36             Notifications.parsingErrorMessage(filename));
37   }
38 }
39