mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CPP-16244 Macro replacement in documentation is not working when ClangFormat is enabled
- return CF formatting procedure for virtual files (`ClangdLanguageService`) - modify the procedure of formatted range detection, based on incoming range (`ClangDaemonFormatProvider`) - better support for psi-element formatting procedure, that can fix psi-tree merging artifacts (`ExternalFormatProcessor`) - more accurate surrounder implementation with error processing (`OCWithCastSurrounder`) - fix `conserve global settings` error in the tests (`ClangFormatHelper`) GitOrigin-RevId: 0a3d69015d48bed1c3bda6618142f48b2010a3d4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
964925647e
commit
898d0bd5f3
@@ -4,9 +4,9 @@ package com.intellij.psi.codeStyle;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -93,7 +93,14 @@ public interface ExternalFormatProcessor {
|
||||
PsiDocumentManager.getInstance(file.getProject()).commitDocument(document);
|
||||
if (!elementToFormat.isValid()) {
|
||||
final PsiElement elementAtStart = file.findElementAt(rangeAfterFormat.getStartOffset());
|
||||
final PsiElement elementAtEnd = file.findElementAt(rangeAfterFormat.getEndOffset() - 1);
|
||||
if (elementAtStart != null) {
|
||||
if (elementAtEnd != null) {
|
||||
PsiElement parent = PsiTreeUtil.findCommonParent(elementAtStart, elementAtEnd);
|
||||
if (parent != null) {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
return elementAtStart;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user