0

Enhance Rails Intellisense in Solargraph

 2023-02-06 07:34:24
source link: https://gist.github.com/castwide/28b349566a223dfb439a337aea29713e

Enhance Rails Intellisense in Solargraph · GitHub

jhirn

commented

Oct 18, 2021

edited

What would the yard docs look like for extending Active Support on object. For instance, I'd like to complete .in? on string which comes from core_ext Inclusion but can't seem to get it working after 30 mins of what I would officially refer to as "futzing" around with the definitions file.

I attempted adding this to my solargraph.yml but it didnt' seem to have any effect.

require:
  - actioncable
  - actionmailer
  - actionpack
  - actionview
  - activejob
  - activemodel
  - activerecord
  - activestorage
  - activesupport

You can put this file anywhere in the project, as long as it gets included in the workspace maps

I'm not sure how to tell / make sure that the file is included in the workspace maps. Can anyone give an example implementation?

You can put this file anywhere in the project, as long as it gets included in the workspace maps

I'm not sure how to tell / make sure that the file is included in the workspace maps. Can anyone give an example implementation?

See The Comment File section at https://solargraph.org/guides/rails

Regardless of whether it's right or wrong, I feel that having more modules in the ActiveRecord can really help a lot in the development experience, and thus, I add the following:

extend all modules under Active Record

