File |
Line |
de/fhdw/wtf/parser/ExceptionClassParser.java |
98 |
de/fhdw/wtf/parser/RegularClassParser.java |
98 |
ExceptionClassType.create(
name,
modifiers,
attributes,
superTypes,
operations,
constructors,
firstToken,
subTypes);
try {
classResult.getSuperTypes().addAll(this.parseSuperTypes());
ParserUtils.requireAndRemoveCurlyBracketOpenToken(this.stream);
} catch (final NoCurlyBracketOpenException e) {
this.exceptions.add(e);
// Don't skip to next semicolon because you may find it behind the class so that
// you produce more exceptions as necessary.
}
while (this.stream.hasNext() && !this.checkClassEnd() && !(this.stream.peek().isEndToken())) {
final Token currentToken = this.stream.peek();
if (currentToken.isIdentifierToken()) {
try {
final IdentifierToken token = ParserUtils.requireAndRemoveIdentifier(this.stream);
this.parseClassElement(
classResult,
constructors,
attributes,
operations,
token.stringRepresentation(),
classResult,
token);
} catch (final NoSemicolonException e) {
throw e;
} catch (final AbstractParserException e) {
this.exceptions.add(e);
ParserUtils.skipToSemicolonToken(this.stream);
continue;
}
} else if (currentToken.isBracketOpenToken()) {
this.parseConstructor(currentToken, constructors, classResult);
} else {
ParserUtils.requireAndRemoveCurlyBracketCloseToken(this.stream);
}
}
modifiers.addAll(ClassModifierParser.create(this.stream, this.exceptions).parse(classResult));
classResult.setLastToken(this.stream.peek());
return classResult;
}
/**
* Parses a constructor.
*
* @param firstToken
* firstToken.
* @param constructors
* the list of constructors for classResult.
* @param owner
* the owner class of the constructor.
* @throws AbstractParserException
* if the syntax is not correct.
*/
private void parseConstructor(final Token firstToken,
final Collection<Constructor> constructors,
final ClassType owner) throws AbstractParserException {
constructors.add(ConstructorParser.create(this.stream, this.exceptions).parse(firstToken, owner));
}
/**
* Parses a series of tokens and returns the a list of {@link TypeProxy} . If the series of tokens does not match
* the grammar an Exception will be thrown.
*
* @return super types
* @throws AbstractParserException
* {@link NoPlusSymbolException}: if there are some {@link IdentifierToken}s or an
* {@link IdentifierToken} followed by an {@link de.fhdw.wtf.common.token.symbols.CurlyBracketOpenToken}
* with no symbol between, than there is a PlusSymbol missing. {@link NoCurlyBracketOpenException}: If
* it ist not a {@link NoPlusSymbolException} it must be a {@link NoCurlyBracketOpenException}.
*
*/
private Collection<TypeProxy> parseSuperTypes() throws AbstractParserException {
final Collection<TypeProxy> superTypes = new Vector<>();
tryPossibleExceptions(this.stream.copy());
while (this.stream.hasNext() && this.stream.peek().isIdentifierToken()) {
final NameParser nameParser = NameParser.createNameParser(this.stream);
final Name currentSuperTypeName = nameParser.parse();
ParserUtils.requireAndRemovePlusSymbol(this.stream);
final ByNameState byName = ByNameState.create(currentSuperTypeName);
final TypeProxy typeProxy = TypeProxy.create(currentSuperTypeName.getFirstToken(), byName);
typeProxy.setLastToken(currentSuperTypeName.getLastToken());
superTypes.add(typeProxy);
}
return superTypes;
}
/**
* Trys if there are any excpetions with missing + or {. In the case of missing { it is necessary to start the
* parsing again from the first identifier. For example: Class:class=attribute:String;};
*
* @param copy
* - a copy of the origin tokenStream
* @throws AbstractParserException
* {@link NoPlusSymbolException} and {@link NoCurlyBracketOpenException}.
*/
private static void tryPossibleExceptions(final TokenStream copy) throws AbstractParserException {
final Token firstPosition = copy.peek();
try {
while (copy.hasNext() && copy.peek().isIdentifierToken()) {
final NameParser nameParser = NameParser.createNameParser(copy);
nameParser.parse();
ParserUtils.requireAndRemovePlusSymbol(copy);
}
} catch (final NoPlusSymbolException e) {
if (copy.hasNext() && (copy.peek().isIdentifierToken() || copy.peek().isCurlyBracketOpenToken())) {
throw e;
} else {
throw NoCurlyBracketOpenException.create(firstPosition);
}
}
}
/**
* Parses a series of Tokens and creates attribute or operation. The name it is <code>name</code>. The result will
* be add to <code>attributes</code> or <code>operations</code>. The first {@link Token} is <code>firstToken</code>.
* be <code>attributeName</code>.
*
* @param classResult
* the class that is being parsed at the moment.
*
* @param attributes
* attributes
* @param operations
* operations
* @param constructors
* constructors
* @param name
* name of attribute or operation
* @param firstToken
* firstToken
* @throws AbstractParserException
* AbstractParserException
*/
private void parseClassElement(final ClassType classResult,
final Collection<Constructor> constructors,
final Collection<Attribute> attributes,
final Collection<Operation> operations,
final String name,
final ClassType containingType,
final IdentifierToken firstToken) throws AbstractParserException {
ParserUtils.requireAndRemoveColonToken(this.stream);
final Token nextToken = this.stream.peek();
if (nextToken.isDoubleSquareBracketOpenToken()) {
this.stream.removeFirst();
operations
.add(OperationParser.create(this.stream, this.exceptions).parse(name, containingType, firstToken));
} else {
attributes.add(AttributeParser.create(this.stream, this.exceptions).parse(name, firstToken));
}
}
/**
* Returns true if the next Token of this.stream is a CurlyBracketCloseToken, otherwise false.
*
* @return Boolean
*/
private boolean checkClassEnd() {
if (!(this.stream.peek().isCurlyBracketCloseToken())) {
return false;
}
this.stream.removeFirst();
return true;
}
} |
File |
Line |
de/fhdw/wtf/common/ast/type/ProductType.java |
90 |
de/fhdw/wtf/common/ast/type/SumType.java |
95 |
public List<ProductElementType> getElements() {
return this.elements;
}
@Override
public int compareTo(final Type o) {
return o.accept(new TypeVisitorReturn<Integer>() {
@Override
public Integer handle(final AtomicType s) {
return s.accept(new AtomicTypeVisitorReturn<Integer>() {
@Override
public Integer handle(final BaseType baseType) {
return 1;
}
@Override
public Integer handle(final ClassType clazz) {
return -1;
}
});
}
@Override
public Integer handle(final CompositeType c) {
return c.accept(new CompositeTypeVisitorReturn<Integer>() {
@Override
public Integer handle(final ListType list) {
return 1;
}
@Override
public Integer handle(final MapType map) {
return 1;
}
@Override
public Integer handle(final ProductType product) { |
File |
Line |
de/fhdw/wtf/common/ast/ConstructorByReferenceState.java |
105 |
de/fhdw/wtf/common/ast/ConstructorByTypeAndSignatureState.java |
96 |
result.append(current.getType().getTypeString());
if (iterator.hasNext()) {
result.append(AstDescriptionConstants.COMMA_TOKEN);
}
}
result.append(AstDescriptionConstants.BRACKET_CLOSE_TOKEN);
return result.toString();
}
@Override
public void accept(final ConstructorReferenceStateVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final ConstructorReferenceStateVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <Y extends Exception> void accept(final ConstructorReferenceStateVisitorException<Y> v) throws Y {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final ConstructorReferenceStateVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
}
} |
File |
Line |
de/fhdw/wtf/common/ast/type/SumType.java |
275 |
de/fhdw/wtf/common/ast/type/SumType.java |
551 |
normSumElements = this.standardize().accept(new TypeVisitorReturn<List<Type>>() {
@Override
public List<Type> handle(final AtomicType atomicType) {
throw new ASTException("A atomicType cannot be a standardized type of a sumType.");
}
@Override
public List<Type> handle(final CompositeType compositeType) {
return compositeType.accept(new CompositeTypeVisitorReturn<List<Type>>() {
@Override
public List<Type> handle(final ListType list) {
throw new ASTException("A listType cannot be a standardized type of a sumType.");
}
@Override
public List<Type> handle(final MapType map) {
throw new ASTException("A mapType cannot be a standardized type of a sumType.");
}
@Override
public List<Type> handle(final ProductType product) {
throw new ASTException("A productType cannot be a standardized type of a sumType.");
}
@Override
public List<Type> handle(final SumType sum) { |
File |
Line |
de/fhdw/wtf/common/ast/type/ByNameState.java |
82 |
de/fhdw/wtf/common/ast/type/ByReferenceState.java |
111 |
}
@Override
public void accept(final TypeProxyStateVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final TypeProxyStateVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <Y extends Exception> void accept(final TypeProxyStateVisitorException<Y> v) throws Y {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final TypeProxyStateVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
}
@Override
public int compareTo(final TypeProxyState o) {
return o.accept(new TypeProxyStateVisitorReturn<Integer>() {
@Override
public Integer handle(final ByNameState byName) {
return ByNameState.this.getName().toString().compareTo(byName.getName().toString()) * -1; |
File |
Line |
de/fhdw/wtf/common/ast/type/SumType.java |
368 |
de/fhdw/wtf/common/ast/type/SumType.java |
560 |
return compositeType2.accept(new CompositeTypeVisitorReturn<List<Type>>() {
@Override
public List<Type> handle(final ListType list) {
throw new ASTException(
"A listType cannot be a standardized type of a sumType.");
}
@Override
public List<Type> handle(final MapType map) {
throw new ASTException(
"A mapType cannot be a standardized type of a sumType.");
}
@Override
public List<Type> handle(final ProductType product) {
throw new ASTException(
"A productType cannot be a standardized type of a sumType.");
}
@Override
public List<Type> handle(final SumType sum2) {
return sum2.getElements();
}
@Override
public List<Type> handle(final ThrownType thrownType) {
throw new ASTException(
"A thrownType cannot be a standardized type of a sumType.");
}
});
}
@Override
public List<Type> handle(final TypeProxy typeProxy) {
throw new ASTException("A typeType cannot be a standardized type of a sumType."); |
File |
Line |
de/fhdw/wtf/common/ast/type/MapType.java |
113 |
de/fhdw/wtf/common/ast/type/ProductType.java |
92 |
de/fhdw/wtf/common/ast/type/SumType.java |
97 |
}
@Override
public int compareTo(final Type o) {
return o.accept(new TypeVisitorReturn<Integer>() {
@Override
public Integer handle(final AtomicType s) {
return s.accept(new AtomicTypeVisitorReturn<Integer>() {
@Override
public Integer handle(final BaseType baseType) {
return 1;
}
@Override
public Integer handle(final ClassType clazz) {
return -1;
}
});
}
@Override
public Integer handle(final CompositeType c) {
return c.accept(new CompositeTypeVisitorReturn<Integer>() {
@Override
public Integer handle(final ListType list) {
return 1;
}
@Override
public Integer handle(final MapType map) { |
File |
Line |
de/fhdw/wtf/common/ast/type/ExceptionClassType.java |
123 |
de/fhdw/wtf/common/ast/type/RegularClassType.java |
123 |
return new ExceptionClassType(name, modifiers, attributes, superTypes, operations, superConstructors,
firstToken, subTypes, null);
}
@Override
public void accept(final ClassTypeVisitor classTypeVisitor) {
classTypeVisitor.handle(this);
}
@Override
public <X> X accept(final ClassTypeVisitorReturn<X> classTypeVisitorReturn) {
return classTypeVisitorReturn.handle(this);
}
@Override
public <Y extends Exception> void accept(final ClassTypeVisitorException<Y> classTypeVisitorException) throws Y {
classTypeVisitorException.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final ClassTypeVisitorReturnException<X, Y> classTypeVisitorReturnException)
throws Y {
return classTypeVisitorReturnException.handle(this);
}
} |
File |
Line |
de/fhdw/wtf/parser/ExceptionClassParser.java |
68 |
de/fhdw/wtf/parser/RegularClassParser.java |
68 |
return new ExceptionClassParser(stream, exceptions);
}
/**
* Parses a Class with <code>name</code> as the class name from this.stream. This method expects the first Token in
* the stream to be an EqualToken. This method calls an operation to parse the Attributes and ClassModifiers. If one
* of the Tokens in the stream is unexpected, an AbstractParserException will be thrown.
*
* @param name
* : Name of Class.
* @param firstToken
* : First token of class.
* @throws AbstractParserException
* AbstractParserException
* @return ClassType
*/
protected ClassType parse(final Name name, final Token firstToken) throws AbstractParserException {
try {
ParserUtils.requireAndRemoveEqualToken(this.stream);
} catch (final NoEqualException e) {
throw e;
}
final Collection<Attribute> attributes = new Vector<>();
final Collection<ClassModifier> modifiers = new Vector<>();
final Collection<ClassType> subTypes = new Vector<>();
final Collection<Operation> operations = new Vector<>();
final List<Type> superTypes = new Vector<>();
final Collection<Constructor> constructors = new Vector<>();
final ClassType classResult = |
File |
Line |
de/fhdw/wtf/common/ast/type/ListType.java |
145 |
de/fhdw/wtf/common/ast/type/MapType.java |
175 |
return this.getOf().hashCode();
}
@Override
public void accept(final CompositeTypeVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final CompositeTypeVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <X extends Exception> void accept(final CompositeTypeVisitorException<X> v) throws X {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final CompositeTypeVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
}
@Override
public boolean isSupertypeOf(final Type type) {
return false;
}
@Override
public ListType getPrototype() { |
File |
Line |
de/fhdw/wtf/common/ast/type/ListType.java |
145 |
de/fhdw/wtf/common/ast/type/SumType.java |
243 |
return this.getOf().hashCode();
}
@Override
public void accept(final CompositeTypeVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final CompositeTypeVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <X extends Exception> void accept(final CompositeTypeVisitorException<X> v) throws X {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final CompositeTypeVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
}
@Override
public boolean isSupertypeOf(final Type type) { |
File |
Line |
de/fhdw/wtf/common/ast/type/MapType.java |
175 |
de/fhdw/wtf/common/ast/type/SumType.java |
243 |
});
}
@Override
public void accept(final CompositeTypeVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final CompositeTypeVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <X extends Exception> void accept(final CompositeTypeVisitorException<X> v) throws X {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final CompositeTypeVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
}
@Override
public boolean isSupertypeOf(final Type type) { |
File |
Line |
de/fhdw/wtf/common/ast/type/ListType.java |
64 |
de/fhdw/wtf/common/ast/type/MapType.java |
113 |
de/fhdw/wtf/common/ast/type/ProductType.java |
92 |
de/fhdw/wtf/common/ast/type/SumType.java |
97 |
}
@Override
public int compareTo(final Type o) {
return o.accept(new TypeVisitorReturn<Integer>() {
@Override
public Integer handle(final AtomicType s) {
return s.accept(new AtomicTypeVisitorReturn<Integer>() {
@Override
public Integer handle(final BaseType baseType) {
return 1;
}
@Override
public Integer handle(final ClassType clazz) {
return -1;
}
});
}
@Override
public Integer handle(final CompositeType c) {
return c.accept(new CompositeTypeVisitorReturn<Integer>() {
@Override
public Integer handle(final ListType list) { |
File |
Line |
de/fhdw/wtf/common/ast/type/MapType.java |
172 |
de/fhdw/wtf/common/ast/type/ThrownType.java |
155 |
public Integer handle(final TypeProxy s) {
return 1;
}
});
}
@Override
public void accept(final CompositeTypeVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final CompositeTypeVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <X extends Exception> void accept(final CompositeTypeVisitorException<X> v) throws X {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final CompositeTypeVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
}
@Override
public boolean isSupertypeOf(final Type type) { |
File |
Line |
de/fhdw/wtf/common/ast/type/ProductType.java |
238 |
de/fhdw/wtf/common/ast/type/SumType.java |
242 |
result.append(AstDescriptionConstants.BRACKET_CLOSE_TOKEN);
return result.toString();
}
@Override
public void accept(final CompositeTypeVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final CompositeTypeVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <X extends Exception> void accept(final CompositeTypeVisitorException<X> v) throws X {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final CompositeTypeVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
} |
File |
Line |
de/fhdw/wtf/common/ast/type/AtomicType.java |
89 |
de/fhdw/wtf/common/ast/type/CompositeType.java |
33 |
}
@Override
public void accept(final TypeVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final TypeVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <X extends Exception> void accept(final TypeVisitorException<X> v) throws X {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final TypeVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
}
/**
* Accept-Methode Visitor-Pattern.
*
* @param v
* Visitor
*/
public abstract void accept(AtomicTypeVisitor v); |
File |
Line |
de/fhdw/wtf/common/ast/type/ListType.java |
145 |
de/fhdw/wtf/common/ast/type/SumType.java |
243 |
de/fhdw/wtf/common/ast/type/ThrownType.java |
158 |
return this.getOf().hashCode();
}
@Override
public void accept(final CompositeTypeVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final CompositeTypeVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <X extends Exception> void accept(final CompositeTypeVisitorException<X> v) throws X {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final CompositeTypeVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
}
@Override
public boolean isSupertypeOf(final Type type) { |
File |
Line |
de/fhdw/wtf/common/ast/ConstructorByReferenceState.java |
111 |
de/fhdw/wtf/common/ast/ConstructorByTypeAndSignatureState.java |
102 |
de/fhdw/wtf/common/ast/ConstructorInvalidState.java |
47 |
return result.toString();
}
@Override
public void accept(final ConstructorReferenceStateVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final ConstructorReferenceStateVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <Y extends Exception> void accept(final ConstructorReferenceStateVisitorException<Y> v) throws Y {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final ConstructorReferenceStateVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
}
} |
File |
Line |
de/fhdw/wtf/common/ast/type/ByNameState.java |
82 |
de/fhdw/wtf/common/ast/type/ByReferenceState.java |
111 |
de/fhdw/wtf/common/ast/type/InvalidState.java |
61 |
}
@Override
public void accept(final TypeProxyStateVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final TypeProxyStateVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <Y extends Exception> void accept(final TypeProxyStateVisitorException<Y> v) throws Y {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final TypeProxyStateVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
}
@Override
public int compareTo(final TypeProxyState o) { |
File |
Line |
de/fhdw/wtf/common/ast/type/ListType.java |
145 |
de/fhdw/wtf/common/ast/type/ProductType.java |
239 |
return this.getOf().hashCode();
}
@Override
public void accept(final CompositeTypeVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final CompositeTypeVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <X extends Exception> void accept(final CompositeTypeVisitorException<X> v) throws X {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final CompositeTypeVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
} |
File |
Line |
de/fhdw/wtf/common/ast/type/CompositeType.java |
32 |
de/fhdw/wtf/common/ast/type/TypeProxy.java |
276 |
super(firstToken, lastToken);
}
@Override
public void accept(final TypeVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final TypeVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <X extends Exception> void accept(final TypeVisitorException<X> v) throws X {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final TypeVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
} |
File |
Line |
de/fhdw/wtf/common/ast/type/MapType.java |
175 |
de/fhdw/wtf/common/ast/type/ProductType.java |
239 |
de/fhdw/wtf/common/ast/type/ThrownType.java |
158 |
});
}
@Override
public void accept(final CompositeTypeVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final CompositeTypeVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <X extends Exception> void accept(final CompositeTypeVisitorException<X> v) throws X {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final CompositeTypeVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
} |
File |
Line |
de/fhdw/wtf/common/ast/type/AtomicType.java |
89 |
de/fhdw/wtf/common/ast/type/TypeProxy.java |
277 |
}
@Override
public void accept(final TypeVisitor v) {
v.handle(this);
}
@Override
public <X> X accept(final TypeVisitorReturn<X> v) {
return v.handle(this);
}
@Override
public <X extends Exception> void accept(final TypeVisitorException<X> v) throws X {
v.handle(this);
}
@Override
public <X, Y extends Exception> X accept(final TypeVisitorReturnException<X, Y> v) throws Y {
return v.handle(this);
} |
File |
Line |
de/fhdw/wtf/walker/tasks/InheritanceOfThrownExceptionsCheck.java |
17 |
de/fhdw/wtf/walker/tasks/NoThrownListTypesCheck.java |
30 |
public InheritanceOfThrownExceptionsCheck(final Model m, final TaskExecutor taskmanager) {
super(m, taskmanager);
// Auto-generated constructor stub
}
@Override
public void handleClass(final ClassType c) throws TaskException {
// Auto-generated method stub
}
@Override
public void handleGroup(final Group g) throws TaskException {
// Auto-generated method stub
}
@Override
public void handleAttribute(final Attribute a, final ClassType owner) throws TaskException {
// Auto-generated method stub
}
@Override
public void handleConstructorOrOperation(final ConstructorOrOperation coo, final ClassType owner)
throws TaskException {
coo.accept(new ConstructorOrOperationExceptionVisitor<TaskException>() {
@Override
public void handleOperation(final Operation operation) throws TaskException { |