@nexus-ioc/language-service 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +44 -0
  2. package/dist/actions/get-completion-info.actions.js +4 -6
  3. package/dist/actions/get-completion-info.actions.js.map +1 -1
  4. package/dist/actions/get-semantic-diagnostics.actions.d.ts +13 -0
  5. package/dist/actions/get-semantic-diagnostics.actions.js +467 -48
  6. package/dist/actions/get-semantic-diagnostics.actions.js.map +1 -1
  7. package/dist/actions/go-to-dependency-definition.actions.d.ts +18 -0
  8. package/dist/actions/go-to-dependency-definition.actions.js +73 -0
  9. package/dist/actions/go-to-dependency-definition.actions.js.map +1 -0
  10. package/dist/index.d.ts +10 -0
  11. package/dist/index.js +37 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/language-service/ns-language-service.d.ts +6 -5
  14. package/dist/language-service/ns-language-service.js +8 -2
  15. package/dist/language-service/ns-language-service.js.map +1 -1
  16. package/dist/language-service/parse-config-service.js +1 -0
  17. package/dist/language-service/parse-config-service.js.map +1 -1
  18. package/dist/language-service/types.d.ts +0 -1
  19. package/dist/logger.js +1 -0
  20. package/dist/logger.js.map +1 -1
  21. package/package.json +19 -11
  22. package/dist/helpers/check-types.helper.d.ts +0 -3
  23. package/dist/helpers/check-types.helper.js +0 -30
  24. package/dist/helpers/check-types.helper.js.map +0 -1
  25. package/dist/helpers/compare-string-types.helper.d.ts +0 -4
  26. package/dist/helpers/compare-string-types.helper.js +0 -16
  27. package/dist/helpers/compare-string-types.helper.js.map +0 -1
  28. package/dist/helpers/find-node-at-position.helper.d.ts +0 -2
  29. package/dist/helpers/find-node-at-position.helper.js +0 -16
  30. package/dist/helpers/find-node-at-position.helper.js.map +0 -1
  31. package/dist/helpers/find-type-references.helper.d.ts +0 -8
  32. package/dist/helpers/find-type-references.helper.js +0 -51
  33. package/dist/helpers/find-type-references.helper.js.map +0 -1
  34. package/dist/helpers/get-type-of-node.helper.d.ts +0 -2
  35. package/dist/helpers/get-type-of-node.helper.js +0 -14
  36. package/dist/helpers/get-type-of-node.helper.js.map +0 -1
  37. package/dist/parsers/inject.parser.d.ts +0 -16
  38. package/dist/parsers/inject.parser.js +0 -44
  39. package/dist/parsers/inject.parser.js.map +0 -1
  40. package/dist/parsers/injectable.parser.d.ts +0 -5
  41. package/dist/parsers/injectable.parser.js +0 -13
  42. package/dist/parsers/injectable.parser.js.map +0 -1
  43. package/dist/parsers/ns-module.parser.d.ts +0 -45
  44. package/dist/parsers/ns-module.parser.js +0 -237
  45. package/dist/parsers/ns-module.parser.js.map +0 -1
  46. package/dist/parsers/ns-modules.parser.d.ts +0 -7
  47. package/dist/parsers/ns-modules.parser.js +0 -35
  48. package/dist/parsers/ns-modules.parser.js.map +0 -1
