Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
make "invalid @apply" quick fix work in mixed-language documents
Brad Cornes <bradlc41@gmail.com>
4 years ago
1 changed files, 95 additions(+), 64 deletions(-)
M src/lsp/providers/codeActionProvider/index.ts -> src/lsp/providers/codeActionProvider/index.ts
diff --git a/src/lsp/providers/codeActionProvider/index.ts b/src/lsp/providers/codeActionProvider/index.ts
index 6ae4bf984ee3310f28f8a627347c6b54b8ad140c..62bdb128c3e49cf2cd5895a14dff8cfa7064aef1 100644
--- a/src/lsp/providers/codeActionProvider/index.ts
+++ b/src/lsp/providers/codeActionProvider/index.ts
@@ -6,7 +6,6 @@   Range,
   TextEdit,
 } from 'vscode-languageserver'
 import { State } from '../../util/state'
-import { findLast } from '../../util/find'
 import { isWithinRange } from '../../util/isWithinRange'
 import { getClassNameParts } from '../../util/getClassNameAtPosition'
 const dlv = require('dlv')
@@ -31,6 +30,9 @@   isInvalidVariantDiagnostic,
 } from '../diagnostics/types'
 import { flatten, dedupeBy } from '../../../util/array'
 import { joinWithAnd } from '../../util/joinWithAnd'
