/******************************************************************************* * Copyright (c) 2009-2015 CWI * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI * * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl * * Paul Klint - Paul.Klint@cwi.nl - CWI * * Mark Hills - Mark.Hills@cwi.nl (CWI) * * Arnold Lankamp - Arnold.Lankamp@cwi.nl * * Michael Steindorfer - Michael.Steindorfer@cwi.nl - CWI *******************************************************************************/ package org.rascalmpl.ast; import org.rascalmpl.value.IConstructor; import org.rascalmpl.value.ISourceLocation; public abstract class PathPart extends AbstractAST { public PathPart(ISourceLocation src, IConstructor node) { super(src /* we forget node on purpose */); } public boolean hasExpression() { return false; } public org.rascalmpl.ast.Expression getExpression() { throw new UnsupportedOperationException(); } public boolean hasPathChars() { return false; } public org.rascalmpl.ast.PathChars getPathChars() { throw new UnsupportedOperationException(); } public boolean hasTail() { return false; } public org.rascalmpl.ast.PathTail getTail() { throw new UnsupportedOperationException(); } public boolean hasPre() { return false; } public org.rascalmpl.ast.PrePathChars getPre() { throw new UnsupportedOperationException(); } public boolean isInterpolated() { return false; } static public class Interpolated extends PathPart { // Production: sig("Interpolated",[arg("org.rascalmpl.ast.PrePathChars","pre"),arg("org.rascalmpl.ast.Expression","expression"),arg("org.rascalmpl.ast.PathTail","tail")],breakable=false) private final org.rascalmpl.ast.PrePathChars pre; private final org.rascalmpl.ast.Expression expression; private final org.rascalmpl.ast.PathTail tail; public Interpolated(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PrePathChars pre, org.rascalmpl.ast.Expression expression, org.rascalmpl.ast.PathTail tail) { super(src, node); this.pre = pre; this.expression = expression; this.tail = tail; } @Override public boolean isInterpolated() { return true; } @Override public <T> T accept(IASTVisitor<T> visitor) { return visitor.visitPathPartInterpolated(this); } @Override protected void addForLineNumber(int $line, java.util.List<AbstractAST> $result) { if (getLocation().getBeginLine() == $line) { $result.add(this); } ISourceLocation $l; $l = pre.getLocation(); if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { pre.addForLineNumber($line, $result); } if ($l.getBeginLine() > $line) { return; } $l = expression.getLocation(); if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { expression.addForLineNumber($line, $result); } if ($l.getBeginLine() > $line) { return; } $l = tail.getLocation(); if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { tail.addForLineNumber($line, $result); } if ($l.getBeginLine() > $line) { return; } } @Override public boolean equals(Object o) { if (!(o instanceof Interpolated)) { return false; } Interpolated tmp = (Interpolated) o; return true && tmp.pre.equals(this.pre) && tmp.expression.equals(this.expression) && tmp.tail.equals(this.tail) ; } @Override public int hashCode() { return 383 + 853 * pre.hashCode() + 743 * expression.hashCode() + 331 * tail.hashCode() ; } @Override public org.rascalmpl.ast.PrePathChars getPre() { return this.pre; } @Override public boolean hasPre() { return true; } @Override public org.rascalmpl.ast.Expression getExpression() { return this.expression; } @Override public boolean hasExpression() { return true; } @Override public org.rascalmpl.ast.PathTail getTail() { return this.tail; } @Override public boolean hasTail() { return true; } @Override public Object clone() { return newInstance(getClass(), src, (IConstructor) null , clone(pre), clone(expression), clone(tail)); } } public boolean isNonInterpolated() { return false; } static public class NonInterpolated extends PathPart { // Production: sig("NonInterpolated",[arg("org.rascalmpl.ast.PathChars","pathChars")],breakable=false) private final org.rascalmpl.ast.PathChars pathChars; public NonInterpolated(ISourceLocation src, IConstructor node , org.rascalmpl.ast.PathChars pathChars) { super(src, node); this.pathChars = pathChars; } @Override public boolean isNonInterpolated() { return true; } @Override public <T> T accept(IASTVisitor<T> visitor) { return visitor.visitPathPartNonInterpolated(this); } @Override protected void addForLineNumber(int $line, java.util.List<AbstractAST> $result) { if (getLocation().getBeginLine() == $line) { $result.add(this); } ISourceLocation $l; $l = pathChars.getLocation(); if ($l.hasLineColumn() && $l.getBeginLine() <= $line && $l.getEndLine() >= $line) { pathChars.addForLineNumber($line, $result); } if ($l.getBeginLine() > $line) { return; } } @Override public boolean equals(Object o) { if (!(o instanceof NonInterpolated)) { return false; } NonInterpolated tmp = (NonInterpolated) o; return true && tmp.pathChars.equals(this.pathChars) ; } @Override public int hashCode() { return 967 + 257 * pathChars.hashCode() ; } @Override public org.rascalmpl.ast.PathChars getPathChars() { return this.pathChars; } @Override public boolean hasPathChars() { return true; } @Override public Object clone() { return newInstance(getClass(), src, (IConstructor) null , clone(pathChars)); } } }