package/README.md CHANGED
@@ -11,6 +11,8 @@
11
11
  - [Features](#features)
12
12
  - [Installation](#installation)
13
13
  - [Quick Start](#quick-start)
14
+ - [Example Project](#example-project)
15
+ - [Roadmap](#roadmap)
14
16
  - [License](#license)
15
17
  - [Author](#author)
16
18
  - [Contributing](#contributing)
@@ -44,6 +46,48 @@ npm install @nexus-ioc/language-service
44
46
 
45
47
  ```
46
48
 
49
+ ### Child containers
50
+
51
+ Modules declared in `@Module({ children })` are analysed as child scopes. A missing-dependency error in a child scope is suppressed when the declaring module can see the token in the parent graph. A module that is also imported outside a child scope keeps the diagnostic. Tokens the declaring module sees only through a re-export are not recognised yet. Tokens supplied per child instance (the `providers` of `forProfile()` or another dynamic module, or `createChild(..., { providers })`) are not visible to static analysis, so they may be reported as missing. See [Child containers](../ioc/README.md#child-containers).
52
+
53
+ ## Example Project
54
+
55
+ A comprehensive example project is available in the `example/` directory that demonstrates all plugin features:
56
+
57
+ - ✅ Auto-completion for `@Inject()` decorators
58
+ - ✅ Go-to-definition for dependency tokens
59
+ - ✅ Semantic diagnostics for DI errors
60
+ - ✅ Working examples with proper module configuration
61
+ - ✅ Error examples showing common mistakes
62
+
63
+ **Quick Start**:
64
+ ```bash
65
+ # From monorepo root
66
+ cd packages/language-service/example
67
+ npm install
68
+ npm run build
69
+
70
+ # Open in your IDE
71
+ code .
72
+ ```
73
+
74
+ See [`example/README.md`](./example/README.md) for detailed setup instructions and [`example/TESTING_GUIDE.md`](./example/TESTING_GUIDE.md) for comprehensive testing procedures.
75
+
76
+ ## Roadmap
77
+
78
+ See [`ROADMAP.md`](./ROADMAP.md) for the complete feature roadmap including:
79
+ - Current capabilities and limitations
80
+ - Planned enhancements (Phases 2-6)
81
+ - Effort estimates and prioritization
82
+ - Success metrics
83
+
84
+ **Highlights**:
85
+ - **Phase 2**: Support for `@Optional()`, `@Global()`, property injection, circular dependency detection
86
+ - **Phase 3**: Quick fixes (auto-add providers, import modules, fix type mismatches)
87
+ - **Phase 4**: Refactoring support (rename tokens, extract to module)
88
+ - **Phase 5**: Performance optimizations, hover info, inlay hints
89
+ - **Phase 6**: Dependency graph visualization, testing support
90
+
47
91
  ## License
48
92
 
49
93
  This project is licensed under the MIT License. See the LICENSE file for details.
@@ -2,23 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCompletionInfoActions = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const type_checker_1 = require("@nexus-ioc/type-checker");
5
6
  const tsserverlibrary_1 = tslib_1.__importDefault(require("typescript/lib/tsserverlibrary"));
6
- const find_type_references_helper_1 = require("../helpers/find-type-references.helper");
7
- const ns_module_parser_1 = require("../parsers/ns-module.parser");
8
- const ns_modules_parser_1 = require("../parsers/ns-modules.parser");
9
7
  const getCompletionInfoActions = (classDeclaration, tsNsLs) => {
10
8
  const typeChecker = tsNsLs.tsLS.getProgram()?.getTypeChecker();
11
9
  if (!typeChecker) {
12
10
  return;
13
11
  }
14
- const entries = (0, find_type_references_helper_1.findTypeReferences)(classDeclaration, tsNsLs.tsLS, tsNsLs.logger)
12
+ const entries = (0, type_checker_1.findTypeReferences)(classDeclaration, tsNsLs)
15
13
  .map((item) => {
16
14
  const sourceFile = tsNsLs.tsLS
17
15
  .getProgram()
18
16
  ?.getSourceFile(item.fileName);
19
- return ns_modules_parser_1.NsModulesParser.executeByClassDependency(sourceFile, classDeclaration, tsNsLs.logger);
17
+ return type_checker_1.ModulesParser.executeByClassDependency(sourceFile, classDeclaration, tsNsLs);
20
18
  })
21
- .flatMap((items) => ns_module_parser_1.NsModuleParser.execute(items, typeChecker, tsNsLs.logger))
19
+ .flatMap((items) => type_checker_1.ModuleParser.execute(items, typeChecker, tsNsLs))
22
20
  .flatMap((module) => module.providers)
23
21
  .map((provider, index) => {
24
22
  if (tsserverlibrary_1.default.isStringLiteral(provider.provide)) {
@@ -1 +1 @@
1
- {"version":3,"file":"get-completion-info.actions.js","sourceRoot":"","sources":["../../src/actions/get-completion-info.actions.ts"],"names":[],"mappings":";;;;AACA,6FAAgD;AAChD,wFAA4E;AAE5E,kEAA6D;AAC7D,oEAA+D;AAExD,MAAM,wBAAwB,GAAG,CACvC,gBAAqC,EACrC,MAAyB,EACO,EAAE;IAClC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,cAAc,EAAE,CAAC;IAE/D,IAAI,CAAC,WAAW,EAAE,CAAC;QAClB,OAAO;IACR,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,gDAAkB,EACjC,gBAAgB,EAChB,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,MAAM,CACb;SACC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACb,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI;aAC5B,UAAU,EAAE;YACb,EAAE,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAkB,CAAC;QACjD,OAAO,mCAAe,CAAC,wBAAwB,CAC9C,UAAU,EACV,gBAAgB,EAChB,MAAM,CAAC,MAAM,CACb,CAAC;IACH,CAAC,CAAC;SACD,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAClB,iCAAc,CAAC,OAAO,CAA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,EAAE,GAAG,KAAK,EAAE;gBACpB,UAAU,EAAE,IAAI;aAChB,CAAC;QACH,CAAC;QAED,IAAI,yBAAE,CAAC,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7C,OAAO;gBACN,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAc;gBAC3C,IAAI,EAAE,yBAAE,CAAC,iBAAiB,CAAC,YAAY;gBACvC,aAAa,EAAE,QAAQ;gBACvB,QAAQ,EAAE,GAAG,KAAK,EAAE;gBACpB,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,IAAc;aACjD,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,CAAC,CAAC;IAElB,OAAO;QACN,kBAAkB,EAAE,KAAK;QACzB,kBAAkB,EAAE,IAAI;QACxB,uBAAuB,EAAE,IAAI;QAC7B,OAAO,EAAE,OAA4B;KACrC,CAAC;AACH,CAAC,CAAC;AA3DW,QAAA,wBAAwB,4BA2DnC"}
@@ -1,3 +1,16 @@
1
1
  import * as ts from "typescript/lib/tsserverlibrary";
2
2
  import type { NsLanguageService } from "../language-service/ns-language-service";
3
+ /**
4
+ * Generates semantic diagnostics for Nexus IoC dependency injection
5
+ *
6
+ * Analyzes @Injectable classes and their @Inject decorators to detect:
7
+ * - Missing dependencies (not provided in any module)
8
+ * - Type mismatches between injected and provided types
9
+ * - Services not connected to any module
10
+ * - Circular dependencies
11
+ *
12
+ * @param fileName - The source file to analyze
13
+ * @param tsNsLs - The Nexus IoC Language Service instance
14
+ * @returns Array of TypeScript diagnostics including original diagnostics and DI-specific errors
15
+ */
3
16
  export declare const getSemanticDiagnosticsActions: (fileName: string, tsNsLs: NsLanguageService) => ts.Diagnostic[];