public void updateEnvironment(IDocument document) {
String contents = document.get();
+ // Strip triple quoted strings from the contents since they may contain lines that look exactly like normal imports / includes
+ contents = contents.replaceAll("(?s)\"\"\".*?\"\"\"", "\"\"");
+ // Strip multiline comments since they may contain lines that look exactly like normal imports / includes
+ contents = contents.replaceAll("(?s)/\\*.*?\\*/", "");
+
String[] lines = contents.split("\\R+"); //$NON-NLS-1$
List<ImportDeclaration> imports = new ArrayList<>();
imports.add(new ImportDeclaration("StandardLibrary", "")); //$NON-NLS-1$ //$NON-NLS-2$
for (String line : lines) {
line = line.trim();
- if (line.startsWith("import") || line.startsWith("include")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (line.startsWith("import ") || line.startsWith("include ")) { //$NON-NLS-1$ //$NON-NLS-2$
SCLParserImpl parser = new SCLParserImpl(new StringReader(line));
try {
ImportDeclaration importDecl = (ImportDeclaration)parser.parseImport();