fixed fromatter, plugin, site, libs for new language features
This commit is contained in:
1 parent
abb262d9cf
commit
1d9befe101
14 files changed
+218
-36
No files matched your search
+1
-1
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package net.sergeych.lyng.idea.completion
|
||||
|
||||
import LyngAstManager
|
||||
import com.intellij.codeInsight.completion.*
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder
|
||||
import com.intellij.icons.AllIcons
|
||||
@@ -36,6 +35,7 @@ import net.sergeych.lyng.idea.LyngLanguage
|
||||
import net.sergeych.lyng.idea.highlight.LyngTokenTypes
|
||||
import net.sergeych.lyng.idea.settings.LyngFormatterSettings
|
||||
import net.sergeych.lyng.idea.util.DocsBootstrap
|
||||
import net.sergeych.lyng.idea.util.LyngAstManager
|
||||
import net.sergeych.lyng.idea.util.TextCtx
|
||||
import net.sergeych.lyng.miniast.*
|
||||
|
||||
|
||||
@@ -85,7 +85,13 @@ class LyngEnterHandler : EnterHandlerDelegate {
|
||||
if (code == "}" || code == "*/") {
|
||||
// Adjust indent for the previous line if it's a block or comment closer
|
||||
val prevStart = doc.getLineStartOffset(prevLine)
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, prevStart)
|
||||
if (file.context == null) {
|
||||
try {
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, prevStart)
|
||||
} catch (e: Exception) {
|
||||
log.warn("Failed to adjust line indent for previous line: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback for previous line: manual application
|
||||
val desiredPrev = computeDesiredIndent(project, doc, prevLine)
|
||||
@@ -102,8 +108,13 @@ class LyngEnterHandler : EnterHandlerDelegate {
|
||||
}
|
||||
// Adjust indent for the current (new) line
|
||||
val currentStart = doc.getLineStartOffsetSafe(currentLine)
|
||||
val csm = CodeStyleManager.getInstance(project)
|
||||
csm.adjustLineIndent(file, currentStart)
|
||||
if (file.context == null) {
|
||||
try {
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, currentStart)
|
||||
} catch (e: Exception) {
|
||||
log.warn("Failed to adjust line indent for current line: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: if the platform didn't physically insert indentation, compute it from our formatter and apply
|
||||
val lineStart = doc.getLineStartOffset(currentLine)
|
||||
|
||||
@@ -58,7 +58,13 @@ class LyngTypedHandler : TypedHandlerDelegate() {
|
||||
}
|
||||
// After block reindent, adjust line indent to what platform thinks (no-op in many cases)
|
||||
val lineStart = doc.getLineStartOffset(line)
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, lineStart)
|
||||
if (file.context == null) {
|
||||
try {
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, lineStart)
|
||||
} catch (e: Exception) {
|
||||
log.warn("Failed to adjust line indent for current line: ${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (c == '/') {
|
||||
val doc = editor.document
|
||||
@@ -67,7 +73,13 @@ class LyngTypedHandler : TypedHandlerDelegate() {
|
||||
PsiDocumentManager.getInstance(project).commitDocument(doc)
|
||||
val line = doc.getLineNumber(offset - 1)
|
||||
val lineStart = doc.getLineStartOffset(line)
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, lineStart)
|
||||
if (file.context == null) {
|
||||
try {
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, lineStart)
|
||||
} catch (e: Exception) {
|
||||
log.warn("Failed to adjust line indent for comment: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
// Manual application fallback
|
||||
val desired = computeDesiredIndent(project, doc, line)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com
|
||||
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -80,7 +80,14 @@ class LyngPreFormatProcessor : PreFormatProcessor {
|
||||
val lineStart = doc.getLineStartOffset(line)
|
||||
// adjustLineIndent delegates to our LineIndentProvider which computes
|
||||
// indentation from scratch; this is safe and idempotent
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, lineStart)
|
||||
if (file.context == null) {
|
||||
try {
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, lineStart)
|
||||
} catch (e: Exception) {
|
||||
// Log as debug because this can be called many times during reformat
|
||||
// and we don't want to spam warnings if it's a known platform issue with injections
|
||||
}
|
||||
}
|
||||
|
||||
// After indentation, update block/paren/bracket balances using the current line text
|
||||
val lineEnd = doc.getLineEndOffset(line)
|
||||
|
||||
+1
-1
@@ -17,7 +17,6 @@
|
||||
|
||||
package net.sergeych.lyng.idea.navigation
|
||||
|
||||
import LyngAstManager
|
||||
import com.intellij.lang.cacheBuilder.DefaultWordsScanner
|
||||
import com.intellij.lang.cacheBuilder.WordsScanner
|
||||
import com.intellij.lang.findUsages.FindUsagesProvider
|
||||
@@ -26,6 +25,7 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.tree.TokenSet
|
||||
import net.sergeych.lyng.idea.highlight.LyngLexer
|
||||
import net.sergeych.lyng.idea.highlight.LyngTokenTypes
|
||||
import net.sergeych.lyng.idea.util.LyngAstManager
|
||||
import net.sergeych.lyng.miniast.DocLookupUtils
|
||||
|
||||
class LyngFindUsagesProvider : FindUsagesProvider {
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
package net.sergeych.lyng.idea.navigation
|
||||
|
||||
import LyngAstManager
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.ide.IconProvider
|
||||
import com.intellij.psi.PsiElement
|
||||
import net.sergeych.lyng.idea.util.LyngAstManager
|
||||
import net.sergeych.lyng.miniast.DocLookupUtils
|
||||
import javax.swing.Icon
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
package net.sergeych.lyng.idea.navigation
|
||||
|
||||
import LyngAstManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.search.FilenameIndex
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import net.sergeych.lyng.highlight.offsetOf
|
||||
import net.sergeych.lyng.idea.util.LyngAstManager
|
||||
import net.sergeych.lyng.idea.util.TextCtx
|
||||
import net.sergeych.lyng.miniast.*
|
||||
|
||||
|
||||
+1
-1
@@ -17,12 +17,12 @@
|
||||
|
||||
package net.sergeych.lyng.idea.navigation
|
||||
|
||||
import LyngAstManager
|
||||
import com.intellij.patterns.PlatformPatterns
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.util.ProcessingContext
|
||||
import net.sergeych.lyng.idea.LyngLanguage
|
||||
import net.sergeych.lyng.idea.highlight.LyngTokenTypes
|
||||
import net.sergeych.lyng.idea.util.LyngAstManager
|
||||
import net.sergeych.lyng.miniast.DocLookupUtils
|
||||
|
||||
class LyngPsiReferenceContributor : PsiReferenceContributor() {
|
||||
|
||||
@@ -15,23 +15,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
a/*
|
||||
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package net.sergeych.lyng.idea.util
|
||||
|
||||
import com.intellij.openapi.util.Key
|
||||
|
||||
Reference in new issue
Block a user