Closed capital-G closed 1 year ago
The Class documentation can be helpful for this.
Class.allClasses.do({|c|
c.postln;
nil;
});
Array.dumpAllMethods;
returns
Instance Methods for Array
reverse ( )
scramble ( )
mirror ( )
mirror1 ( )
mirror2 ( )
stutter ( n )
rotate ( n )
This also returns all Methods of all Superclasses.
Array.helpFilePath
returns
SCDoc: Indexing help-files...
SCDoc: Indexed 2208 documents in 1.18 seconds
-> file:///Users/xxx/Library/Application Support/SuperCollider/Help/Classes/Array.html
This html file contains a link at the end to the schelp file which can be displayed nicer than HTML in a tooltip
<div class='doclink'>helpfile source: <a href='file:///Applications/SuperCollider.app/Contents/Resources/HelpSource/Classes/Class.schelp'>/Applications/SuperCollider.app/Contents/Resources/HelpSource/Classes/Class.schelp</a><br>link::Classes/Class::<br></div></div><script src='./../editor.js' type='text/javascript'></script>
</body></html>
A basic auto-complete is implemented but it is yet very buggy and has no intelligence in it - but regarding the reference implementation in SC IDE it seems there is no proper way to get the methods of an object.
Taking a look at these resources could be helpful
(
var methodExtractor = {|method|
(
name: method.name,
arguments: method.argNames.collect({|argName, i|
(
name: argName,
default: method.prototypeFrame[i],
)
});
)
};
x = Class.allClasses.collect({|class|
(
name: class.name,
sourceFile: class.filenameSymbol,
// meta class does not have helpFilePath implemented
helpFile: if(class.isMetaClass, {""}, {class.helpFilePath}),
methods: class.methods.collect({|m|
methodExtractor.value(m);
}),
classMethods: class.class.methods.collect({|m|
methodExtractor.value(m);
});
)
});
)
one class as JSON becomes
{
"classMethods": [
{
"arguments": [
{
"name": "this"
},
{
"default": 28,
"name": "columns"
},
{
"default": 7,
"name": "rows"
},
{
"default": 0.6,
"name": "lambda"
},
{
"default": 1.0,
"name": "sigma"
},
{
"default": 2,
"name": "singleEventsPerSec"
},
{
"default": 5,
"name": "maxEventOrder"
}
],
"name": "new"
},
{
"arguments": [
{
"name": "this"
},
{
"name": "lambda"
},
{
"name": "k"
}
],
"name": "poisson"
}
],
"helpFile": "file:\/\/\/Users\/scheiba\/Library\/Application Support\/SuperCollider\/Help\/Classes\/Aachorripsis.html",
"methods": [
{
"name": "columns"
},
{
"name": "rows"
},
{
"name": "lambda"
},
{
"name": "sigma"
},
{
"name": "maxEventOrder"
},
{
"name": "matrix"
},
{
"name": "p"
},
{
"arguments": [
{
"name": "this"
}
],
"name": "init"
},
{
"arguments": [
{
"name": "this"
},
{
"name": "eventType"
},
{
"name": "simEvents"
}
],
"name": "prInsertEvent"
}
],
"name": "Aachorripsis",
"sourceFile": "\/Users\/scheiba\/github\/aachorripsis\/Classes\/Aachorripsis.sc"
}
Maybe we could parse the Help Files like in the IDE as well?
this results in a 13mb JSON which is not really practical anymore :/ Maybe we can instead rely on the OSC communication for this?
This seems to be a big task but it is definitely worth it.
Maybe SC autocomplete could be implemented via https://langserver.org/
Other implementations of an IDE such as vim, emacs or atom mostly rely on static keywords.
There is an interesting idea mentioned at https://github.com/crucialfelix/atom-supercollider/issues/22#issue-41791462