use of dyvil.lang.Name in project Dyvil by Dyvil.
the class Property method formatSetter.
private static void formatSetter(IMethod setter, String prefix, StringBuilder buffer) {
final String indent = Formatting.getIndent("property.setter.indent", prefix);
final IValue value = setter.getValue();
final Name setterParameterName = setter.getParameters().get(0).getName();
buffer.append('\n').append(indent);
setter.getAttributes().toInlineString(indent, buffer);
buffer.append("set");
if (setterParameterName != Names.newValue) {
Formatting.appendSeparator(buffer, "property.setter.parameter.open_paren", '(');
buffer.append(setterParameterName);
Formatting.appendSeparator(buffer, "property.setter.parameter.close_paren", ')');
}
if (value != null) {
if (Util.formatStatementList(indent, buffer, value)) {
return;
}
// Separator
if (Formatting.getBoolean("property.setter.separator.space_before")) {
buffer.append(' ');
}
buffer.append(':');
if (Formatting.getBoolean("property.setter.separator.newline_after")) {
buffer.append('\n').append(indent);
} else if (Formatting.getBoolean("property.setter.separator.space_after")) {
buffer.append(' ');
}
value.toString(indent, buffer);
}
if (Formatting.getBoolean("property.setter.semicolon")) {
buffer.append(';');
}
}
use of dyvil.lang.Name in project Dyvil by Dyvil.
the class OperatorElement method resolve.
protected void resolve(MarkerList markers, IContext context) {
IOperator operator = IContext.resolveOperator(context, this.name, IOperator.INFIX);
if (operator != null) {
this.operator = operator;
// Infix check
checkPosition(markers, this.position, operator, IOperator.INFIX);
return;
}
if (!Util.hasEq(this.name)) {
// Unresolved operator, no =
this.operator = Operator.DEFAULT;
markers.add(Markers.semantic(this.position, "operator.unresolved", this.name));
return;
}
// = at the end
final Name removeEq = Util.removeEq(this.name);
operator = IContext.resolveOperator(context, removeEq, IOperator.INFIX);
if (operator == null) {
this.operator = Operator.DEFAULT_RIGHT;
return;
}
if (operator.getAssociativity() != IOperator.RIGHT) {
this.operator = new Operator(removeEq, IOperator.RIGHT, operator.getPrecedence() - 1);
return;
}
// No infix check required, the type is ID_INFIX_RIGHT
this.operator = operator;
}
use of dyvil.lang.Name in project Dyvil by Dyvil.
the class ExpressionParser method parseInfixAccess.
private void parseInfixAccess(IParserManager pm, IToken token) {
Name name = token.nameValue();
if (name == null) {
name = Name.from(token.stringValue());
}
this.parseInfixAccess(pm, token, name, false);
}
use of dyvil.lang.Name in project Dyvil by Dyvil.
the class PackageParser method parse.
@Override
public void parse(IParserManager pm, IToken token) {
final int type = token.type();
switch(this.mode) {
case PACKAGE:
this.mode = NAME;
if (type != DyvilKeywords.PACKAGE) {
pm.report(token, "package.package");
pm.reparse();
}
return;
case NAME:
if (Tokens.isIdentifier(type)) {
final Name name = token.nameValue();
this.buffer.append(name.qualified);
this.mode = DOT;
return;
}
pm.report(token, "package.identifier");
return;
case DOT:
switch(type) {
case BaseSymbols.SEMICOLON:
pm.reparse();
// Fallthrough
case Tokens.EOF:
this.packageDeclaration.setPackage(this.buffer.toString());
pm.popParser();
return;
case BaseSymbols.DOT:
this.mode = NAME;
this.buffer.append('.');
return;
default:
this.mode = NAME;
pm.report(token, "package.dot");
pm.reparse();
return;
}
}
}
use of dyvil.lang.Name in project Dyvil by Dyvil.
the class TypeAliasParser method parse.
@Override
public void parse(IParserManager pm, IToken token) {
int type = token.type();
switch(this.mode) {
case END:
this.map.addTypeAlias(this.typeAlias);
pm.popParser(true);
return;
case TYPE:
this.mode = NAME;
if (type != DyvilKeywords.TYPE) {
pm.reparse();
pm.report(token, "typealias.type");
}
return;
case NAME:
if (Tokens.isIdentifier(type)) {
Name name = token.nameValue();
this.typeAlias = new TypeAlias(name, token.raw());
this.mode = TYPE_PARAMETERS;
return;
}
pm.popParser();
pm.report(token, "typealias.identifier");
return;
case TYPE_PARAMETERS:
if (TypeParser.isGenericStart(token, type)) {
this.mode = TYPE_PARAMETERS_END;
pm.splitJump(token, 1);
pm.pushParser(new TypeParameterListParser(this.typeAlias));
return;
}
// Fallthrough
case EQUAL:
this.mode = END;
pm.pushParser(new TypeParser(this.typeAlias));
if (type != BaseSymbols.EQUALS) {
pm.reparse();
pm.report(token, "typealias.equals");
}
return;
case TYPE_PARAMETERS_END:
this.mode = EQUAL;
if (TypeParser.isGenericEnd(token, type)) {
pm.splitJump(token, 1);
return;
}
pm.reparse();
pm.report(token, "generic.close_angle");
}
}
Aggregations