Examples of IMessage


Examples of org.aspectj.bridge.IMessage

            NewConstructorTypeMunger nctm = (NewConstructorTypeMunger) element.getMunger();
            itdMatch = declA.matches(nctm.getSignature(), world);
          }
        }
        if (!itdMatch) {
          IMessage message = null;
          if (isDeclareAtField) {
            message = new Message("The field '" + declA.getSignaturePattern().toString() + "' does not exist",
                declA.getSourceLocation(), true);
          } else {
            message = new Message("The method '" + declA.getSignaturePattern().toString() + "' does not exist",
View Full Code Here

Examples of org.aspectj.bridge.IMessage

  private boolean openOutputStream(File outJar) {
    try {
      OutputStream os = FileUtil.makeOutputStream(buildConfig.getOutputJar());
      zos = new JarOutputStream(os, getWeaver().getManifest(true));
    } catch (IOException ex) {
      IMessage message = new Message("Unable to open outjar " + outJar.getPath() + "(" + ex.getMessage() + ")",
          new SourceLocation(outJar, 0), true);
      handler.handleMessage(message);
      return false;
    }
    return true;
View Full Code Here

Examples of org.aspectj.bridge.IMessage

          buildConfig.getCompilationResultDestinationManager().reportFileRemove(outJar.getPath(),
              CompilationResultDestinationManager.FILETYPE_OUTJAR);
        }
      }
    } catch (IOException ex) {
      IMessage message = new Message("Unable to write outjar " + outJar.getPath() + "(" + ex.getMessage() + ")",
          new SourceLocation(outJar, 0), true);
      handler.handleMessage(message);
    }
  }
View Full Code Here

Examples of org.aspectj.bridge.IMessage

   * @param srcloc the src of the directory entry, for use when creating a warning message
   * @throws IOException if something goes wrong creating the new zip entry
   */
  private void writeDirectory(String directory, File srcloc) throws IOException {
    if (state.hasResource(directory)) {
      IMessage msg = new Message("duplicate resource: '" + directory + "'", IMessage.WARNING, null, new SourceLocation(
          srcloc, 0));
      handler.handleMessage(msg);
      return;
    }
    if (zos != null) {
View Full Code Here

Examples of org.aspectj.bridge.IMessage

    // Nothing to do if not writing to a zip file
  }

  private void writeResource(String filename, byte[] content, File srcLocation) throws IOException {
    if (state.hasResource(filename)) {
      IMessage msg = new Message("duplicate resource: '" + filename + "'", IMessage.WARNING, null, new SourceLocation(
          srcLocation, 0));
      handler.handleMessage(msg);
      return;
    }
    if (filename.equals(buildConfig.getOutxmlName())) {
      ignoreOutxml = true;
      IMessage msg = new Message("-outxml/-outxmlfile option ignored because resource already exists: '" + filename + "'",
          IMessage.WARNING, null, new SourceLocation(srcLocation, 0));
      handler.handleMessage(msg);
    }
    if (zos != null) {
      ZipEntry newEntry = new ZipEntry(filename); // ??? get compression scheme right
      zos.putNextEntry(newEntry);
      zos.write(content);
      zos.closeEntry();
    } else {
      File destDir = buildConfig.getOutputDir();
      if (buildConfig.getCompilationResultDestinationManager() != null) {
        destDir = buildConfig.getCompilationResultDestinationManager().getOutputLocationForResource(srcLocation);
      }
      try {
        File outputLocation = new File(destDir, filename);
        OutputStream fos = FileUtil.makeOutputStream(outputLocation);
        fos.write(content);
        fos.close();
        if (buildConfig.getCompilationResultDestinationManager() != null) {
          buildConfig.getCompilationResultDestinationManager().reportFileWrite(outputLocation.getPath(),
              CompilationResultDestinationManager.FILETYPE_RESOURCE);
        }
      } catch (FileNotFoundException fnfe) {
        IMessage msg = new Message("unable to copy resource to output folder: '" + filename + "' - reason: "
            + fnfe.getMessage(), IMessage.ERROR, null, new SourceLocation(srcLocation, 0));
        handler.handleMessage(msg);
      }
    }
    state.recordResource(filename, srcLocation);
View Full Code Here

Examples of org.aspectj.bridge.IMessage

    }

    for (Iterator i = buildConfig.getAspectpath().iterator(); i.hasNext();) {
      File f = (File) i.next();
      if (!f.exists()) {
        IMessage message = new Message("invalid aspectpath entry: " + f.getName(), null, true);
        handler.handleMessage(message);
      } else {
        bcelWeaver.addLibraryJarFile(f);
      }
    }

    // String lintMode = buildConfig.getLintMode();

    File outputDir = buildConfig.getOutputDir();
    if (outputDir == null && buildConfig.getCompilationResultDestinationManager() != null) {
      // send all output from injars and inpath to the default output location
      // (will also later send the manifest there too)
      outputDir = buildConfig.getCompilationResultDestinationManager().getDefaultOutputLocation();
    }
    // ??? incremental issues
    for (File inJar : buildConfig.getInJars()) {
      List<UnwovenClassFile> unwovenClasses = bcelWeaver.addJarFile(inJar, outputDir, false);
      state.recordBinarySource(inJar.getPath(), unwovenClasses);
    }

    for (File inPathElement : buildConfig.getInpath()) {
      if (!inPathElement.isDirectory()) {
        // its a jar file on the inpath
        // the weaver method can actually handle dirs, but we don't call it, see next block
        List<UnwovenClassFile> unwovenClasses = bcelWeaver.addJarFile(inPathElement, outputDir, true);
        state.recordBinarySource(inPathElement.getPath(), unwovenClasses);
      } else {
        // add each class file in an in-dir individually, this gives us the best error reporting
        // (they are like 'source' files then), and enables a cleaner incremental treatment of
        // class file changes in indirs.
        File[] binSrcs = FileUtil.listFiles(inPathElement, binarySourceFilter);
        for (int j = 0; j < binSrcs.length; j++) {
          UnwovenClassFile ucf = bcelWeaver.addClassFile(binSrcs[j], inPathElement, outputDir);
          List<UnwovenClassFile> ucfl = new ArrayList<UnwovenClassFile>();
          ucfl.add(ucf);
          state.recordBinarySource(binSrcs[j].getPath(), ucfl);
        }
      }
    }

    bcelWeaver.setReweavableMode(buildConfig.isXNotReweavable());

    // check for org.aspectj.runtime.JoinPoint
    ResolvedType joinPoint = bcelWorld.resolve("org.aspectj.lang.JoinPoint");
    if (joinPoint.isMissing()) {
      IMessage message = new Message(
          "classpath error: unable to find org.aspectj.lang.JoinPoint (check that aspectjrt.jar is in your classpath)",
          null, true);
      handler.handleMessage(message);
    }
  }
