forked from eclipse-embed-cdt/eclipse-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo_format_code.sh
executable file
·51 lines (44 loc) · 1.74 KB
/
do_format_code.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
###############################################################################
# Copyright (c) 2018, 2020 Kichwa Coders Ltd and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
###############################################################################
set -e
##
# This script is reused by other projects, if so, COREPROJECT should be set
# to the project to use a basis for project settings
##
: ${COREPROJECT:=plugins/org.eclipse.embedcdt.core}
if test -z "$(git status -s)"; then
echo "Tree looks clean - ready to start formatting!"
else
echo "Tree is dirty - code formatting can't run, see comment near the end of this script"
exit 1
fi
##
# Format code
##
: ${ECLIPSE:=~/buildtools/eclipse-SDK-4.13/eclipse}
if test -e check_code_cleanliness_workspace; then
echo check_code_cleanliness_workspace needs to be deleted
exit 1
fi
${ECLIPSE} \
-consolelog -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter \
-config $PWD/$COREPROJECT/.settings/org.eclipse.jdt.core.prefs \
$PWD -data check_code_cleanliness_workspace
rm -rf check_code_cleanliness_workspace
###
# The liqp and semver files maintain their code formatting. This isn't possible to enforce
# in any reasonable way with JDT settings, so instead after formatting, restore these
# files.
# This is why we have to start with a clean tree before formatting starts
##
git checkout -- plugins/org.eclipse.embedcdt.core/src/org/eclipse/embedcdt/core/liqp
git checkout -- plugins/org.eclipse.embedcdt.core/src/org/eclipse/embedcdt/core/zafarkhaja