Package org.aspectj.bridge

Examples of org.aspectj.bridge.IMessage


    return msg;
  }

  public static IMessage makeErrorMessage(ICompilationUnit unit, String text, Exception ex) {
    ISourceLocation loc = new SourceLocation(new File(new String(unit.getFileName())), 0, 0, 0, "");
    IMessage msg = new Message(text, IMessage.ERROR, ex, loc);
    return msg;
  }
View Full Code Here


    return msg;
  }

  public static IMessage makeErrorMessage(String srcFile, String text, Exception ex) {
    ISourceLocation loc = new SourceLocation(new File(srcFile), 0, 0, 0, "");
    IMessage msg = new Message(text, IMessage.ERROR, ex, loc);
    return msg;
  }
View Full Code Here

          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 if (t.equals(ResolvedType.JL_CLASS)) {
            String typename = v.substring(0, v.lastIndexOf('.')); // strip off '.class'
            ResolvedType rt = scope.lookupType(typename, this).resolve(scope.getWorld());
            if (rt.isMissing()) {
              IMessage m = MessageUtil.error("Unable to resolve type '" + v + "' specified for value '" + k + "'",
                  getSourceLocation());
              scope.getWorld().getMessageHandler().handleMessage(m);
            }
            annotationValues.put(k, rt.getSignature());
          } 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);
      } else {
        break;
      }
View Full Code Here

    this.typePattern = typePattern.resolveBindings(scope, bindings, false, false);
    resolved = true;
    if (typePattern instanceof ExactTypePattern) {
      ExactTypePattern et = (ExactTypePattern) typePattern;
      if (!et.getExactType().resolve(scope.getWorld()).isAnnotation()) {
        IMessage m = MessageUtil.error(
            WeaverMessages.format(WeaverMessages.REFERENCE_TO_NON_ANNOTATION_TYPE, et.getExactType().getName()),
            getSourceLocation());
        scope.getWorld().getMessageHandler().handleMessage(m);
        resolved = false;
      }
View Full Code Here

            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

    return bcelWeavingSupport;
  }

  @Override
  public void reportCheckerMatch(Checker checker, Shadow shadow) {
    IMessage iMessage = new Message(checker.getMessage(shadow), shadow.toString(), checker.isError() ? IMessage.ERROR
        : IMessage.WARNING, shadow.getSourceLocation(), null, new ISourceLocation[] { checker.getSourceLocation() }, true,
        0, -1, -1);

    getMessageHandler().handleMessage(iMessage);
View Full Code Here

    }
    return true;
  }

  public void error(BcelClassWeaver weaver, String text, ISourceLocation primaryLoc, ISourceLocation[] extraLocs) {
    IMessage msg = new Message(text, primaryLoc, true, extraLocs);
    weaver.getWorld().getMessageHandler().handleMessage(msg);
  }
View Full Code Here

          }
        }
        if (!isOK) {
          // the class does not implement this method, they needed to
          // supply a default impl class
          IMessage msg = new Message("@DeclareParents: No defaultImpl was specified but the type '" + gen.getName()
              + "' does not implement the method '" + stringifyMember(introduced) + "' defined on the interface '"
              + introduced.getDeclaringType() + "'", weaver.getLazyClassGen().getType().getSourceLocation(), true,
              new ISourceLocation[] { munger.getSourceLocation() });
          weaver.getWorld().getMessageHandler().handleMessage(msg);
          return false;
View Full Code Here

      }
    }
  }

  private void signalError(String msgid, BcelClassWeaver weaver, UnresolvedType onType) {
    IMessage msg = MessageUtil.error(WeaverMessages.format(msgid, onType.getName()), getSourceLocation());
    weaver.getWorld().getMessageHandler().handleMessage(msg);
  }
View Full Code Here

  // IMessage msg = MessageUtil.warn(msgString, getSourceLocation());
  // weaver.getWorld().getMessageHandler().handleMessage(msg);
  // }

  private void signalError(String msgString, BcelClassWeaver weaver) {
    IMessage msg = MessageUtil.error(msgString, getSourceLocation());
    weaver.getWorld().getMessageHandler().handleMessage(msg);
  }
View Full Code Here

TOP

Related Classes of org.aspectj.bridge.IMessage

Copyright © 2018 www.massapicom. 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.