-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IEP-1277 Create .clang_format (#1022)
* feat: creating clang-format file
- Loading branch information
Showing
6 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/.clang-format-project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# We'll use defaults from the LLVM style, but with some modifications so that it's close to the CDT K&R style. | ||
BasedOnStyle: LLVM | ||
UseTab: Always | ||
IndentWidth: 4 | ||
TabWidth: 4 | ||
PackConstructorInitializers: NextLineOnly | ||
BreakConstructorInitializers: AfterColon | ||
IndentAccessModifiers: false | ||
AccessModifierOffset: -4 |
42 changes: 42 additions & 0 deletions
42
bundles/com.espressif.idf.core/src/com/espressif/idf/core/util/ClangFormatFileHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright 2024 Espressif Systems (Shanghai) PTE LTD. All rights reserved. | ||
* Use is subject to license terms. | ||
*******************************************************************************/ | ||
package com.espressif.idf.core.util; | ||
|
||
import java.io.IOException; | ||
|
||
import org.eclipse.core.resources.IFile; | ||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
|
||
import com.espressif.idf.core.ILSPConstants; | ||
|
||
public class ClangFormatFileHandler | ||
{ | ||
private final IFile clangFormatFile; | ||
|
||
public ClangFormatFileHandler(IProject project) throws CoreException | ||
{ | ||
this.clangFormatFile = project.getFile(ILSPConstants.CLANG_FORMAT_FILE); | ||
} | ||
|
||
/** | ||
* Updates the .clang-format file. If the file does not exist, it is created and initialized with default settings. | ||
* | ||
* @throws IOException if an I/O error occurs during file creation or writing | ||
* @throws CoreException if an error occurs while refreshing the project | ||
*/ | ||
public void update() throws IOException, CoreException | ||
{ | ||
if (clangFormatFile.exists()) | ||
{ | ||
return; | ||
} | ||
try (final var source = getClass().getResourceAsStream(".clang-format-project");) //$NON-NLS-1$ | ||
{ | ||
clangFormatFile.create(source, true, new NullProgressMonitor()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,5 +66,4 @@ public void updateLspQueryDrivers() | |
metadata.queryDriver().defaultValue()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters