Examples of ISourceLocation


Examples of org.eclipse.imp.pdb.facts.ISourceLocation

      IValueFactory vf = eval.getValueFactory();
      prod = ProductionAdapter.setDefined(prod, vf.constructor(Factory.Symbol_Label, vf.string("$parsed"), sym));
      return TreeAdapter.setProduction(TreeAdapter.setArg(tree, "parts", fragment), prod);
    }
    catch (ParseError e) {
      ISourceLocation loc = TreeAdapter.getLocation(tree);
      ISourceLocation src = eval.getValueFactory().sourceLocation(loc.getURI(), loc.getOffset() + e.getOffset(), loc.getLength(), loc.getBeginLine() + e.getBeginLine() - 1, loc.getEndLine() + e.getEndLine() - 1, loc.getBeginColumn() + e.getBeginColumn(), loc.getBeginColumn() + e.getEndColumn());
      eval.getMonitor().warning("parse error in concrete syntax", src);
      return tree.asAnnotatable().setAnnotation("parseError", src);
    }
    catch (StaticError e) {
      ISourceLocation loc = TreeAdapter.getLocation(tree);
      ISourceLocation src = eval.getValueFactory().sourceLocation(loc.getURI(), loc.getOffset(), loc.getLength(), loc.getBeginLine(), loc.getEndLine(), loc.getBeginColumn(), loc.getBeginColumn());
      eval.getMonitor().warning(e.getMessage(), e.getLocation());
      return tree.asAnnotatable().setAnnotation("can not parse fragment due to " + e.getMessage(), src);
    }
    catch (UndeclaredNonTerminalException e) {
      ISourceLocation loc = TreeAdapter.getLocation(tree);
      ISourceLocation src = eval.getValueFactory().sourceLocation(loc.getURI(), loc.getOffset(), loc.getLength(), loc.getBeginLine(), loc.getEndLine(), loc.getBeginColumn(), loc.getBeginColumn());
      eval.getMonitor().warning(e.getMessage(), src);
      return tree.asAnnotatable().setAnnotation("can not parse fragment due to " + e.getMessage(), src);
    }
  }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.ISourceLocation

    if (params.isVarArgs() && formals.size() > 0) {
      // deal with varags, change the last argument to a list if its not a pattern
      Expression last = formals.get(formals.size() - 1);
      if (last.isTypedVariable()) {
        org.rascalmpl.ast.Type oldType = last.getType();
        ISourceLocation origin = last.getLocation();
        Structured newType = ASTBuilder.make("Type","Structured", origin, ASTBuilder.make("StructuredType",origin, ASTBuilder.make("BasicType","List", origin), Arrays.asList(ASTBuilder.make("TypeArg","Default", origin,oldType))));
        last = ASTBuilder.make("Expression","TypedVariable",origin, newType, last.getName());
        formals = replaceLast(formals, last);
      }
      else if (last.isQualifiedName()) {
        ISourceLocation origin = last.getLocation();
        org.rascalmpl.ast.Type newType = ASTBuilder.make("Type","Structured",origin, ASTBuilder.make("StructuredType",origin, ASTBuilder.make("BasicType","List", origin), Arrays.asList(ASTBuilder.make("TypeArg",origin, ASTBuilder.make("Type","Basic", origin, ASTBuilder.make("BasicType","Value", origin))))));
        last = ASTBuilder.makeExp("TypedVariable", origin, newType, Names.lastName(last.getQualifiedName()));
        formals = replaceLast(formals, last);
      }
      else {
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.ISourceLocation

  public static boolean isRascalLexical(IConstructor tree) {
    return SymbolAdapter.isLex(getType(tree));
  }

  public static IConstructor locateDeepestContextFreeNode(IConstructor tree, int offset) {
    ISourceLocation l = TreeAdapter.getLocation(tree);
 
    if (l == null) {
      throw new IllegalArgumentException(
          "locate assumes position information on the tree");
    }
 
    if (TreeAdapter.isLexical(tree)) {
      if (l.getOffset() <= offset
          && offset < l.getOffset() + l.getLength()) {
        return tree;
      }
 
      return null;
    }
 
    if (TreeAdapter.isAmb(tree)) {
      return null;
    }
 
    if (TreeAdapter.isAppl(tree)) {
      IList children = TreeAdapter.getASTArgs(tree);
 
      for (IValue child : children) {
        ISourceLocation childLoc = TreeAdapter
            .getLocation((IConstructor) child);
 
        if (childLoc == null) {
          continue;
        }
 
        if (childLoc.getOffset() <= offset
            && offset < childLoc.getOffset() + childLoc.getLength()) {
          IConstructor result = locateDeepestContextFreeNode((IConstructor) child,
              offset);
 
          if (result != null) {
            return result;
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.