#   class ActiveRecord::Base
#     extend ActiveRecord::Aggregations
#     extend ActiveRecord::Aggregations::ClassMethods
#     extend ActiveRecord::Batches
#     extend ActiveRecord::Calculations
#     extend ActiveRecord::Callbacks
#     extend ActiveRecord::Coders
#     extend ActiveRecord::ConnectionAdapters
#     extend ActiveRecord::ConnectionAdapters::AbstractPool
#     extend ActiveRecord::ConnectionAdapters::ColumnMethods
#     extend ActiveRecord::ConnectionAdapters::DatabaseLimits
#     extend ActiveRecord::ConnectionAdapters::DatabaseStatements
#     extend ActiveRecord::ConnectionAdapters::DetermineIfPreparableVisitor
#     extend ActiveRecord::ConnectionAdapters::MySQL
#     extend ActiveRecord::ConnectionAdapters::MySQL::ColumnMethods
#     extend ActiveRecord::ConnectionAdapters::MySQL::DatabaseStatements
#     extend ActiveRecord::ConnectionAdapters::MySQL::Quoting
#     extend ActiveRecord::ConnectionAdapters::MySQL::SchemaStatements
#     extend ActiveRecord::ConnectionAdapters::PostgreSQL
#     extend ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnMethods
#     extend ActiveRecord::ConnectionAdapters::PostgreSQL::DatabaseStatements
#     extend ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting
#     extend ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements
#     extend ActiveRecord::ConnectionAdapters::PostgreSQL::OID
#     extend ActiveRecord::ConnectionAdapters::PostgreSQL::ReferentialIntegrity
#     extend ActiveRecord::ConnectionAdapters::PostgreSQL::Utils
#     extend ActiveRecord::ConnectionAdapters::QueryCache
#     extend ActiveRecord::ConnectionAdapters::QueryCache::ConnectionPoolConfiguration
#     extend ActiveRecord::ConnectionAdapters::Quoting
#     extend ActiveRecord::ConnectionAdapters::Savepoints
#     extend ActiveRecord::ConnectionAdapters::SQLite3
#     extend ActiveRecord::ConnectionAdapters::SQLite3::DatabaseStatements
#     extend ActiveRecord::ConnectionAdapters::SQLite3::Quoting
#     extend ActiveRecord::ConnectionAdapters::SQLite3::SchemaStatements
#     extend ActiveRecord::ConnectionAdapters::SchemaStatements
#     extend ActiveRecord::ConnectionHandling
#     extend ActiveRecord::Core
#     extend ActiveRecord::Core::ClassMethods
#     extend ActiveRecord::CounterCache
#     extend ActiveRecord::CounterCache::ClassMethods
#     extend ActiveRecord::DefineCallbacks
#     extend ActiveRecord::DefineCallbacks::ClassMethods
#     extend ActiveRecord::Delegation::ClassMethods
#     extend ActiveRecord::Delegation::ClassSpecificRelation
#     extend ActiveRecord::Delegation::ClassSpecificRelation::ClassMethods
#     extend ActiveRecord::Delegation::DelegateCache
#     extend ActiveRecord::DynamicMatchers
#     extend ActiveRecord::Enum
#     extend ActiveRecord::Explain
#     extend ActiveRecord::FinderMethods
#     extend ActiveRecord::Generators
#     extend ActiveRecord::Generators::Migration
#     extend ActiveRecord::Generators::Migration::ClassMethods
#     extend ActiveRecord::Inheritance
#     extend ActiveRecord::Inheritance::ClassMethods
#     extend ActiveRecord::Integration
#     extend ActiveRecord::Integration::ClassMethods
#     extend ActiveRecord::LegacyYamlAdapter
#     extend ActiveRecord::LegacyYamlAdapter::Rails41
#     extend ActiveRecord::LegacyYamlAdapter::Rails420::
#     extend ActiveRecord::Locking
#     extend ActiveRecord::Locking::Optimistic
#     extend ActiveRecord::Locking::Optimistic::ClassMethods
#     extend ActiveRecord::Locking::Pessimistic
#     extend ActiveRecord::Middleware
#     extend ActiveRecord::ModelSchema
#     extend ActiveRecord::ModelSchema::ClassMethods
#     extend ActiveRecord::NestedAttributes
#     extend ActiveRecord::NoTouching
#     extend ActiveRecord::NoTouching::ClassMethods
#     extend ActiveRecord::NullRelation
#     extend ActiveRecord::Persistence
#     extend ActiveRecord::Persistence::ClassMethods
#     extend ActiveRecord::Querying
#     extend ActiveRecord::QueryMethods
#     extend ActiveRecord::Railties
#     extend ActiveRecord::Railties::CollectionCacheAssociationLoading
#     extend ActiveRecord::Railties::ControllerRuntime
#     extend ActiveRecord::Railties::ControllerRuntime::ClassMethods
#     extend ActiveRecord::ReadonlyAttributes
#     extend ActiveRecord::ReadonlyAttributes::ClassMethods
#     extend ActiveRecord::Reflection
#     extend ActiveRecord::Reflection::ClassMethods
#     extend ActiveRecord::Sanitization
#     extend ActiveRecord::Sanitization::ClassMethods
#     extend ActiveRecord::Scoping::ClassMethods
#     extend ActiveRecord::Scoping::Default
#     extend ActiveRecord::Scoping::Default::ClassMethods
#     extend ActiveRecord::Scoping::Named
#     extend ActiveRecord::Scoping::Named::ClassMethods
#     extend ActiveRecord::SecureToken
#     extend ActiveRecord::SecureToken::ClassMethods
#     extend ActiveRecord::Serialization
#     extend ActiveRecord::SpawnMethods
#     extend ActiveRecord::Store
#     extend ActiveRecord::Store::ClassMethods
#     extend ActiveRecord::Suppressor
#     extend ActiveRecord::Suppressor::ClassMethods
#     extend ActiveRecord::Tasks
#     extend ActiveRecord::Tasks::DatabaseTasks
#     extend ActiveRecord::TestDatabases
#     extend ActiveRecord::TestFixtures
#     extend ActiveRecord::TestFixtures::ClassMethods
#     extend ActiveRecord::Timestamp
#     extend ActiveRecord::Timestamp::ClassMethods
#     extend ActiveRecord::TouchLater
#     extend ActiveRecord::Transactions
#     extend ActiveRecord::Transactions::ClassMethods
#     extend ActiveRecord::Translation
#     extend ActiveRecord::Type
#     extend ActiveRecord::Type::Internal
#     extend ActiveRecord::Type::Internal::Timezone
#     extend ActiveRecord::TypeCaster
#     extend ActiveRecord::Validations
#     extend ActiveRecord::Validations::Callbacks
#     extend ActiveRecord::Validations::ClassMethods
#     extend ActiveRecord::Validations::Clusivity
#     extend ActiveRecord::VERSION
#   end

And some other thought...

  • Since I have added by using solargraph to select the modules one by one, there should be a programmatic way to deal with the above.
  • The yard document seems to tell you whether the function returns a relation or not? (for example, .all function says "ActiveRecord::Scoping::Named::ClassMethods#all Returns an ActiveRecord::Relation scope object") maybe we can use that information to annotate the function?

Not sure whether it is possible or not, any thoughts?


About Archive Link


everyday a lot of link has gone away.
archive.link will keep it forever.