Fix compile errors

This commit is contained in:
Andrew Steinborn
2021-05-14 16:28:16 -04:00
parent ee2870aafb
commit 07f8980f82
4 changed files with 37 additions and 10 deletions

View File

@@ -1,3 +1,20 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.velocitypowered.annotationprocessor;
class AnnotationProcessorConstants {

View File

@@ -88,7 +88,8 @@ public class ApiAnnotationProcessor extends AbstractProcessor {
msg.printMessage(Diagnostic.Kind.ERROR,
"method must not be abstract", method);
}
if (method.getEnclosingElement().getKind().isInterface()) {
Element enclosing = method.getEnclosingElement();
if (enclosing != null && enclosing.getKind().isInterface()) {
msg.printMessage(Diagnostic.Kind.ERROR,
"interfaces cannot declare listeners", method);
}
@@ -97,7 +98,8 @@ public class ApiAnnotationProcessor extends AbstractProcessor {
msg.printMessage(Kind.ERROR, "method must return void or EventTask", method);
}
final List<? extends VariableElement> parameters = method.getParameters();
if (parameters.isEmpty() || !this.isTypeSubclass(parameters.get(0), SUBSCRIBE_ANNOTATION_CLASS)) {
if (parameters.isEmpty()
|| !this.isTypeSubclass(parameters.get(0), SUBSCRIBE_ANNOTATION_CLASS)) {
msg.printMessage(Diagnostic.Kind.ERROR,
"method must have an Event as its first parameter", method);
}
@@ -116,9 +118,9 @@ public class ApiAnnotationProcessor extends AbstractProcessor {
if (Objects.equals(pluginClassFound, qualifiedName.toString())) {
if (!warnedAboutMultiplePlugins) {
processingEnv.getMessager()
.printMessage(Diagnostic.Kind.WARNING, "Velocity does not yet currently support "
+ "multiple plugins. We are using " + pluginClassFound
+ " for your plugin's main class.");
.printMessage(Diagnostic.Kind.WARNING,
"Velocity does not yet currently support multiple plugins. "
+ "We are using " + pluginClassFound + " for your plugin's main class.");
warnedAboutMultiplePlugins = true;
}
return false;
@@ -126,10 +128,10 @@ public class ApiAnnotationProcessor extends AbstractProcessor {
Plugin plugin = element.getAnnotation(Plugin.class);
if (!SerializedPluginDescription.ID_PATTERN.matcher(plugin.id()).matches()) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Invalid ID for plugin "
+ qualifiedName
+ ". IDs must start alphabetically, have alphanumeric characters, and can "
+ "contain dashes or underscores.");
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,
"Invalid ID for plugin " + qualifiedName + ". "
+ "IDs must start alphabetically, have alphanumeric characters, and can "
+ "contain dashes or underscores.");
return false;
}