Package dk.brics.misc

Examples of dk.brics.misc.Origin


        }
        return a;
    }

    private Origin getOrigin() { // TODO: improve origin tracking (messed up by wrapAndConvertGaps)
        Origin origin = null;
        if (base != null) {
            int line = base.getLine();
            int col = base.getColumn();
            if (locator.getLineNumber() == 1) {
                col += locator.getColumnNumber();
            } else {
                line += locator.getLineNumber();
                col = locator.getColumnNumber();
            }
            origin = new Origin(base.getFile(), line, col);
        }
        return origin;
    }
View Full Code Here


        }
    }

    @Override
    public void startElement(String uri, String localname, String name, Attributes attrs) {
        Origin origin = getOrigin();
        Node n;
        if (uri.equals(XMLParser.XACT_NAMESPACE)) {
            if (localname.equals("tgap")) {
                n = new TemplateGap(attrs.getValue("", "gap"), attrs.getValue("", "type"), origin);
            } else { // agap
View Full Code Here

                      }
                      g2.setXMLGraph(xg);
                          XMLGraphBuilder b = buildXMLGraphs(g2);    
                          analyzeXMLGraphs(g2, b);
                  } catch (XMLException e) {
                      Origin or = e.getOrigin();
                      errors.error(or, ErrorType.OTHER, e.getMessage());
                      System.out.println("Error: " + e.getMessage() +
                              ((or!=null ? " at " + or.getFile() + " line " + or.getLine() +
                                      (or.getColumn()>0 ? " column " + or.getColumn() : ""): "")));
                  } catch (Throwable t) {
                      errors.error(t);
                  }
              }
          });
        index++;
      }
      tasks.runTasks();
    } catch (XMLAnalysisException e) {
      Origin or = e.getOrigin();
      errors.error(or, ErrorType.OTHER, e.getMessage());
      System.out.println("Error: " + e.getMessage() +
          ((or!=null ? " at " + or.getFile() + " line " + or.getLine() +
              (or.getColumn()>0 ? " column " + or.getColumn() : ""): "")));
    }
  }
View Full Code Here

   
    final Stack<XMLValidationException> errors = new Stack<XMLValidationException>();
   
    public boolean error(ElementNode n, Origin origin, String msg, String example, Origin schema) {
      StringBuilder b = new StringBuilder(msg);
      Origin or;
      if (n != null) {
        String name = n.getName().getShortestExample(true);
        int i1 = name.indexOf('@');
        name = (i1 < 0) ? name : name.substring(0, i1);
        int i2 = name.indexOf('%');
View Full Code Here

            try {
                InputStream in = base.getResourceAsStream(name);
                if (in == null) {
                    throw new XMLTemplateException("Resource not found: " + name + " from " + base.toString());
                }
                x = XMLParser.parse(in, "UTF-8", true, null, new Origin(name, 0, 0));
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            } catch (IOException e) {
                throw new XMLException(e);
            }
View Full Code Here

                Node base = g.getTypemap().get(schemaName);
               
                // add datatypes on-the-fly when needed
                if (base == null) {
                    if (XMLSchemaDatatypes.isDatatype(schemaName)) {
                        base = new TextNode(XMLSchemaDatatypes.getDatatype(schemaName, origin), new Origin("", -1, -1));
                        xg.addNode(base);
                        g.getTypemap().put(schemaName, base);
                    }
                }
               
View Full Code Here

  public boolean hasOrigin() {
      return origin != null;
  }
  public Origin getOrigin() {
      if (origin == null)
          return new Origin("?", -1, -1);
    return origin;
  }
View Full Code Here

                Node base = g.getTypemap().get(schemaName);
               
                // add datatypes on-the-fly when needed
                if (base == null) {
                    if (XMLSchemaDatatypes.isDatatype(schemaName)) {
                        base = new TextNode(XMLSchemaDatatypes.getDatatype(schemaName, origin), new Origin("", -1, -1));
                        xg.addNode(base);
                        g.getTypemap().put(schemaName, base);
                    }
                }
               
View Full Code Here

    TranslatorContext context = new TranslatorContext(graph, errors);
    Translator translator = new Translator(context, config);
    // create methods and parse field annotations
    for (SootClass c : Scene.v().getApplicationClasses()) {
      for (SootMethod m : c.getMethods()) {
        Origin origin = new Origin(c.getName() + "." + m.getName(), 0, 0);
        Statement methodentry, methodexit;
        Variable returnVar;
        Variable[] parameters = new Variable[m.getParameterCount()];
        if (m.isConcrete()) {
          // entry
          methodentry = new NopStm(origin, "method entry");
          graph.addNode(methodentry);
          // exit
          methodexit = new NopStm(origin, "method exit");
          graph.addNode(methodexit);
          // parameters
          for (int i=0; i<m.getParameterCount(); i++) {
            parameters[i] = new Variable(context.getNextVarID(), false);
          }
          // return var
          returnVar = new Variable(context.getNextVarID(), false);
          // externally callable
          if (config.isExternallyCallable(m)) {
            graph.addEntry(methodentry);
          }
        } else {
          // non-concrete method. it must still be created for annotations to
          // be visible.
          methodentry = methodexit = null;
          returnVar = null;
        }
        // parse annotations
        SchemaType returnType;
        if (context.isAnnotatableType(m.getReturnType())) {
          returnType = context.parseSchemaType(config.getMethodReturnType(m, context.getTypeAnnotation(m)), origin);
        } else {
          returnType = null;
        }
        SchemaType[] paramTypes = new SchemaType[m.getParameterCount()];
        for (int i=0; i<m.getParameterCount(); i++) {
          if (context.isAnnotatableType(m.getParameterType(i))) {
            paramTypes[i] = context.parseSchemaType(config.getMethodParameterType(m, i, context.getTypeAnnotationForParameter(m, i)), origin);
          }
        }
        // make the method
        Method method = new Method(m.getName(), methodentry, methodexit, parameters, returnVar, returnType, paramTypes);
        context.setMethod(m, method);
      }
      for (SootField f : c.getFields()) {
        // parse annotations
        if (context.isAnnotatableType(f.getType())) {
          Origin origin = new Origin(c.getName() + "." + f.getName(), 0, 0);
          context.setFieldSchemaType(f, context.parseSchemaType(config.getFieldType(f, context.getTypeAnnotation(f)), origin));
        }
      }
    }
    // translate!
View Full Code Here

                  && js1.getDefBoxes().size() == 1 && js1.getDefBoxes().get(0) instanceof AbstractValueBox
                  && js2.getInvokeExpr() instanceof JInterfaceInvokeExpr) {
                Value v = ((AbstractValueBox) js1.getDefBoxes().get(0)).getValue();
                JInterfaceInvokeExpr put = (JInterfaceInvokeExpr) js2.getInvokeExpr();
                if (put.getBase().equivTo(v)) {
                  Origin origin = new Origin(m.getDeclaringClass().getName() + "." + m.getName(), getLineNumber(u), 0);
                  String prefix = getConstantString(put.getArg(0), origin);
                  String uri = getConstantString(put.getArg(1), origin);
                  String oldUri = namespaces.put(prefix, uri);
                  if (oldUri != null && !uri.equals(oldUri)) {
                      throw new XMLException("Conflicting namespace bindings of prefix " + prefix + " at " + origin, origin);
View Full Code Here

TOP

Related Classes of dk.brics.misc.Origin

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.