From: Hannu Niemistö Date: Wed, 26 Jul 2017 11:10:42 +0000 (+0300) Subject: (refs #7386) Minor SCL tools improvements X-Git-Tag: v1.31.0~264^2~25 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F68%2F768%2F3;p=simantics%2Fplatform.git (refs #7386) Minor SCL tools improvements * A new error type for failed imports that are shown only after other errors and have their own icon * Definition location for data type constructors * Improved content assist for nested namespaces Change-Id: Ie2a32f755a2487d8d969bb10c927b39e4d304165 --- diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/ComponentTypeScriptRequest.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/ComponentTypeScriptRequest.java index 53b601fa2..e5ae63935 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/ComponentTypeScriptRequest.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/ComponentTypeScriptRequest.java @@ -13,6 +13,7 @@ import org.simantics.db.request.Read; import org.simantics.scl.compiler.environment.LocalEnvironment; import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification; import org.simantics.scl.compiler.errors.CompilationError; +import org.simantics.scl.compiler.errors.ErrorSeverity; import org.simantics.scl.compiler.module.repository.ImportFailure; import org.simantics.scl.compiler.module.repository.ImportFailureException; import org.simantics.scl.compiler.runtime.RuntimeEnvironment; @@ -47,7 +48,7 @@ public class ComponentTypeScriptRequest implements Read errors = new ArrayList(); for (ImportFailure failure : cause.failures) { - errors.add(new CompilationError(0, failure.toString())); + errors.add(new CompilationError(0, failure.toString(), ErrorSeverity.IMPORT_ERROR)); } return new ComponentTypeScriptResult(errors, null); } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java index fccf26815..ff5ee3b29 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/Elaboration.java @@ -61,7 +61,9 @@ import org.simantics.scl.compiler.environment.AmbiguousNameException; import org.simantics.scl.compiler.environment.Environment; import org.simantics.scl.compiler.environment.EnvironmentFactory; import org.simantics.scl.compiler.environment.Environments; +import org.simantics.scl.compiler.errors.CompilationError; import org.simantics.scl.compiler.errors.ErrorLog; +import org.simantics.scl.compiler.errors.ErrorSeverity; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.internal.codegen.effects.EffectConstructor; import org.simantics.scl.compiler.internal.codegen.effects.ThreadLocalVariable; @@ -179,7 +181,7 @@ public class Elaboration { compilationContext.environment = new EnvironmentOfModule(importedEnvironment, module); } catch (ImportFailureException e) { for(ImportFailure failure : e.failures) - errorLog.log(failure.location, failure.toString()); + errorLog.log(new CompilationError(failure.location, failure.toString(), ErrorSeverity.IMPORT_ERROR)); return; } for(ImportDeclaration importAst : importsAst) @@ -1113,6 +1115,7 @@ public class Elaboration { int constructorTag = 0; for(Constructor constructor : dataType.constructors) { SCLValue value = new SCLValue(constructor.name); + value.definitionLocation = constructor.loc; SCLConstructor sclConstructor = new SCLConstructor( constructor.name.name, diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/Environments.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/Environments.java index 3be214d2d..2ce0ced5b 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/Environments.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/environment/Environments.java @@ -241,6 +241,8 @@ public class Environments { Namespace childNamespace = namespace.getNamespace(prefix.substring(0, p)); if(childNamespace != null) findValuesForPrefix(childNamespace, prefix.substring(p+1), proc); + else + namespace.findValuesForPrefix(prefix, AcceptAllNamespaceFilter.INSTANCE, proc); } else namespace.findValuesForPrefix(prefix, AcceptAllNamespaceFilter.INSTANCE, proc); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorLog.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorLog.java index 62d5d8c3d..0e61a1644 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorLog.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorLog.java @@ -16,7 +16,7 @@ public class ErrorLog { public void log(CompilationError error) { errors.add(error); - if(error.severity == ErrorSeverity.ERROR) + if(error.severity != ErrorSeverity.WARNING) ++errorCount; } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorSeverity.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorSeverity.java index 9f65cb3e8..101e0f9e5 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorSeverity.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/ErrorSeverity.java @@ -1,6 +1,7 @@ package org.simantics.scl.compiler.errors; public enum ErrorSeverity { - ERROR, - WARNING + ERROR, + IMPORT_ERROR, + WARNING } diff --git a/bundles/org.simantics.scl.ui/icons/import_error.png b/bundles/org.simantics.scl.ui/icons/import_error.png new file mode 100644 index 000000000..caa1838d7 Binary files /dev/null and b/bundles/org.simantics.scl.ui/icons/import_error.png differ diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/Activator.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/Activator.java index a408e7f30..768682fa3 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/Activator.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/Activator.java @@ -33,6 +33,7 @@ public class Activator extends AbstractUIPlugin { reg.put("find", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/find.png") ); reg.put("disk", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/disk.png") ); reg.put("error", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/error.png") ); + reg.put("import_error", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/import_error.png") ); reg.put("warning", Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/warning.png") ); } diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/completion/SCLCompletionProposal.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/completion/SCLCompletionProposal.java index 4c429e7fd..11749a4b2 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/completion/SCLCompletionProposal.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/completion/SCLCompletionProposal.java @@ -37,8 +37,15 @@ public class SCLCompletionProposal implements ICompletionProposal, ICompletionPr private final SCLCompletionType completionType; public SCLCompletionProposal(SCLValue value, int replacementOffset, String prefix) { - this.name = value.getName().name; - this.module = value.getName().module; + String tempName = value.getName().name; + String tempModule = value.getName().module; + int p = tempName.lastIndexOf('.'); + if(p >= 0) { + tempModule = tempModule + "." + tempName.substring(0, p); + tempName = tempName.substring(p+1); + } + this.name = tempName; + this.module = tempModule; this.documentation = value.getDocumentation(); this.content = name + " :: " + value.getType() + " (" + module + ")"; this.replacementOffset = replacementOffset; diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenDeclaration.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenDeclaration.java index 4b6818ab7..378840397 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenDeclaration.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor2/OpenDeclaration.java @@ -9,6 +9,7 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PlatformUI; import org.simantics.scl.compiler.elaboration.modules.SCLValue; +import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.module.InvalidModulePathException; import org.simantics.scl.compiler.module.ModuleUtils; import org.simantics.scl.compiler.source.ModuleSource; @@ -106,6 +107,7 @@ public class OpenDeclaration extends AbstractHandler { SCLTextEditorEnvironment editorEnvironment = moduleEditor.getSCLTextEditorEnvironment(); editorEnvironment.updateEnvironment(moduleEditor.getDocument()); SCLValue value = editorEnvironment.getValue(identifierAtCaret); + System.out.println("identifierAtCaret = " + identifierAtCaret + " [" + Locations.beginOf(value.definitionLocation) + ", " + Locations.endOf(value.definitionLocation) + "]"); if(value != null) OpenSCLDefinition.openDefinition(value); } diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/issues/SCLIssuesView.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/issues/SCLIssuesView.java index b4fd1edd8..3e0cc3120 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/issues/SCLIssuesView.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/issues/SCLIssuesView.java @@ -90,6 +90,8 @@ public class SCLIssuesView extends ViewPart { SCLIssuesTableEntry entry = (SCLIssuesTableEntry)element; return entry.error.severity == ErrorSeverity.ERROR ? imageRegistry.get("error") + : entry.error.severity == ErrorSeverity.IMPORT_ERROR + ? imageRegistry.get("import_error") : imageRegistry.get("warning"); } });