我想在给定的代码中找到任何方法调用.所以我用分号作为分隔符拆分代码.所以最后我有兴趣找到在给定代码中调用的方法的名称.我需要一个正则表达式来匹配方法调用模式.请帮忙!!
我正在寻找调用 IMethod 的 IMethod、IType 或 IJavaElement。我探索了 org.eclipse.jdt.internal.corex.callhierarchy.CallHierarchy。我已经编写了这段代码,但它没有在包装器或位置上给我任何东西。请指导我。
public void getMethodCallers(IMethod[] methods){
CallHierarchy hierarchy = new CallHierarchy();
IJavaSearchScope searchScope= SearchEngine.createWorkspaceScope();
hierarchy.setSearchScope(searchScope);
CallLocation location = hierarchy.getCallLocation(method[0])
MethodWrapper [] wrapper = hierarchy.getCalleeRoots(methods);
}
Run Code Online (Sandbox Code Playgroud) 我正在为一个类分配任务,它在rspec测试中使用column_types方法。
it "User database structure in place" do
expect(User.column_names).to include "password_digest", "username"
expect(User.column_types["username"].type).to eq :string
expect(User.column_types["password_digest"].type).to eq :string
expect(User.column_types["created_at"].type).to eq :datetime
expect(User.column_types["updated_at"].type).to eq :datetime
Run Code Online (Sandbox Code Playgroud)
结束
错误:当我在命令行中运行rpsec时。
Rails 5.0
Ubuntu 14.10
失败/错误:期望(User.column_types [“ username”]。type).to eq:string
NoMethodError:
undefined method `column_types' for #<Class:0x000000053a0188>
Did you mean? columns
column_names
# ./spec/assignment_spec.rb:67:in `block (5 levels) in <top (required)>'
# ./spec/assignment_spec.rb:14:in `block (2 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud) ArrowKt 已弃用Try,因为它会促进效果的急切执行,并且建议使用挂起构造函数。但是,如果我确实希望在不使用传统的try-catch 的情况下有意执行,我应该如何处理以下情况。
fun getMainAccount(accounts: List<String>): Either<Exception, String> {
return Try {
accounts.single()
}.toEither().mapLeft {
InvalidAccountError()
}
}
Run Code Online (Sandbox Code Playgroud)