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

Implement auto-completion #3

Closed
capital-G opened this issue Nov 4, 2020 · 7 comments · Fixed by #4 or #37
Closed

Implement auto-completion #3

capital-G opened this issue Nov 4, 2020 · 7 comments · Fixed by #4 or #37
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@capital-G
Copy link
Owner

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 crucialfelix/atom-supercollider#22 (comment)

@capital-G capital-G added enhancement New feature or request help wanted Extra attention is needed labels Nov 4, 2020
@capital-G
Copy link
Owner Author

The Class documentation can be helpful for this.

List all Classes

Class.allClasses.do({|c|
    c.postln;
    nil;
});

Find all methods of a class

Array.dumpAllMethods;

returns

Instance Methods for Array

   reverse (  )
   scramble (  )
   mirror (  )
   mirror1 (  )
   mirror2 (  )
   stutter ( n )
   rotate ( n )

This also returns all Methods of all Superclasses.

Find help for class

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>

@capital-G capital-G linked a pull request Nov 16, 2020 that will close this issue
capital-G added a commit that referenced this issue Nov 16, 2020
@capital-G
Copy link
Owner Author

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.

@capital-G capital-G reopened this Nov 16, 2020
@capital-G capital-G added this to the v0.4.0 milestone Jan 29, 2023
@capital-G
Copy link
Owner Author

(
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?

image

@capital-G
Copy link
Owner Author

this results in a 13mb JSON which is not really practical anymore :/
Maybe we can instead rely on the OSC communication for this?

capital-G added a commit that referenced this issue Feb 9, 2023
capital-G added a commit that referenced this issue Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
1 participant