Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent error on method signature query #243

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 44 additions & 9 deletions scide_scnvim/Classes/SCNvimDoc/extSCNvim.sc
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
+ SCNvim {
// This function will be replaced by LSP in the future
*methodArgs {|method|
var args = Help.methodArgs(method);
args = args.split(Char.nl);
if (args.size == 1) {
^args[0]
}
^"";
// copy of `Help.methodArgs` with an additional bugfix
// remove this later if merged upstream
*getMethodArgs {|string|
var class, meth, f, m;
f = string.findRegexp("(\\w*)\\.(\\w+)").flop[1];
if(f.notNil) {#class, meth = f[1..]} {
if(string[0].isUpper) {
class = string;
meth = \new;
} {
meth = string;
}
};
f = {|m,c|
class = (c ?? {m.ownerClass}).name;
class = if(class.isMetaClassName) {class.asString[5..]++" *"} {class.asString++" -"};
if (m.argNames.notNil) { // argNames can be nil in rare cases such as `Done.freeSelf`
class++m.name++" ("++m.argNames[1..].collect {|n,i|
n.asString++":"+m.prototypeFrame[i+1];
}.join(", ")++")";
} { "" }
};
class = class.asSymbol.asClass;
if(class.notNil) {
m = class.class.findRespondingMethodFor(meth.asSymbol);
^if(m.notNil) {f.value(m,class.class)} {""};
} {
^Class.allClasses.reject{|c|c.isMetaClass}.collect {|c|
c.findMethod(meth.asSymbol);
}.reject{|m|m.isNil}.collect {|m|
f.value(m);
}.join($\n);
}
}

// This function will be replaced by LSP in the future
*methodArgs {|method|
var args = this.getMethodArgs(method);
args = args.split(Char.nl);
if (args.size == 1) {
^args[0]
}
^"";
}

*prepareHelpFor {|text|
Expand All @@ -17,7 +52,7 @@
SCDoc.renderer = SCNvimDocRenderer;

urlString = SCNvimDoc.findHelpFile(text);
url = URI(urlString);
url = URI(urlString);
brokenAction = {
"Sorry no help for %".format(text).postln;
^nil;
Expand Down
Loading