public void updateEnvironment(IDocument document) {
String contents = document.get();
- String[] lines = contents.split("\\R+");
+ // 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", ""));
+ 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")) {
+ 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();
List<SCLCompletionProposal> proposals = new ArrayList<>();
for(SCLValue value : Environments.findValuesForPrefix(env, prefix)) {
Name name = value.getName();
- if((name.module.equals(moduleName) || !value.isPrivate()) && !(name.name.contains("$") && Character.isLetter(name.name.charAt(0))))
+ if((name.module.equals(moduleName) || !value.isPrivate()) && !(name.name.contains("$") && Character.isLetter(name.name.charAt(0)))) //$NON-NLS-1$
proposals.add(new SCLCompletionProposal(value, offset - lastPart.length(), lastPart));
}
for(TCon type : Environments.findTypesForPrefix(env, prefix)) {
proposals.add(new SCLCompletionProposal(type.name, type.module, SCLCompletionType.TYPE, offset - lastPart.length(), lastPart));
}
- if(!prefix.contains(".")) {
+ if(!prefix.contains(".")) { //$NON-NLS-1$
for (ImportDeclaration decl : cachedImports) {
if (decl.localName != null && !decl.localName.isEmpty() && decl.localName.toLowerCase().startsWith(prefix.toLowerCase())) {
proposals.add(new SCLCompletionProposal(decl.localName, decl.moduleName, SCLCompletionType.CONST, offset - prefix.length(), prefix));
try {
String absoluteModuleName = ModuleUtils.resolveAbsolutePath(moduleName, relativeImport.moduleName);
absoluteImports.add(new ImportDeclaration(
+ relativeImport.location,
absoluteModuleName, relativeImport.localName,
relativeImport.reexport, relativeImport.spec));
} catch (InvalidModulePathException e) {