< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.options.processor/src/org/graalvm/compiler/options/processor/OptionProcessor.java

Print this page




 157         PackageElement enclosingPackage = null;
 158         while (enclosing != null) {
 159             if (enclosing.getKind() == ElementKind.CLASS || enclosing.getKind() == ElementKind.INTERFACE || enclosing.getKind() == ElementKind.ENUM) {
 160                 if (enclosing.getModifiers().contains(Modifier.PRIVATE)) {
 161                     String msg = String.format("Option field cannot be declared in a private %s %s", enclosing.getKind().name().toLowerCase(), enclosing);
 162                     processingEnv.getMessager().printMessage(Kind.ERROR, msg, element);
 163                     return;
 164                 }
 165                 originatingElementsList.add(enclosing);
 166                 declaringClass = enclosing.getSimpleName() + separator + declaringClass;
 167                 separator = ".";
 168             } else if (enclosing.getKind() == ElementKind.PACKAGE) {
 169                 enclosingPackage = (PackageElement) enclosing;
 170                 break;
 171             } else {
 172                 processingEnv.getMessager().printMessage(Kind.ERROR, "Unexpected enclosing element kind: " + enclosing.getKind(), element);
 173                 return;
 174             }
 175             enclosing = enclosing.getEnclosingElement();
 176         }
 177         if (enclosingPackage == null) {
 178             processingEnv.getMessager().printMessage(Kind.ERROR, "Option field cannot be declared in the unnamed package", element);
 179             return;
 180         }
 181         List<String> helpValue = getAnnotationValueList(annotation, "help", String.class);
 182         String help = "";
 183         List<String> extraHelp = new ArrayList<>();
 184 
 185         if (helpValue.size() == 1) {
 186             help = helpValue.get(0);
 187             if (help.startsWith("file:")) {
 188                 String path = help.substring("file:".length());
 189                 Filer filer = processingEnv.getFiler();
 190                 try {
 191                     FileObject file;
 192                     try {
 193                         file = filer.getResource(StandardLocation.SOURCE_PATH, enclosingPackage.getQualifiedName(), path);
 194                     } catch (IllegalArgumentException | IOException e) {
 195                         // Handle the case when a compiler doesn't support the SOURCE_PATH location
 196                         file = filer.getResource(StandardLocation.CLASS_OUTPUT, enclosingPackage.getQualifiedName(), path);
 197                     }




 157         PackageElement enclosingPackage = null;
 158         while (enclosing != null) {
 159             if (enclosing.getKind() == ElementKind.CLASS || enclosing.getKind() == ElementKind.INTERFACE || enclosing.getKind() == ElementKind.ENUM) {
 160                 if (enclosing.getModifiers().contains(Modifier.PRIVATE)) {
 161                     String msg = String.format("Option field cannot be declared in a private %s %s", enclosing.getKind().name().toLowerCase(), enclosing);
 162                     processingEnv.getMessager().printMessage(Kind.ERROR, msg, element);
 163                     return;
 164                 }
 165                 originatingElementsList.add(enclosing);
 166                 declaringClass = enclosing.getSimpleName() + separator + declaringClass;
 167                 separator = ".";
 168             } else if (enclosing.getKind() == ElementKind.PACKAGE) {
 169                 enclosingPackage = (PackageElement) enclosing;
 170                 break;
 171             } else {
 172                 processingEnv.getMessager().printMessage(Kind.ERROR, "Unexpected enclosing element kind: " + enclosing.getKind(), element);
 173                 return;
 174             }
 175             enclosing = enclosing.getEnclosingElement();
 176         }
 177         if (enclosingPackage == null || enclosingPackage.isUnnamed()) {
 178             processingEnv.getMessager().printMessage(Kind.ERROR, "Option field cannot be declared in the unnamed package", element);
 179             return;
 180         }
 181         List<String> helpValue = getAnnotationValueList(annotation, "help", String.class);
 182         String help = "";
 183         List<String> extraHelp = new ArrayList<>();
 184 
 185         if (helpValue.size() == 1) {
 186             help = helpValue.get(0);
 187             if (help.startsWith("file:")) {
 188                 String path = help.substring("file:".length());
 189                 Filer filer = processingEnv.getFiler();
 190                 try {
 191                     FileObject file;
 192                     try {
 193                         file = filer.getResource(StandardLocation.SOURCE_PATH, enclosingPackage.getQualifiedName(), path);
 194                     } catch (IllegalArgumentException | IOException e) {
 195                         // Handle the case when a compiler doesn't support the SOURCE_PATH location
 196                         file = filer.getResource(StandardLocation.CLASS_OUTPUT, enclosingPackage.getQualifiedName(), path);
 197                     }


< prev index next >