Skip to content

Commit d155731

Browse files
PdeKeywords, reload only if need
1 parent 6621f62 commit d155731

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

app/src/processing/app/syntax/PdeKeywords.java

+25-3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public class PdeKeywords {
4545

4646
private static final Map<String, Integer> KNOWN_TOKEN_TYPES = new HashMap<>();
4747
private static final Pattern ALPHA = Pattern.compile("\\w");
48+
49+
private boolean needReload = true;
4850

4951
static {
5052
KNOWN_TOKEN_TYPES.put("RESERVED_WORD", TokenTypes.RESERVED_WORD);
@@ -99,6 +101,23 @@ public void reload() {
99101
Base.showError("Problem loading keywords", "Could not load keywords.txt,\nplease re-install Arduino.", e);
100102
System.exit(1);
101103
}
104+
105+
needReload = false;
106+
}
107+
108+
public boolean reloadIfNeed() {
109+
110+
if(needReload) {
111+
reload();
112+
return true;
113+
}else {
114+
return false;
115+
}
116+
117+
}
118+
119+
public void setNeedReload(boolean needReload) {
120+
this.needReload = needReload;
102121
}
103122

104123
private void parseKeywordsTxt(File input) throws Exception {
@@ -129,6 +148,7 @@ private void parseKeywordsTxt(File input) throws Exception {
129148
if (pieces.length >= 3) {
130149
parseHTMLReferenceFileName(pieces[2], keyword);
131150
}
151+
132152
if (pieces.length >= 4) {
133153
parseRSyntaxTextAreaTokenType(pieces[3], keyword);
134154
}
@@ -173,9 +193,11 @@ private void parseRSyntaxTextAreaTokenType(String tokenTypeAsString, String keyw
173193
}
174194

175195
private void parseHTMLReferenceFileName(String piece, String keyword) {
176-
String htmlFilename = piece.trim();
177-
if (htmlFilename.length() > 0) {
178-
keywordToReference.put(keyword, htmlFilename);
196+
if(piece != null && keyword != null && !piece.isEmpty()) {
197+
String htmlFilename = piece.trim();
198+
if (htmlFilename.length() > 0) {
199+
keywordToReference.put(keyword, htmlFilename);
200+
}
179201
}
180202
}
181203

0 commit comments

Comments
 (0)