+import { getLanguageBoundaries } from '../../util/getLanguageBoundaries'
+import { isCssDoc } from '../../util/css'
+import { absoluteRange } from '../../util/absoluteRange'
 
 async function getDiagnosticsFromCodeActionParams(
   state: State,
@@ -210,6 +212,8 @@   diagnostic: InvalidApplyDiagnostic
 ): Promise<CodeAction[]> {
   let document = state.editor.documents.get(params.textDocument.uri)
   let documentText = document.getText()
+  let cssRange: Range
+  let cssText = documentText
   const { postcss } = state.modules
   let change: TextEdit
 
@@ -217,92 +221,107 @@   let totalClassNamesInClassList = diagnostic.className.classList.classList.split(
     /\s+/
   ).length
 
-import isObject from '../../../util/isObject'
+  if (!isCssDoc(state, document)) {
+    let languageBoundaries = getLanguageBoundaries(state, document)
+  CodeAction,
   TextEdit,
+  isInvalidConfigPathDiagnostic,
 import {
-        title: `Replace with '${suggestion}'`,
-      return (root) => {
+      isWithinRange(diagnostic.range.start, range)
-        root.walkRules((rule) => {
+    )
+    if (!cssRange) return []
+    cssText = document.getText(cssRange)
 import {
-import { State } from '../../util/state'
+  CodeActionKind,
 
-import {
+  try {
+    await postcss([
+  isInvalidConfigPathDiagnostic,
 import { State } from '../../util/state'
-import {
+        return (root) => {
+          root.walkRules((rule) => {
+  isInvalidTailwindDirectiveDiagnostic,
 import {
-import { State } from '../../util/state'
+
+  isInvalidTailwindDirectiveDiagnostic,
   CodeAction,
-import { getDiagnostics } from '../diagnostics/diagnosticsProvider'
+  isInvalidTailwindDirectiveDiagnostic,
   CodeActionParams,
-import { getDiagnostics } from '../diagnostics/diagnosticsProvider'
+  isInvalidTailwindDirectiveDiagnostic,
   CodeActionKind,
+  isInvalidApplyDiagnostic,
 import {
-import { State } from '../../util/state'
+  isInvalidTailwindDirectiveDiagnostic,
   Range,
-import { getDiagnostics } from '../diagnostics/diagnosticsProvider'
+  isInvalidTailwindDirectiveDiagnostic,
   TextEdit,
-              },
+                },
+  CodeAction,
 import {
-import { State } from '../../util/state'
+  Range,
+  isInvalidTailwindDirectiveDiagnostic,
 } from 'vscode-languageserver'
-import { getDiagnostics } from '../diagnostics/diagnosticsProvider'
+  isInvalidTailwindDirectiveDiagnostic,
 import { State } from '../../util/state'
+  CodeAction,
 import {
-import { State } from '../../util/state'
+  CodeActionKind,
+  isInvalidTailwindDirectiveDiagnostic,
 import { findLast } from '../../util/find'
+  CodeAction,
 import { State } from '../../util/state'
-  TextEdit,
+  isInvalidScreenDiagnostic,
 import {
+  isInvalidTailwindDirectiveDiagnostic,
 import { findLast } from '../../util/find'
 
-            if (!isWithinRange(diagnostic.range.start, range)) {
+              if (!isWithinRange(diagnostic.range.start, atRuleRange)) {
-import { rangesEqual } from '../../util/rangesEqual'
   CodeAction,
+              {
-              return true
+                return true
-import {
+  isInvalidTailwindDirectiveDiagnostic,
 import { findLast } from '../../util/find'
 
-            let className = document.getText(diagnostic.range)
-import { rangesEqual } from '../../util/rangesEqual'
+  isInvalidScreenDiagnostic,
   Range,
-import { rangesEqual } from '../../util/rangesEqual'
+  isInvalidScreenDiagnostic,
   TextEdit,
-import { rangesEqual } from '../../util/rangesEqual'
+  isInvalidScreenDiagnostic,
 } from 'vscode-languageserver'
-import { rangesEqual } from '../../util/rangesEqual'
+  isInvalidScreenDiagnostic,
 import { State } from '../../util/state'
-import {
+  isInvalidScreenDiagnostic,
 import { findLast } from '../../util/find'
+  CodeAction,
 import { findLast } from '../../util/find'
   CodeAction,
+    return []
 
   CodeAction,
-import {
+  })
   CodeAction,
-  CodeAction,
+  return Promise.all(actions)
-import {
+  isInvalidTailwindDirectiveDiagnostic,
 import { findLast } from '../../util/find'
 
   CodeAction,
-  CodeActionParams,
+    .then(flatten)
   CodeAction,
-  CodeActionKind,
+    .then((x) => dedupeBy(x, (item) => JSON.stringify(item.edit)))
 
   CodeAction,
-  Range,
+function classNameToAst(
   CodeAction,
-  TextEdit,
+  className: string,
-import {
+  isInvalidTailwindDirectiveDiagnostic,
 import { findLast } from '../../util/find'
 
   CodeAction,
-} from 'vscode-languageserver'
+  selector: string = `.${className}`,
   CodeAction,
-import { State } from '../../util/state'
+  important: boolean = false
 
-  CodeAction,
+  CodeActionParams,
-import { findLast } from '../../util/find'
-  isInvalidApplyDiagnostic,
                 start: {
                   line: rule.source.start.line - 1,
                   character: rule.source.start.column - 1,
@@ -306,61 +327,73 @@                 end: {
                   line: rule.source.end.line - 1,
                   character: rule.source.end.column,
                 },
-              },
   CodeAction,
-import { getDiagnostics } from '../diagnostics/diagnosticsProvider'
-  isInvalidApplyDiagnostic,
+} from 'vscode-languageserver'
 import { findLast } from '../../util/find'
   CodeAction,
-  CodeAction,
+import { State } from '../../util/state'
-  AugmentedDiagnostic,
+} from '../diagnostics/types'
 import {
   CodeAction,
-  AugmentedDiagnostic,
+        diagnostics: [diagnostic],
-  AugmentedDiagnostic,
+  CodeActionParams,
   CodeActionParams,
+} from '../diagnostics/types'
   CodeAction,
-  CodeAction,
+                range: ruleRange,
+} from '../diagnostics/types'
   CodeActionKind,
-  AugmentedDiagnostic,
+} from '../diagnostics/types'
   Range,
-  AugmentedDiagnostic,
+} from '../diagnostics/types'
   TextEdit,
-  AugmentedDiagnostic,
+} from '../diagnostics/types'
 } from 'vscode-languageserver'
-  AugmentedDiagnostic,
+} from '../diagnostics/types'
 import { State } from '../../util/state'
-  AugmentedDiagnostic,
+} from '../diagnostics/types'
 import { findLast } from '../../util/find'
-  CodeAction,
   CodeActionParams,
+import {
-  CodeAction,
   CodeActionParams,
+import {
 import {
-  CodeAction,
   CodeActionParams,
+import {
   CodeAction,
+  CodeActionParams,
 import {
-      }))
+  CodeActionParams,
   CodeActionParams,
+import { removeRangesFromString } from '../../util/removeRangesFromString'
   CodeActionParams,
+import detectIndent from 'detect-indent'
-  CodeAction,
   CodeActionParams,
+import { cssObjToAst } from '../../util/cssObjToAst'
   CodeActionParams,
+import isObject from '../../../util/isObject'
+                    }),
   CodeAction,
+        diagnostics: [diagnostic],
+  CodeActionParams,
   CodeActionParams,
-  CodeActionKind,
   CodeAction,
+  CodeAction,
   CodeActionParams,
-  Range,
+import { rangesEqual } from '../../util/rangesEqual'
   InvalidApplyDiagnostic,
-  TextEdit,
+  CodeActionKind,
+  CodeActionParams,
   CodeAction,
   CodeActionParams,
-} from 'vscode-languageserver'
+  isInvalidApplyDiagnostic,
+  CodeActionParams,
   CodeAction,
+  CodeAction,
   CodeActionParams,
-import { State } from '../../util/state'
+  InvalidApplyDiagnostic,
+    return []
+  }
 
   if (!change) {
     return []