use of dyvil.lang.Name in project Dyvil by Dyvil.
the class REPLContext method getMethodMatches.
@Override
public void getMethodMatches(MatchList<IMethod> list, IValue receiver, Name name, ArgumentList arguments) {
for (IMethod method : this.methods) {
method.checkMatch(list, receiver, name, arguments);
}
if (name == null) {
return;
}
final Name removeEq = Util.removeEq(name);
IProperty property = this.properties.get(removeEq);
if (property != null) {
property.checkMatch(list, receiver, name, arguments);
}
final IField field = this.fields.get(removeEq);
if (field != null) {
property = field.getProperty();
if (property != null) {
property.checkMatch(list, receiver, name, arguments);
}
}
}
use of dyvil.lang.Name in project Dyvil by Dyvil.
the class REPLContext method setValue.
@Override
public void setValue(IValue value) {
final Name name = Name.fromRaw("res" + this.resultIndex++);
final REPLVariable field = new REPLVariable(this, name, value);
this.initMember(field);
this.currentClass.getBody().addDataMember(field);
this.members.add(field);
}
use of dyvil.lang.Name in project Dyvil by Dyvil.
the class RenameCommand method execute.
@Override
public void execute(DyvilREPL repl, String argument) {
final String[] split;
if (argument == null || (split = argument.split(" ", 2)).length < 2) {
repl.getErrorOutput().println(I18n.get("command.argument_list.invalid", this.getUsage()));
return;
}
final Name memberName = Name.from(split[0]);
final Name newName = Name.from(split[1]);
final Map<Name, IField> fields = repl.getContext().getFields();
final IField field = fields.remap(memberName, newName);
if (field != null) {
field.setName(newName);
repl.getOutput().println(I18n.get("command.rename.success", memberName, newName));
} else {
repl.getOutput().println(I18n.get("command.rename.not_found", memberName));
}
}
Aggregations