Skip to content

Commit

Permalink
Prevent error on method signature query (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgranstrom authored May 15, 2024
1 parent 4777c0d commit de0fbc3
Showing 1 changed file with 44 additions and 9 deletions.
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

0 comments on commit de0fbc3

Please sign in to comment.