View Full Code Here

Examples of org.aspectj.bridge.IMessage

              }
              if (shouldAddAspectName && !classname.endsWith("$ajcMightHaveAspect")) {
                addAspectName(classname, unitResult.getFileName());
              }
            } catch (IOException ex) {
              IMessage message = EclipseAdapterUtils.makeErrorMessage(new String(unitResult.fileName),
                  CANT_WRITE_RESULT, ex);
              handler.handleMessage(message);
            }

          }
          state.noteNewResult(unitResult);
          unitResult.compiledTypes.clear(); // free up references to AjClassFile instances
        }

        if (unitResult.hasProblems() || unitResult.hasTasks()) {
          IProblem[] problems = unitResult.getAllProblems();
          for (int i = 0; i < problems.length; i++) {
            IMessage message = EclipseAdapterUtils.makeMessage(unitResult.compilationUnit, problems[i], getBcelWorld(),
                progressListener);
            handler.handleMessage(message);
          }
        }

      }

      private String writeDirectoryEntry(CompilationResult unitResult, ClassFile classFile, String filename)
          throws IOException {
        File destinationPath = buildConfig.getOutputDir();
        if (buildConfig.getCompilationResultDestinationManager() != null) {
          destinationPath = buildConfig.getCompilationResultDestinationManager().getOutputLocationForClass(
              new File(new String(unitResult.fileName)));
        }
        String outFile;
        if (destinationPath == null) {
          outFile = new File(filename).getName();
          outFile = new File(extractDestinationPathFromSourceFile(unitResult), outFile).getPath();
        } else {
          outFile = new File(destinationPath, filename).getPath();
        }

        try {
          BufferedOutputStream os = FileUtil.makeOutputStream(new File(outFile));
          os.write(classFile.getBytes());
          os.close();
        } catch (FileNotFoundException fnfe) {
          IMessage msg = new Message("unable to write out class file: '" + filename + "' - reason: " + fnfe.getMessage(),
              IMessage.ERROR, null, new SourceLocation(new File(outFile), 0));
          handler.handleMessage(msg);
        }

        if (buildConfig.getCompilationResultDestinationManager() != null) {
View Full Code Here

Examples of org.aspectj.bridge.IMessage

    forCompiler.lookupEnvironment = le;

    forCompiler.parser = new Parser(pr, forCompiler.options.parseLiteralExpressionsAsConstants);
    if (getBcelWorld().shouldPipelineCompilation()) {
      IMessage message = MessageUtil.info("Pipelining compilation");
      handler.handleMessage(message);
      return new AjPipeliningCompilerAdapter(forCompiler, batchCompile, getBcelWorld(), getWeaver(), factory,
          getInterimResultRequestor(), progressListener,
          this, // IOutputFilenameProvider
          this, // IBinarySourceProvider
View Full Code Here

Examples of org.aspectj.bridge.IMessage

    } catch (InvalidInputException iie) {
      ISourceLocation location = null;
      if (buildConfig.getConfigFile() != null) {
        location = new SourceLocation(buildConfig.getConfigFile(), 0);
      }
      IMessage m = new Message(iie.getMessage(), IMessage.ERROR, null, location);
      handler.handleMessage(m);
    }
    return buildConfig;
  }
View Full Code Here

Examples of org.aspectj.bridge.IMessage

          ResolvedType t = resolvedMember.getReturnType().resolve(scope.getWorld());
          if (t.isEnum()) {
            // value must be an enum reference X.Y
            int pos = v.lastIndexOf(".");
            if (pos == -1) {
              IMessage m = MessageUtil.error(WeaverMessages
                  .format(WeaverMessages.INVALID_ANNOTATION_VALUE, v, "enum"), getSourceLocation());
              scope.getWorld().getMessageHandler().handleMessage(m);
            } else {
              String typename = v.substring(0, pos);
              ResolvedType rt = scope.lookupType(typename, this).resolve(scope.getWorld());
              v = rt.getSignature() + v.substring(pos + 1); // from 'Color.RED' to 'Lp/Color;RED'
              annotationValues.put(k, v);
            }
          } else if (t.isPrimitiveType()) {
            if (t.getSignature() == "I") {
              try {
                int value = Integer.parseInt(v);
                annotationValues.put(k, Integer.toString(value));
              } catch (NumberFormatException nfe) {
                IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v,
                    "int"), getSourceLocation());
                scope.getWorld().getMessageHandler().handleMessage(m);
              }
            } else if (t.getSignature() == "F") {
              try {
                float value = Float.parseFloat(v);
                annotationValues.put(k, Float.toString(value));
              } catch (NumberFormatException nfe) {
                IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v,
                    "float"), getSourceLocation());
                scope.getWorld().getMessageHandler().handleMessage(m);
              }

            } else if (t.getSignature() == "Z") {
              if (v.equalsIgnoreCase("true") || v.equalsIgnoreCase("false")) {
                // is it ok !
              } else {
                IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v,
                    "boolean"), getSourceLocation());
                scope.getWorld().getMessageHandler().handleMessage(m);
              }
            } else if (t.getSignature() == "S") {
              try {
                short value = Short.parseShort(v);
                annotationValues.put(k, Short.toString(value));
              } catch (NumberFormatException nfe) {
                IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v,
                    "short"), getSourceLocation());
                scope.getWorld().getMessageHandler().handleMessage(m);
              }
            } else if (t.getSignature() == "J") {
              try {
                long value = Long.parseLong(v);
                annotationValues.put(k, Long.toString(value));
              } catch (NumberFormatException nfe) {
                IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v,
                    "long"), getSourceLocation());
                scope.getWorld().getMessageHandler().handleMessage(m);
              }
            } else if (t.getSignature() == "D") {
              try {
                double value = Double.parseDouble(v);
                annotationValues.put(k, Double.toString(value));
              } catch (NumberFormatException nfe) {
                IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v,
                    "double"), getSourceLocation());
                scope.getWorld().getMessageHandler().handleMessage(m);
              }
            } else if (t.getSignature() == "B") {
              try {
                byte value = Byte.parseByte(v);
                annotationValues.put(k, Byte.toString(value));
              } catch (NumberFormatException nfe) {
                IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v,
                    "byte"), getSourceLocation());
                scope.getWorld().getMessageHandler().handleMessage(m);
              }
            } else if (t.getSignature() == "C") {
              if (v.length() != 3) { // '?'
                IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.INVALID_ANNOTATION_VALUE, v,
                    "char"), getSourceLocation());
                scope.getWorld().getMessageHandler().handleMessage(m);
              } else {
                annotationValues.put(k, v.substring(1, 2));
              }
            } else {
              throw new RuntimeException("Not implemented for " + t);
            }
          } else if (t.equals(ResolvedType.JL_STRING)) {
            // nothing to do, it will be OK
          } else {
            throw new RuntimeException("Compiler limitation: annotation value support not implemented for type " + t);
          }
        }
      }
      if (!validKey) {
        IMessage m = MessageUtil.error(WeaverMessages.format(WeaverMessages.UNKNOWN_ANNOTATION_VALUE, annotationType, k),
            getSourceLocation());
        scope.getWorld().getMessageHandler().handleMessage(m);
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.