mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-21 15:54:39 +01:00
(Re-)implementing syntax highlighting support for library keywords.
This commit is contained in:
parent
f0c3263b2f
commit
59a85bfe59
@ -76,6 +76,8 @@ public class Base {
|
|||||||
static private File toolsFolder;
|
static private File toolsFolder;
|
||||||
static private File hardwareFolder;
|
static private File hardwareFolder;
|
||||||
|
|
||||||
|
static HashSet<File> libraries;
|
||||||
|
|
||||||
// maps imported packages to their library folder
|
// maps imported packages to their library folder
|
||||||
static HashMap<String, File> importToLibraryTable;
|
static HashMap<String, File> importToLibraryTable;
|
||||||
|
|
||||||
@ -963,6 +965,9 @@ public class Base {
|
|||||||
//System.out.println("rebuilding import menu");
|
//System.out.println("rebuilding import menu");
|
||||||
importMenu.removeAll();
|
importMenu.removeAll();
|
||||||
|
|
||||||
|
// reset the set of libraries
|
||||||
|
libraries = new HashSet<File>();
|
||||||
|
|
||||||
// reset the table mapping imports to libraries
|
// reset the table mapping imports to libraries
|
||||||
importToLibraryTable = new HashMap<String, File>();
|
importToLibraryTable = new HashMap<String, File>();
|
||||||
|
|
||||||
@ -1148,6 +1153,7 @@ public class Base {
|
|||||||
// // need to associate each import with a library folder
|
// // need to associate each import with a library folder
|
||||||
// String packages[] =
|
// String packages[] =
|
||||||
// Compiler.packageListFromClassPath(libraryClassPath);
|
// Compiler.packageListFromClassPath(libraryClassPath);
|
||||||
|
libraries.add(subfolder);
|
||||||
String packages[] = Compiler.headerListFromIncludePath(subfolder.getAbsolutePath());
|
String packages[] = Compiler.headerListFromIncludePath(subfolder.getAbsolutePath());
|
||||||
for (String pkg : packages) {
|
for (String pkg : packages) {
|
||||||
importToLibraryTable.put(pkg, subfolder);
|
importToLibraryTable.put(pkg, subfolder);
|
||||||
@ -1395,6 +1401,11 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static public Set<File> getLibraries() {
|
||||||
|
return libraries;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static public String getExamplesPath() {
|
static public String getExamplesPath() {
|
||||||
return examplesFolder.getAbsolutePath();
|
return examplesFolder.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,22 @@ public class PdeKeywords extends CTokenMarker {
|
|||||||
try {
|
try {
|
||||||
keywordColoring = new KeywordMap(false);
|
keywordColoring = new KeywordMap(false);
|
||||||
keywordToReference = new Hashtable();
|
keywordToReference = new Hashtable();
|
||||||
|
getKeywords(Base.getLibStream("keywords.txt"));
|
||||||
|
for (File lib : Base.getLibraries()) {
|
||||||
|
File keywords = new File(lib, "keywords.txt");
|
||||||
|
if (keywords.exists()) getKeywords(new FileInputStream(keywords));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Base.showError("Problem loading keywords",
|
||||||
|
"Could not load keywords.txt,\n" +
|
||||||
|
"please re-install Processing.", e);
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keywordColoring;
|
||||||
|
}
|
||||||
|
|
||||||
InputStream input = Base.getLibStream("keywords.txt");
|
static private void getKeywords(InputStream input) throws Exception {
|
||||||
InputStreamReader isr = new InputStreamReader(input);
|
InputStreamReader isr = new InputStreamReader(input);
|
||||||
BufferedReader reader = new BufferedReader(isr);
|
BufferedReader reader = new BufferedReader(isr);
|
||||||
|
|
||||||
@ -104,15 +118,6 @@ public class PdeKeywords extends CTokenMarker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
Base.showError("Problem loading keywords",
|
|
||||||
"Could not load keywords.txt,\n" +
|
|
||||||
"please re-install Processing.", e);
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return keywordColoring;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user