func (c *CompletionHandler) Handle(it *content.Intent) *content.Response {
	loc := it.Data.Get("loc").(content.SourceLocation)
	args, _ := it.Settings().Get("compiler_flags").([]string)
	if cmp, err := CompleteAt(args, loc); err != nil {
		return content.NewErrorResponse(err.Error())
	} else {
		r := content.NewResponse()
		r.Data.Set("completions", cmp)
		return &r
	}
}
Example #2
0
func (c *CompletionHandler) Handle(it *content.Intent) *content.Response {
	cp, err := DefaultClasspath()
	if err != nil {
		// We don't really care about not being able to get the default classpath as it could be provided manually by the user
		log4go.Warn("Couldn't get the default classpath: %s", err)
	}
	settings := it.Settings()
	if cp2, ok := settings.Get("classpath").([]string); ok {
		// TODO: do we ever want to override rather than append to the classpath?
		cp = append(cp, cp2...)
	}
	// TODO: this should probably be cached in the session...
	if archive, err := NewCompositeArchive(cp); err != nil {
		return content.NewErrorResponse(err.Error())
	} else {
		if cmp, err := c.Complete(archive, it.Data.Get("fqn").(content.FullyQualifiedName)); err != nil {
			return content.NewErrorResponse(err.Error())
		} else {
			r := content.NewResponse()
			r.Data.Set("completions", cmp)
			return &r
		}
	}
}