From 48e460d78faef0cdbfcf8ba5941a4e1b2dfa0074 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Tue, 27 Aug 2019 16:25:53 -0700 Subject: [PATCH 01/17] No classloading in TypeUtil.isMap method See: https://www.pivotaltracker.com/story/show/167917595 --- .../vscode/boot/metadata/PropertyInfo.java | 2 +- .../vscode/boot/metadata/types/TypeUtil.java | 45 ++++++++++++++++--- .../reconcile/PropertyNavigator.java | 2 +- .../ApplicationYamlAssistContext.java | 6 +-- .../ApplicationYamlASTReconciler.java | 2 +- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java index 2ab911d7c..f0a64da2a 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java @@ -145,7 +145,7 @@ public class PropertyInfo { public HintProvider getHints(TypeUtil typeUtil) { Type type = TypeParser.parse(this.type); - if (TypeUtil.isMap(type)) { + if (typeUtil.isMap(type)) { return HintProviders.forMap(keyHints(typeUtil), valueHints(typeUtil), TypeUtil.getDomainType(type)); } else if (TypeUtil.isSequencable(type)) { return HintProviders.forAllValueContexts(valueHints(typeUtil)); diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java index 9bf3614e1..0fc570aa5 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java @@ -485,7 +485,7 @@ public class TypeUtil { return type!=null && type.getErasure().endsWith("[]"); } - public static boolean isMap(Type type) { + public boolean isMap(Type type) { //Note: to be really correct we should use JDT infrastructure to resolve //type in project classpath instead of using Java reflection. //However, use reflection here is okay assuming types we care about @@ -493,9 +493,14 @@ public class TypeUtil { //also potentialy be very slow. if (type!=null) { String erasure = type.getErasure(); + if ("java.util.Map".equals(erasure)) { + //quick / easy case. No looking for types and hierarchies required. + return true; + } try { - Class erasureClass = Class.forName(erasure); - return Map.class.isAssignableFrom(erasureClass); + IType mapType = findType("java.util.Map"); + IType erasureType = findType(erasure); + return isAssignableFrom(mapType, erasureType); } catch (Exception e) { //type not resolveable } @@ -503,6 +508,36 @@ public class TypeUtil { return false; } + private boolean isAssignableFrom(IType mapType, IType erasureType) { + Set seen = new HashSet<>(); + return searchSuperTypes(seen, erasureType, mapType.getFullyQualifiedName()); + } + + + private boolean searchSuperTypes(Set seen, IType searchIn, String fqTargetType) { + if (searchIn!=null) { + String fqName = searchIn.getFullyQualifiedName(); + if (fqName.equals(fqTargetType)) { + return true; + } + if (seen.add(fqName)) { + for (String itfName : searchIn.getSuperInterfaceNames()) { + IType itf = findType(itfName); + if (searchSuperTypes(seen, itf, fqTargetType)) { + return true; + } + } + String klassName = searchIn.getSuperclassName(); + IType klass = findType(klassName); + if (searchSuperTypes(seen, klass, fqTargetType)) { + return true; + } + } + } + return false; + } + + /** * Get domain type for a map or list generic type. */ @@ -966,9 +1001,9 @@ public class TypeUtil { * List>> -> 2 * Map<*,List> -> 2 */ - public static int getDimensionality(Type type) { + public int getDimensionality(Type type) { int dim = 0; - while (isSequencable(type) || isMap(type)) { + while (isSequencable(type) || this.isMap(type)) { dim++; type = getDomainType(type); } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/PropertyNavigator.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/PropertyNavigator.java index ceaea9e6d..2fc448410 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/PropertyNavigator.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/PropertyNavigator.java @@ -163,7 +163,7 @@ public class PropertyNavigator { * checked to be 'dotable'. */ private Type dotNavigate(int offset, Type type) { - if (TypeUtil.isMap(type)) { + if (typeUtil.isMap(type)) { int keyStart = offset+1; Type domainType = TypeUtil.getDomainType(type); int keyEnd = -1; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java index 05d020d69..a1c8c953c 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java @@ -116,7 +116,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon protected String appendTextFor(Type type) { //Note that proper indentation after each \n" is added automatically //so the strings created here do not need to contain indentation spaces - if (TypeUtil.isMap(type)) { + if (typeUtil.isMap(type)) { //ready to enter nested map key on next line return "\n"+YamlIndentUtil.INDENT_STR; } if (TypeUtil.isSequencable(type)) { @@ -328,7 +328,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon @Override public YamlAssistContext traverse(YamlPathSegment s) { if (s.getType()==YamlPathSegmentType.VAL_AT_KEY) { - if (TypeUtil.isSequencable(type) || TypeUtil.isMap(type)) { + if (TypeUtil.isSequencable(type) || typeUtil.isMap(type)) { return contextWith(s, TypeUtil.getDomainType(type)); } String key = s.toPropString(); @@ -632,7 +632,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon private static List getAllJavaElements(TypeUtil typeUtil, Type parentType, String propName) { if (propName!=null) { Type beanType = parentType; - if (TypeUtil.isMap(beanType)) { + if (typeUtil.isMap(beanType)) { Type keyType = typeUtil.getKeyType(beanType); if (keyType!=null && typeUtil.isEnum(keyType)) { IField field = typeUtil.getEnumConstant(keyType, propName); diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java index 8b7c48250..fc1467aa9 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java @@ -224,7 +224,7 @@ public class ApplicationYamlASTReconciler implements YamlASTReconciler { checkForDuplicateKeys(mapping); if (typeUtil.isAtomic(type)) { expectTypeFoundMapping(type, mapping); - } else if (TypeUtil.isMap(type) || TypeUtil.isSequencable(type)) { + } else if (typeUtil.isMap(type) || TypeUtil.isSequencable(type)) { Type keyType = typeUtil.getKeyType(type); Type valueType = TypeUtil.getDomainType(type); if (keyType!=null) { From 28dc41d88b902d3c6e708e62f20fbd9a12e45bef Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Mon, 2 Sep 2019 11:02:31 +0200 Subject: [PATCH 02/17] updates to latest stable 2019-09 orbit p2 repo --- eclipse-distribution/pom.xml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/eclipse-distribution/pom.xml b/eclipse-distribution/pom.xml index 1cf604c5a..83cbd727a 100644 --- a/eclipse-distribution/pom.xml +++ b/eclipse-distribution/pom.xml @@ -409,20 +409,10 @@ https://download.eclipse.org/staging/2019-09/ - 2019-09-platform-i-builds - p2 - https://download.eclipse.org/eclipse/updates/4.13-I-builds/ - - - orbit-i-build - p2 - https://download.eclipse.org/tools/orbit/downloads/drops/I20190812210208/repository - - + https://download.eclipse.org/tools/orbit/downloads/drops/S20190827152740/repository + latest-m2e p2 From 29bd645967b179a3890f95ec17fb9d7614796cdf Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Mon, 2 Sep 2019 11:02:54 +0200 Subject: [PATCH 03/17] first steps towards including wild web developer feature --- .../org.springframework.boot.ide.product | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product b/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product index 0973bd51f..f82609b5a 100644 --- a/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product +++ b/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product @@ -70,14 +70,21 @@ - - - + + + + + + + + + + From b23478248fa22fb0e7697544f1951a82113e8f84 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Wed, 4 Sep 2019 16:18:54 -0700 Subject: [PATCH 04/17] Avoid classloading in TypeUtil.isCollection Use type information from project classpath index instead. --- .../boot/common/CommonLanguageTools.java | 2 +- .../vscode/boot/metadata/PropertyInfo.java | 2 +- .../vscode/boot/metadata/types/TypeUtil.java | 60 +++++++++---------- ...opertiesCompletionProposalsCalculator.java | 2 +- .../hover/PropertiesHoverCalculator.java | 9 +-- .../reconcile/PropertyNavigator.java | 6 +- .../ApplicationYamlAssistContext.java | 6 +- .../ApplicationYamlASTReconciler.java | 4 +- 8 files changed, 44 insertions(+), 47 deletions(-) diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/CommonLanguageTools.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/CommonLanguageTools.java index 9217745c0..efc8720b8 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/CommonLanguageTools.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/CommonLanguageTools.java @@ -70,7 +70,7 @@ public class CommonLanguageTools { public static Collection getValueHints(FuzzyMap index, TypeUtil typeUtil, String query, String propertyName, EnumCaseMode caseMode) { Type type = getValueType(index, typeUtil, propertyName); - if (TypeUtil.isSequencable(type)) { + if (typeUtil.isSequencable(type)) { //It is useful to provide content assist for the values in the list when entering a list type = TypeUtil.getDomainType(type); } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java index f0a64da2a..ef72d0db3 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java @@ -147,7 +147,7 @@ public class PropertyInfo { Type type = TypeParser.parse(this.type); if (typeUtil.isMap(type)) { return HintProviders.forMap(keyHints(typeUtil), valueHints(typeUtil), TypeUtil.getDomainType(type)); - } else if (TypeUtil.isSequencable(type)) { + } else if (typeUtil.isSequencable(type)) { return HintProviders.forAllValueContexts(valueHints(typeUtil)); } else { return HintProviders.forHere(valueHints(typeUtil)); diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java index 0fc570aa5..00e3e84f6 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java @@ -99,6 +99,9 @@ public class TypeUtil { private static final Object OBJECT_TYPE_NAME = Object.class.getName(); private static final String STRING_TYPE_NAME = String.class.getName(); + private static final String MAP_TYPE_NAME = Map.class.getName(); + private static final String SET_TYPE_NAME = Set.class.getName(); + private static final String LIST_TYPE_NAME = List.class.getName(); private static final String INET_ADDRESS_TYPE_NAME = InetAddress.class.getName(); private static final String DURATION_TYPE_NAME = Duration.class.getName(); private static final String CLASS_TYPE_NAME = Class.class.getName(); @@ -443,7 +446,7 @@ public class TypeUtil { * use the notation []= in property file * for properties of this type. */ - public static boolean isBracketable(Type type) { + public boolean isBracketable(Type type) { //Note array types where once not considered 'Bracketable' //see: STS-4031 @@ -452,32 +455,13 @@ public class TypeUtil { //This is actually more logical too. //So '[' notation in props file can be used for either list or arrays (at least in recent versions of boot). //Note also 'Set' are now considered bracketable. See: https://www.pivotaltracker.com/story/show/154644992 - return isArray(type) || isCollection(List.class, type) || isCollection(Set.class, type); - } - - @SuppressWarnings("rawtypes") - private static boolean isCollection( Class klass, Type type) { - //Note: to be really correct we should use JDT infrastructure to resolve - //type in project classpath instead of using Java reflection. - //However, use reflection here is okay assuming types we care about - //are part of JRE standard libraries. Using eclipse 'type hirearchy' would - //also potentialy be very slow. - if (type!=null) { - String erasure = type.getErasure(); - try { - Class erasureClass = Class.forName(erasure); - return klass.isAssignableFrom(erasureClass); - } catch (Exception e) { - //type not resolveable assume its not 'array like' - } - } - return false; + return isArray(type) || isCollection(LIST_TYPE_NAME, type) || isCollection(SET_TYPE_NAME, type); } /** * Check if type can be treated / represented as a sequence node in .yml file */ - public static boolean isSequencable(Type type) { + public boolean isSequencable(Type type) { return isBracketable(type); } @@ -486,21 +470,15 @@ public class TypeUtil { } public boolean isMap(Type type) { - //Note: to be really correct we should use JDT infrastructure to resolve - //type in project classpath instead of using Java reflection. - //However, use reflection here is okay assuming types we care about - //are part of JRE standard libraries. Using eclipse 'type hirearchy' would - //also potentialy be very slow. if (type!=null) { String erasure = type.getErasure(); - if ("java.util.Map".equals(erasure)) { + if (MAP_TYPE_NAME.equals(erasure)) { //quick / easy case. No looking for types and hierarchies required. return true; } try { - IType mapType = findType("java.util.Map"); IType erasureType = findType(erasure); - return isAssignableFrom(mapType, erasureType); + return isAssignableFrom(MAP_TYPE_NAME, erasureType); } catch (Exception e) { //type not resolveable } @@ -508,9 +486,27 @@ public class TypeUtil { return false; } - private boolean isAssignableFrom(IType mapType, IType erasureType) { + private boolean isCollection(String collectionTypeName, Type type) { + if (type!=null) { + String erasure = type.getErasure(); + if (collectionTypeName.equals(erasure)) { + //quick / easy case. No looking for types and hierarchies required. + return true; + } + try { + IType erasureType = findType(erasure); + return isAssignableFrom(collectionTypeName, erasureType); + } catch (Exception e) { + //type not resolveable + } + } + return false; + } + + + private boolean isAssignableFrom(String superTypeName, IType erasureType) { Set seen = new HashSet<>(); - return searchSuperTypes(seen, erasureType, mapType.getFullyQualifiedName()); + return searchSuperTypes(seen, erasureType, superTypeName); } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/completions/PropertiesCompletionProposalsCalculator.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/completions/PropertiesCompletionProposalsCalculator.java index 45ce88d9f..aa79e4ea6 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/completions/PropertiesCompletionProposalsCalculator.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/completions/PropertiesCompletionProposalsCalculator.java @@ -264,7 +264,7 @@ public class PropertiesCompletionProposalsCalculator { if (type!=null) { if (typeUtil.isAssignableType(type)) { postfix = "="; - } else if (TypeUtil.isBracketable(type)) { + } else if (typeUtil.isBracketable(type)) { postfix = "["; } else if (typeUtil.isDotable(type)) { postfix = "."; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/hover/PropertiesHoverCalculator.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/hover/PropertiesHoverCalculator.java index 76f330b39..004219db0 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/hover/PropertiesHoverCalculator.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/hover/PropertiesHoverCalculator.java @@ -77,22 +77,23 @@ class PropertiesHoverCalculator { if (valueRegion.getStart() <= propertyFinder.offset && propertyFinder.offset < valueRegion.getEnd()) { String valueString = valueRegion.toString(); String propertyName = value.getParent().getKey().decode(); - Type type = getValueType(propertyFinder.index, propertyFinder.typeUtil, propertyName); - if (TypeUtil.isSequencable(type)) { + TypeUtil typeUtil = propertyFinder.typeUtil; + Type type = getValueType(propertyFinder.index, typeUtil, propertyName); + if (typeUtil.isSequencable(type)) { //It is useful to provide content assist for the values in the list when entering a list type = TypeUtil.getDomainType(type); } if (TypeUtil.isClass(type)) { //Special case. We want to provide hoverinfos more liberally than what's suggested for completions (i.e. even class names //that are not suggested by the hints because they do not meet subtyping constraints should be hoverable and linkable! - StsValueHint hint = StsValueHint.className(valueString, propertyFinder.typeUtil); + StsValueHint hint = StsValueHint.className(valueString, typeUtil); if (hint!=null) { return Tuples.of(createRenderable(hint), valueRegion.asRegion()); } } //Hack: pretend to invoke content-assist at the end of the value text. This should provide hints applicable to that value // then show hoverinfo based on that. That way we can avoid duplication a lot of similar logic to compute hoverinfos and hyperlinks. - Collection hints = getValueHints(propertyFinder.index, propertyFinder.typeUtil, valueString, propertyName, EnumCaseMode.ALIASED); + Collection hints = getValueHints(propertyFinder.index, typeUtil, valueString, propertyName, EnumCaseMode.ALIASED); if (hints!=null) { Optional hint = hints.stream().filter(h -> valueString.equals(h.getValue())).findFirst(); if (hint.isPresent()) { diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/PropertyNavigator.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/PropertyNavigator.java index 2fc448410..fb1c159c0 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/PropertyNavigator.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/reconcile/PropertyNavigator.java @@ -11,16 +11,16 @@ package org.springframework.ide.vscode.boot.properties.reconcile; -import static org.springframework.ide.vscode.boot.metadata.types.TypeUtil.isBracketable; import static org.springframework.ide.vscode.boot.properties.reconcile.SpringPropertyProblem.problem; import java.util.List; import org.springframework.ide.vscode.boot.metadata.types.Type; import org.springframework.ide.vscode.boot.metadata.types.TypeUtil; -import org.springframework.ide.vscode.boot.metadata.types.TypedProperty; import org.springframework.ide.vscode.boot.metadata.types.TypeUtil.BeanPropertyNameMode; import org.springframework.ide.vscode.boot.metadata.types.TypeUtil.EnumCaseMode; +import org.springframework.ide.vscode.boot.metadata.types.TypedProperty; +import org.springframework.ide.vscode.boot.properties.completions.SpringPropertiesCompletionEngine; import org.springframework.ide.vscode.commons.languageserver.reconcile.IProblemCollector; import org.springframework.ide.vscode.commons.languageserver.reconcile.ReconcileProblem; import org.springframework.ide.vscode.commons.util.BadLocationException; @@ -87,7 +87,7 @@ public class PropertyNavigator { offset, region.getEnd()-offset)); } } else if (navOp=='[') { - if (isBracketable(type)) { + if (typeUtil.isBracketable(type)) { return bracketNavigate(offset, type); } else { problemCollector.accept(problem(ApplicationPropertiesProblemType.PROP_INVALID_INDEXED_NAVIGATION, diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java index a1c8c953c..08530fbcb 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java @@ -119,7 +119,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon if (typeUtil.isMap(type)) { //ready to enter nested map key on next line return "\n"+YamlIndentUtil.INDENT_STR; - } if (TypeUtil.isSequencable(type)) { + } if (typeUtil.isSequencable(type)) { //ready to enter sequence element on next line return "\n- "; } else if (typeUtil.isAtomic(type)) { @@ -328,7 +328,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon @Override public YamlAssistContext traverse(YamlPathSegment s) { if (s.getType()==YamlPathSegmentType.VAL_AT_KEY) { - if (TypeUtil.isSequencable(type) || typeUtil.isMap(type)) { + if (typeUtil.isSequencable(type) || typeUtil.isMap(type)) { return contextWith(s, TypeUtil.getDomainType(type)); } String key = s.toPropString(); @@ -337,7 +337,7 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon return contextWith(s, TypedProperty.typeOf(subproperties.get(key))); } } else if (s.getType()==YamlPathSegmentType.VAL_AT_INDEX) { - if (TypeUtil.isSequencable(type)) { + if (typeUtil.isSequencable(type)) { return contextWith(s, TypeUtil.getDomainType(type)); } } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java index fc1467aa9..d25f1c6dc 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/reconcile/ApplicationYamlASTReconciler.java @@ -224,7 +224,7 @@ public class ApplicationYamlASTReconciler implements YamlASTReconciler { checkForDuplicateKeys(mapping); if (typeUtil.isAtomic(type)) { expectTypeFoundMapping(type, mapping); - } else if (typeUtil.isMap(type) || TypeUtil.isSequencable(type)) { + } else if (typeUtil.isMap(type) || typeUtil.isSequencable(type)) { Type keyType = typeUtil.getKeyType(type); Type valueType = TypeUtil.getDomainType(type); if (keyType!=null) { @@ -280,7 +280,7 @@ public class ApplicationYamlASTReconciler implements YamlASTReconciler { private void reconcile(YamlFileAST root, SequenceNode seq, Type type) { if (typeUtil.isAtomic(type)) { expectTypeFoundSequence(type, seq); - } else if (TypeUtil.isSequencable(type)) { + } else if (typeUtil.isSequencable(type)) { Type domainType = TypeUtil.getDomainType(type); if (domainType!=null) { for (Node element : seq.getValue()) { From a4d97e0ad56fb5692f087e733e9cfe71b5476526 Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Thu, 5 Sep 2019 09:18:19 +0200 Subject: [PATCH 05/17] remove wild web feature for now again, needs more thought --- .../org.springframework.boot.ide.product | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product b/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product index f82609b5a..e5fe67fd1 100644 --- a/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product +++ b/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product @@ -73,14 +73,14 @@ - - - + + + - + From 297aea926e35bacb5c25ada735a3314061f0fea2 Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Thu, 5 Sep 2019 17:48:42 -0400 Subject: [PATCH 06/17] PT #168196551: Dark teheme color for boot live hint --- .../META-INF/MANIFEST.MF | 3 ++- .../build.properties | 3 ++- .../css/e4-dark_sts4_prefstyle.css | 4 ++++ .../plugin.xml | 22 +++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/css/e4-dark_sts4_prefstyle.css diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/META-INF/MANIFEST.MF b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/META-INF/MANIFEST.MF index 968600c30..3bc469342 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/META-INF/MANIFEST.MF +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/META-INF/MANIFEST.MF @@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.8.0", org.apache.commons.lang3, org.eclipse.ui.genericeditor, org.eclipse.ui.editors, - org.springsource.ide.eclipse.commons.core + org.springsource.ide.eclipse.commons.core, + org.eclipse.e4.ui.css.swt.theme Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Export-Package: org.springframework.tooling.ls.eclipse.commons, diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/build.properties b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/build.properties index 3f3bea221..3157a99f4 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/build.properties +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/build.properties @@ -6,4 +6,5 @@ bin.includes = META-INF/,\ icons/,\ lib/remark-1.0.0.jar,\ lib/jsoup-1.9.2.jar,\ - about.html + about.html,\ + css/ diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/css/e4-dark_sts4_prefstyle.css b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/css/e4-dark_sts4_prefstyle.css new file mode 100644 index 000000000..e16dab21c --- /dev/null +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/css/e4-dark_sts4_prefstyle.css @@ -0,0 +1,4 @@ +/* See bug 466075 about the pseudo-selector ":org-springframework-tooling-ls-eclipse-commons" */ +IEclipsePreferences#org-eclipse-ui-workbench:org-springframework-tooling-ls-eclipse-commons { + preferences: + 'org.springframework.tooling.ls.eclipse.commons.STS4BootMarkerIndicationColor=109,177,63' diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/plugin.xml b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/plugin.xml index f0144cbc5..7d3471c33 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/plugin.xml +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/plugin.xml @@ -117,4 +117,26 @@ + + + + + + + + + + Running Spring Boot app live data availability hints + + + From f7276a568399eefebd55ef704a20f109741dc462 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Thu, 5 Sep 2019 15:12:57 -0700 Subject: [PATCH 07/17] Try to shorten labels for boot property completions See: https://github.com/spring-projects/sts4/issues/361 --- .../completion/ICompletionProposal.java | 13 +++- .../completion/ScoreableProposal.java | 64 ------------------- .../completion/TransformedCompletion.java | 10 +-- .../ide/vscode/commons/util/StringUtil.java | 17 +++++ .../yaml/completion/YTypeAssistContext.java | 1 + .../yaml/completion/YamlCompletionEngine.java | 1 + ...opertiesCompletionProposalsCalculator.java | 19 +++++- .../test/ApplicationPropertiesEditorTest.java | 51 +++++++++++++++ 8 files changed, 105 insertions(+), 71 deletions(-) rename headless-services/commons/{commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml => commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver}/completion/TransformedCompletion.java (82%) diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java index 3774189e3..131ef4453 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java @@ -38,5 +38,16 @@ public interface ICompletionProposal { default ICompletionProposal deemphasize(double howmuch) { return this; } default boolean isDeprecated() { return false; } - + + default ICompletionProposal dropLabelPrefix(int numberOfDroppedChars) { + return new TransformedCompletion(this) { + @Override + protected String tranformLabel(String originalLabel) { + if (originalLabel.length()>=numberOfDroppedChars) { + return originalLabel.substring(numberOfDroppedChars); + } + return ""; + } + }; + } } diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ScoreableProposal.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ScoreableProposal.java index f955f2bf3..36e29082f 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ScoreableProposal.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ScoreableProposal.java @@ -68,70 +68,6 @@ public abstract class ScoreableProposal implements ICompletionProposal { return deemphasizedBy > 0; } -// @Override -// public boolean isAutoInsertable() { -// return !isDeemphasized(); -// } - -// public StyledString getStyledDisplayString() { -// StyledString result = new StyledString(); -// highlightPattern(getHighlightPattern(), getBaseDisplayString(), result); -// return result; -// } - -// private void highlightPattern(String pattern, String data, StyledString result) { -// Styler highlightStyle = CompletionFactory.HIGHLIGHT; -// Styler plainStyle = isDeemphasized()?CompletionFactory.DEEMPHASIZE:CompletionFactory.NULL_STYLER; -// if (isDeprecated()) { -// highlightStyle = CompletionFactory.compose(highlightStyle, CompletionFactory.DEPRECATE); -// plainStyle = CompletionFactory.compose(plainStyle, CompletionFactory.DEPRECATE); -// } -// if (StringUtils.hasText(pattern)) { -// int dataPos = 0; int dataLen = data.length(); -// int patternPos = 0; int patternLen = pattern.length(); -// -// while (dataPos strings) { + CharSequence prefix = null; + for (CharSequence string : (Iterable)strings::iterator) { + if (prefix==null) { + prefix = string; + } else { + int end = 0; + while (end elideCommonPrefix(String basePrefix, ArrayList proposals) { + String prefix = StringUtil.commonPrefix(Stream.concat(Stream.of(basePrefix), proposals.stream().map(ICompletionProposal::getLabel))); + int lastDot = prefix.lastIndexOf('.'); + if (lastDot>=0) { + for (int i = 0; i < proposals.size(); i++) { + ICompletionProposal p = proposals.get(i); + proposals.set(i, p.dropLabelPrefix(lastDot+1)); + } + } + return proposals; + } + + } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java index 7c86b4ef8..9ab60820d 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java @@ -85,6 +85,57 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { ); editor.assertProblems("no-bool|boolean"); } + + @Test public void abbreviateLongPrefixCompletions() throws Exception { + //See: https://github.com/spring-projects/sts4/issues/361 + Editor editor; + + data("spring.data.jpa.very.long.foobar", "java.lang.String", null, null); + data("spring.data.jpa.very.long.barbar", "java.lang.String", null, null); + data("spring.data.jpa.very.long.foofoo", "java.lang.String", null, null); + data("spring.data.jpa.very.long.barfoo", "java.lang.String", null, null); + data("spring.data.jpa.very.long.foobar.more", "java.lang.String", null, null); + data("spring.data.jpa.very.long.barbar.more", "java.lang.String", null, null); + data("spring.data.jpa.very.long.foofoo.more", "java.lang.String", null, null); + data("spring.data.jpa.very.long.barfoo.more", "java.lang.String", null, null); + + + editor = newEditor( + "spring.data.jpa.very.bar<*>" + ); + editor.assertCompletions( + "spring.data.jpa.very.long.barbar=<*>", + "spring.data.jpa.very.long.barfoo=<*>", + "spring.data.jpa.very.long.foobar=<*>", + "spring.data.jpa.very.long.barbar.more=<*>", + "spring.data.jpa.very.long.barfoo.more=<*>", + "spring.data.jpa.very.long.foobar.more=<*>" + ); + + editor.assertCompletionLabels( + "long.barbar", + "long.barfoo", + "long.foobar", + "long.barbar.more", + "long.barfoo.more", + "long.foobar.more" + ); + + editor = newEditor( + "spring.data.jpa.vr<*>" + ); + editor.assertCompletionLabels( + "very.long.barbar", + "very.long.barfoo", + "very.long.foobar", + "very.long.foofoo", + "very.long.barbar.more", + "very.long.barfoo.more", + "very.long.foobar.more", + "very.long.foofoo.more" + ); + + } @Test public void testReconcileCatchesParseError() throws Exception { From 44e9532ea34f15116a285440aae0aa516bb471d8 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Thu, 5 Sep 2019 16:10:01 -0700 Subject: [PATCH 08/17] Try to shorten labels for boot property completions Part 2: also do the same in application.yml See: https://github.com/spring-projects/sts4/issues/361 --- .../completion/ICompletionProposal.java | 2 +- .../ApplicationYamlAssistContext.java | 4 + .../boot/test/ApplicationYamlEditorTest.java | 94 ++++++++++++++++++- 3 files changed, 98 insertions(+), 2 deletions(-) diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java index 131ef4453..134292231 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java @@ -39,7 +39,7 @@ public interface ICompletionProposal { default boolean isDeprecated() { return false; } - default ICompletionProposal dropLabelPrefix(int numberOfDroppedChars) { + default TransformedCompletion dropLabelPrefix(int numberOfDroppedChars) { return new TransformedCompletion(this) { @Override protected String tranformLabel(String originalLabel) { diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java index 08530fbcb..fb629251a 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java @@ -450,6 +450,10 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon ScoreableProposal completion = completionFactory.property( doc.getDocument(), edits, match, typeUtil ); + String prefix = indexNav.getPrefix(); + if (StringUtil.hasText(prefix)) { + completion = completion.dropLabelPrefix(prefix.length()+1); + } if (getContextRoot(doc).exists(YamlPath.fromProperty(match.data.getId()))) { completion.deemphasize(DEEMP_EXISTS); } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java index 2dc104a63..bc639058c 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java @@ -71,6 +71,98 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest { //////////////////////////////////////////////////////////////////////////////////////// + @Test public void abbreviateLongPrefixCompletions() throws Exception { + //See: https://github.com/spring-projects/sts4/issues/361 + Editor editor; + + data("spring.data.jpa.very.long.foobar", "java.lang.String", null, null); + data("spring.data.jpa.very.long.barbar", "java.lang.String", null, null); + data("spring.data.jpa.very.long.foofoo", "java.lang.String", null, null); + data("spring.data.jpa.very.long.barfoo", "java.lang.String", null, null); + data("spring.data.jpa.very.long.foobar.more", "java.lang.String", null, null); + data("spring.data.jpa.very.long.barbar.more", "java.lang.String", null, null); + data("spring.data.jpa.very.long.foofoo.more", "java.lang.String", null, null); + data("spring.data.jpa.very.long.barfoo.more", "java.lang.String", null, null); + + + editor = newEditor( + "spring:\n" + + " data:\n" + + " jpa:\n" + + " very:\n" + + " bar<*>" + ); + editor.assertCompletions( + "spring:\n" + + " data:\n" + + " jpa:\n" + + " very:\n" + + " long:\n" + + " barbar: <*>", + "spring:\n" + + " data:\n" + + " jpa:\n" + + " very:\n" + + " long:\n" + + " barfoo: <*>", + "spring:\n" + + " data:\n" + + " jpa:\n" + + " very:\n" + + " long:\n" + + " foobar: <*>", + "spring:\n" + + " data:\n" + + " jpa:\n" + + " very:\n" + + " long:\n" + + " barbar:\n"+ + " more: <*>", + "spring:\n" + + " data:\n" + + " jpa:\n" + + " very:\n" + + " long:\n" + + " barfoo:\n"+ + " more: <*>", + "spring:\n" + + " data:\n" + + " jpa:\n" + + " very:\n" + + " long:\n" + + " foobar:\n"+ + " more: <*>" + ); + + editor.assertCompletionLabels( + "long.barbar", + "long.barfoo", + "long.foobar", + "long.barbar.more", + "long.barfoo.more", + "long.foobar.more" + ); + + editor = newEditor( + "spring:\n" + + " data:\n" + + " jpa:\n" + + " vr<*>" + ); + editor.assertCompletionLabels( + "very.long.barbar", + "very.long.barfoo", + "very.long.foobar", + "very.long.foofoo", + "very.long.barbar.more", + "very.long.barfoo.more", + "very.long.foobar.more", + "very.long.foofoo.more" + ); + + } + + @Test public void bug_GH_327() throws Exception { //See https://github.com/spring-projects/sts4/issues/327 data("spring.resources.static-locations", "java.lang.Boolean", null, "Blah"); @@ -3358,7 +3450,7 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest { " p<*>" ); - editor.assertCompletionLabels("server.port"); + editor.assertCompletionLabels("port"); From 2f31f55318c36827dc1e4b9734ffdf71894a71ea Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Thu, 5 Sep 2019 21:37:33 -0400 Subject: [PATCH 09/17] PT #168196551: Dark theme support for live boot hints --- .../LanguageServerCommonsActivator.java | 61 +++---------------- .../preferences/PreferenceConstants.java | 4 +- 2 files changed, 9 insertions(+), 56 deletions(-) diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java index 1dacf6aec..be0a33c69 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java @@ -13,28 +13,21 @@ package org.springframework.tooling.ls.eclipse.commons; import java.net.URL; import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.ColorRegistry; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGB; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.internal.editors.text.EditorsPlugin; import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.ui.progress.UIJob; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.springframework.tooling.ls.eclipse.commons.STS4LanguageClientImpl.UpdateHighlights; import org.springframework.tooling.ls.eclipse.commons.preferences.PreferenceConstants; -@SuppressWarnings("restriction") public class LanguageServerCommonsActivator extends AbstractUIPlugin { public static final String PLUGIN_ID = "org.springframework.tooling.ls.eclipse.commons"; @@ -43,20 +36,13 @@ public class LanguageServerCommonsActivator extends AbstractUIPlugin { private static LanguageServerCommonsActivator instance; - private ColorRegistry colorRegistry; - private final IPropertyChangeListener PROPERTY_LISTENER = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { switch (event.getProperty()) { - case PreferenceConstants.HIGHLIGHT_RANGE_COLOR_PREFS: - RGB prefsColor = PreferenceConverter - .getColor(EditorsPlugin.getDefault().getPreferenceStore(), PreferenceConstants.HIGHLIGHT_RANGE_COLOR_PREFS); - // Convert color to without alpha with background - RGB derivedColor = convertRGBtoNonTransparent(prefsColor); - colorRegistry.put(PreferenceConstants.HIGHLIGHT_RANGE_COLOR_PREFS, derivedColor); - // No break - need to update highlights for the new color to take effect + case PreferenceConstants.HIGHLIGHT_RANGE_COLOR_THEME: + // Fall through to update highlights case PreferenceConstants.HIGHLIGHT_CODELENS_PREFS: new UpdateHighlights(null, true); break; @@ -66,23 +52,6 @@ public class LanguageServerCommonsActivator extends AbstractUIPlugin { }; - private static int convertColorToNonTransparent(int color, int bg, double alpha) { - int x = (int) Math.round((color - (1 - alpha) * bg) / alpha); - x = Math.max(0, x); - x = Math.min(x, 0xFF); - return x; - } - - private static RGB convertRGBtoNonTransparent(RGB rgb) { - double alpha = 0.25; - RGB bg = new RGB(0xFF, 0xFF, 0xFF); // white - return new RGB( - convertColorToNonTransparent(rgb.red, bg.red, alpha), - convertColorToNonTransparent(rgb.green, bg.green, alpha), - convertColorToNonTransparent(rgb.blue, bg.blue, alpha) - ); - } - public LanguageServerCommonsActivator() { } @@ -92,29 +61,12 @@ public class LanguageServerCommonsActivator extends AbstractUIPlugin { super.start(context); getImageRegistry().put(BOOT_KEY, getImageDescriptor("icons/boot.png")); - UIJob uiJob = new UIJob("Setup color registry") { - { - setSystem(true); - } - - @Override - public IStatus runInUIThread(IProgressMonitor arg0) { - colorRegistry = new ColorRegistry(PlatformUI.getWorkbench().getDisplay(), true); - RGB prefsColor = PreferenceConverter.getColor(EditorsPlugin.getDefault().getPreferenceStore(), PreferenceConstants.HIGHLIGHT_RANGE_COLOR_PREFS); - colorRegistry.put(PreferenceConstants.HIGHLIGHT_RANGE_COLOR_PREFS, convertRGBtoNonTransparent(prefsColor)); - getPreferenceStore().addPropertyChangeListener(PROPERTY_LISTENER); - EditorsPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(PROPERTY_LISTENER); - return Status.OK_STATUS; - } - }; - uiJob.schedule(); + getPreferenceStore().addPropertyChangeListener(PROPERTY_LISTENER); + PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(PROPERTY_LISTENER);; } public Color getBootHighlightRangeColor() { - if (colorRegistry!=null) { - return colorRegistry.get(PreferenceConstants.HIGHLIGHT_RANGE_COLOR_PREFS); - } - return null; + return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry().get(PreferenceConstants.HIGHLIGHT_RANGE_COLOR_THEME); } public final static ImageDescriptor getImageDescriptor(String path) { @@ -132,8 +84,8 @@ public class LanguageServerCommonsActivator extends AbstractUIPlugin { @Override public void stop(BundleContext context) throws Exception { - EditorsPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(PROPERTY_LISTENER); getPreferenceStore().removePropertyChangeListener(PROPERTY_LISTENER); + PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(PROPERTY_LISTENER); super.stop(context); } @@ -148,4 +100,5 @@ public class LanguageServerCommonsActivator extends AbstractUIPlugin { public static void logInfo(String message) { instance.getLog().log(new Status(IStatus.INFO, instance.getBundle().getSymbolicName(), message)); } + } diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/preferences/PreferenceConstants.java b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/preferences/PreferenceConstants.java index a127e27b3..0c63ed7a2 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/preferences/PreferenceConstants.java +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/preferences/PreferenceConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Pivotal, Inc. + * Copyright (c) 2018, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,6 @@ public class PreferenceConstants { public static final String HIGHLIGHT_CODELENS_PREFS = "highlight.codelens"; - public static final String HIGHLIGHT_RANGE_COLOR_PREFS = "STS4BootMarkerIndicationColor"; + public static final String HIGHLIGHT_RANGE_COLOR_THEME = "org.springframework.tooling.ls.eclipse.commons.STS4BootMarkerIndicationColor"; } From 6ce467e2f16315dd75432145a625b5d287156fd3 Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Fri, 6 Sep 2019 10:49:14 +0200 Subject: [PATCH 10/17] remove rse to avoid empty package explorer due to hidden remote files project disables shortcuts being displayed --- .../org.springframework.boot.ide.product | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product b/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product index e5fe67fd1..12ed14fe9 100644 --- a/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product +++ b/eclipse-distribution/org.springframework.boot.ide.product.e413/org.springframework.boot.ide.product @@ -82,7 +82,7 @@ - + From 3773444a4ab4d110f11f7adc4b1c7ad573131a37 Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Fri, 6 Sep 2019 10:53:40 +0200 Subject: [PATCH 11/17] update to orbit release version for 2019-09 --- eclipse-distribution/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eclipse-distribution/pom.xml b/eclipse-distribution/pom.xml index 83cbd727a..54baaa3c7 100644 --- a/eclipse-distribution/pom.xml +++ b/eclipse-distribution/pom.xml @@ -409,9 +409,9 @@ https://download.eclipse.org/staging/2019-09/ - orbit-s-build + orbit p2 - https://download.eclipse.org/tools/orbit/downloads/drops/S20190827152740/repository + https://download.eclipse.org/tools/orbit/downloads/drops/R20190827152740/repository latest-m2e From 1200bf2c8b34006bfc41bfc778d09a1e8fc6177f Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Fri, 6 Sep 2019 12:35:25 -0400 Subject: [PATCH 12/17] Fix duplicate files in XML index --- .../ide/vscode/boot/java/utils/SpringIndexerXML.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/SpringIndexerXML.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/SpringIndexerXML.java index ad5985012..2c56975f4 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/SpringIndexerXML.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/SpringIndexerXML.java @@ -230,6 +230,9 @@ public class SpringIndexerXML implements SpringIndexer { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { + if (dir.getFileName().toString().startsWith(".")) { + return FileVisitResult.SKIP_SUBTREE; + } return FileVisitResult.CONTINUE; } @@ -242,6 +245,7 @@ public class SpringIndexerXML implements SpringIndexer { for (PathMatcher matcher : matchers) { if (matcher.matches(parent)) { builder.add(file.toAbsolutePath().toString()); + return FileVisitResult.CONTINUE; } } } From 8d60b77bcb2a404357db61bfc159d4fcf544d727 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Fri, 6 Sep 2019 12:22:52 -0700 Subject: [PATCH 13/17] Some tweaks around issue #361 When dropping prefix from completion label in application.properties, also update the edits to drop it from the edit range. --- .../completion/DocumentEdits.java | 21 +++++++++- .../completion/ICompletionProposal.java | 16 ++++--- .../test/ApplicationPropertiesEditorTest.java | 42 ++++++++++++++++++- .../vscode-spring-boot/lib/Main.ts | 2 +- 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEdits.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEdits.java index aae74ee3b..8cfe7a421 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEdits.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/DocumentEdits.java @@ -17,7 +17,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.lsp4j.TextEdit; -import org.springframework.ide.vscode.commons.languageserver.util.PlaceHolderString; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.ide.vscode.commons.util.Assert; import org.springframework.ide.vscode.commons.util.BadLocationException; import org.springframework.ide.vscode.commons.util.text.IDocument; @@ -45,6 +46,8 @@ import org.springframework.ide.vscode.commons.util.text.TextDocument; * @author Kris De Volder */ public class DocumentEdits implements ProposalApplier { + + private static final Logger log = LoggerFactory.getLogger(DocumentEdits.class); private static final Pattern NON_WS_CHAR = Pattern.compile("\\S"); @@ -511,4 +514,20 @@ public class DocumentEdits implements ProposalApplier { final public boolean hasSnippets() { return hasSnippets; } + + public void dropPrefix(String prefix) { + try { + if (edits.size() == 2 && edits.get(0) instanceof Deletion && edits.get(1) instanceof Insertion) { + Deletion del = (Deletion) edits.get(0); + Insertion ins = (Insertion) edits.get(1); + String replacedText = doc.textBetween(del.start, del.end); + if (ins.offset>=del.start && ins.offset <=del.end && replacedText.startsWith(prefix)) { + del.start+=prefix.length(); + ins.text = ins.text.substring(prefix.length()); + } + } + } catch (BadLocationException e) { + log.error("", e); + } + } } diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java index 134292231..1881cf1d0 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java @@ -39,14 +39,20 @@ public interface ICompletionProposal { default boolean isDeprecated() { return false; } - default TransformedCompletion dropLabelPrefix(int numberOfDroppedChars) { + default TransformedCompletion dropLabelPrefix(int _numberOfDroppedChars) { + String orgLabel = getLabel(); + int numberOfDroppedChars = Math.min(orgLabel.length(), _numberOfDroppedChars); + String prefix = getLabel().substring(0, numberOfDroppedChars); return new TransformedCompletion(this) { @Override protected String tranformLabel(String originalLabel) { - if (originalLabel.length()>=numberOfDroppedChars) { - return originalLabel.substring(numberOfDroppedChars); - } - return ""; + return originalLabel.substring(numberOfDroppedChars); + } + + @Override + protected DocumentEdits transformEdit(DocumentEdits textEdit) { + textEdit.dropPrefix(prefix); + return textEdit; } }; } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java index 9ab60820d..e4757940a 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.springframework.ide.vscode.boot.test; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.springframework.ide.vscode.boot.properties.reconcile.ApplicationPropertiesProblemType.PROP_DUPLICATE_KEY; @@ -25,6 +26,7 @@ import java.util.List; import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.Diagnostic; +import org.eclipse.lsp4j.TextEdit; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -112,7 +114,7 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { "spring.data.jpa.very.long.foobar.more=<*>" ); - editor.assertCompletionLabels( + List completions = editor.assertCompletionLabels( "long.barbar", "long.barfoo", "long.foobar", @@ -120,11 +122,15 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { "long.barfoo.more", "long.foobar.more" ); + for (CompletionItem c : completions) { + TextEdit edit = c.getTextEdit(); + assertEquals("bar", editor.getText(edit.getRange())); + } editor = newEditor( "spring.data.jpa.vr<*>" ); - editor.assertCompletionLabels( + completions = editor.assertCompletionLabels( "very.long.barbar", "very.long.barfoo", "very.long.foobar", @@ -134,6 +140,38 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { "very.long.foobar.more", "very.long.foofoo.more" ); + for (CompletionItem c : completions) { + TextEdit edit = c.getTextEdit(); + assertEquals("vr", editor.getText(edit.getRange())); + } + + editor = newEditor( + "spring.data.jpa.very.<*>" + ); + editor.assertCompletions( + "spring.data.jpa.very.long.barbar=<*>", + "spring.data.jpa.very.long.barbar.more=<*>", + "spring.data.jpa.very.long.barfoo=<*>", + "spring.data.jpa.very.long.barfoo.more=<*>", + "spring.data.jpa.very.long.foobar=<*>", + "spring.data.jpa.very.long.foobar.more=<*>", + "spring.data.jpa.very.long.foofoo=<*>", + "spring.data.jpa.very.long.foofoo.more=<*>" + ); + completions = editor.assertCompletionLabels( + "long.barbar", + "long.barbar.more", + "long.barfoo", + "long.barfoo.more", + "long.foobar", + "long.foobar.more", + "long.foofoo", + "long.foofoo.more" + ); + for (CompletionItem c : completions) { + TextEdit edit = c.getTextEdit(); + assertEquals("", editor.getText(edit.getRange())); + } } diff --git a/vscode-extensions/vscode-spring-boot/lib/Main.ts b/vscode-extensions/vscode-spring-boot/lib/Main.ts index ff83022ec..063368bb7 100644 --- a/vscode-extensions/vscode-spring-boot/lib/Main.ts +++ b/vscode-extensions/vscode-spring-boot/lib/Main.ts @@ -18,7 +18,7 @@ export function activate(context: VSCode.ExtensionContext): Thenable { From 09f05cd33fd36817b91dcf5f69d35237f1282049 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Fri, 6 Sep 2019 13:08:04 -0700 Subject: [PATCH 14/17] Revert accidentally committed CONNECT_TO_LS: true --- vscode-extensions/vscode-spring-boot/lib/Main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode-extensions/vscode-spring-boot/lib/Main.ts b/vscode-extensions/vscode-spring-boot/lib/Main.ts index 063368bb7..ff83022ec 100644 --- a/vscode-extensions/vscode-spring-boot/lib/Main.ts +++ b/vscode-extensions/vscode-spring-boot/lib/Main.ts @@ -18,7 +18,7 @@ export function activate(context: VSCode.ExtensionContext): Thenable { From e6592f06374e2431278b23dd6ed99057a63c7e1d Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Mon, 9 Sep 2019 14:39:04 -0400 Subject: [PATCH 15/17] PT #168196551: Connect marker color to theme color. Remove old marker --- .../css/e4-dark_sts4_prefstyle.css | 2 +- .../plugin.xml | 3 +- .../LanguageServerCommonsActivator.java | 28 +++- .../commons/STS4LanguageClientImpl.java | 141 ++++++++---------- .../preferences/PreferenceConstants.java | 2 + 5 files changed, 97 insertions(+), 79 deletions(-) diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/css/e4-dark_sts4_prefstyle.css b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/css/e4-dark_sts4_prefstyle.css index e16dab21c..07c9c7a09 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/css/e4-dark_sts4_prefstyle.css +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/css/e4-dark_sts4_prefstyle.css @@ -1,4 +1,4 @@ /* See bug 466075 about the pseudo-selector ":org-springframework-tooling-ls-eclipse-commons" */ IEclipsePreferences#org-eclipse-ui-workbench:org-springframework-tooling-ls-eclipse-commons { preferences: - 'org.springframework.tooling.ls.eclipse.commons.STS4BootMarkerIndicationColor=109,177,63' + 'org.springframework.tooling.ls.eclipse.commons.STS4BootMarkerIndicationColor=56,84,26' diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/plugin.xml b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/plugin.xml index 7d3471c33..4f03d4551 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/plugin.xml +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/plugin.xml @@ -14,6 +14,7 @@ highlightPreferenceKey="STS4BootMarkerHighlighting" highlightPreferenceValue="true" icon="icons/boot-icon.png" + includeOnPreferencePage="false" label="Boot Dynamic Info" overviewRulerPreferenceKey="STS4BootMarkerIndicationInOverviewRuler" overviewRulerPreferenceValue="false" @@ -133,7 +134,7 @@ id="org.springframework.tooling.ls.eclipse.commons.STS4BootMarkerIndicationColor" isEditable="true" label="Live Boot Hint Color" - value="111,179,63"> + value="219,236,207"> Running Spring Boot app live data availability hints diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java index be0a33c69..37e60e391 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/LanguageServerCommonsActivator.java @@ -11,25 +11,33 @@ package org.springframework.tooling.ls.eclipse.commons; import java.net.URL; +import java.util.Objects; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; +import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.internal.editors.text.EditorsPlugin; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.ui.texteditor.AnnotationPreference; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.springframework.tooling.ls.eclipse.commons.STS4LanguageClientImpl.UpdateHighlights; import org.springframework.tooling.ls.eclipse.commons.preferences.PreferenceConstants; +@SuppressWarnings("restriction") public class LanguageServerCommonsActivator extends AbstractUIPlugin { + private static final String BOOT_HINT_ANNOTATION_TYPE = "org.springframework.tooling.bootinfo"; + public static final String PLUGIN_ID = "org.springframework.tooling.ls.eclipse.commons"; public static final String BOOT_KEY = "boot-key"; @@ -42,6 +50,7 @@ public class LanguageServerCommonsActivator extends AbstractUIPlugin { public void propertyChange(PropertyChangeEvent event) { switch (event.getProperty()) { case PreferenceConstants.HIGHLIGHT_RANGE_COLOR_THEME: + updateMarkerAnnotationPreferences(); // Fall through to update highlights case PreferenceConstants.HIGHLIGHT_CODELENS_PREFS: new UpdateHighlights(null, true); @@ -52,6 +61,8 @@ public class LanguageServerCommonsActivator extends AbstractUIPlugin { }; + private AnnotationPreference bootHintAnnotationPreference; + public LanguageServerCommonsActivator() { } @@ -62,7 +73,22 @@ public class LanguageServerCommonsActivator extends AbstractUIPlugin { getImageRegistry().put(BOOT_KEY, getImageDescriptor("icons/boot.png")); getPreferenceStore().addPropertyChangeListener(PROPERTY_LISTENER); - PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(PROPERTY_LISTENER);; + PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(PROPERTY_LISTENER); + + bootHintAnnotationPreference = EditorsPlugin.getDefault().getMarkerAnnotationPreferences() + .getAnnotationPreferences().stream().filter(Objects::nonNull) + .filter(info -> BOOT_HINT_ANNOTATION_TYPE.equals(info.getAnnotationType())).findFirst().orElse(null); + updateMarkerAnnotationPreferences(); + } + + /** + * Forwards theme colors on to marker preferences + */ + private void updateMarkerAnnotationPreferences() { + RGB themeRgb = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry() + .getRGB(PreferenceConstants.HIGHLIGHT_RANGE_COLOR_THEME); + PreferenceConverter.setValue(EditorsPlugin.getDefault().getPreferenceStore(), + bootHintAnnotationPreference.getColorPreferenceKey(), themeRgb); } public Color getBootHighlightRangeColor() { diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageClientImpl.java b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageClientImpl.java index f25b587e9..54a8f07c4 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageClientImpl.java +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/STS4LanguageClientImpl.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.springframework.tooling.ls.eclipse.commons; -import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URI; @@ -42,8 +41,6 @@ import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.AnnotationPainter; -import org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IAnnotationModelExtension; import org.eclipse.jface.text.source.ISourceViewer; @@ -54,12 +51,6 @@ import org.eclipse.lsp4j.CodeLens; import org.eclipse.lsp4j.Location; import org.eclipse.lsp4j.MarkupContent; import org.eclipse.lsp4j.MarkupKind; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorReference; @@ -68,9 +59,7 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.progress.UIJob; -import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; import org.eclipse.ui.texteditor.AbstractTextEditor; -import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; import org.springframework.ide.vscode.commons.protocol.CursorMovement; import org.springframework.ide.vscode.commons.protocol.HighlightParams; import org.springframework.ide.vscode.commons.protocol.ProgressParams; @@ -143,8 +132,8 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La private static final String ANNOTION_TYPE_ID = "org.springframework.tooling.bootinfo"; - private static final String ALT_ANNOTATION_DRAWING_STRATEGY_ID = "boot.hint.strategy"; - private static final String ALT_ANNOTATION_TYPE_ID = "org.springframework.tooling.bootinfoCodeLens"; +// private static final String ALT_ANNOTATION_DRAWING_STRATEGY_ID = "boot.hint.strategy"; +// private static final String ALT_ANNOTATION_TYPE_ID = "org.springframework.tooling.bootinfoCodeLens"; /** * Latest highlight request params. It is sufficient to only remember the last request per uri, because @@ -157,32 +146,32 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La */ private static Map currentAnnotations = new ConcurrentHashMap<>(); - private static final IDrawingStrategy BOOT_RANGE_HIGHLIGHT_DRAWING_STRATEGY = new IDrawingStrategy() { - - @Override - public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color) { - - if (gc == null) { - textWidget.redrawRange(offset, length, true); - } else { - int oldAlpha = gc.getAlpha(); - Font oldFont = gc.getFont(); - - Point left= textWidget.getLocationAtOffset(offset); - Point right = textWidget.getLocationAtOffset(offset + length); - gc.setFont(textWidget.getFont()); - int fontHeight = gc.getFontMetrics().getHeight(); - Rectangle r = new Rectangle(left.x, left.y + textWidget.getLineHeight(offset) - fontHeight, right.x - left.x, fontHeight); - gc.setAlpha(0x40); - gc.setBackground(color); - gc.fillRectangle(r); - - gc.setAlpha(oldAlpha); - gc.setFont(oldFont); - } - } - - }; +// private static final IDrawingStrategy BOOT_RANGE_HIGHLIGHT_DRAWING_STRATEGY = new IDrawingStrategy() { +// +// @Override +// public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color) { +// +// if (gc == null) { +// textWidget.redrawRange(offset, length, true); +// } else { +// int oldAlpha = gc.getAlpha(); +// Font oldFont = gc.getFont(); +// +// Point left= textWidget.getLocationAtOffset(offset); +// Point right = textWidget.getLocationAtOffset(offset + length); +// gc.setFont(textWidget.getFont()); +// int fontHeight = gc.getFontMetrics().getHeight(); +// Rectangle r = new Rectangle(left.x, left.y + textWidget.getLineHeight(offset) - fontHeight, right.x - left.x, fontHeight); +// gc.setAlpha(0x40); +// gc.setBackground(color); +// gc.fillRectangle(r); +// +// gc.setAlpha(oldAlpha); +// gc.setFont(oldFont); +// } +// } +// +// }; static class UpdateHighlights extends UIJob { @@ -231,11 +220,11 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La private static void updateHighlightAnnotations(IEditorPart editor, ISourceViewer sourceViewer, IAnnotationModel annotationModel, String docUri, boolean updateCodeMinings) { - boolean codeLensHighlightOn = isCodeLensHighlightOn(); +// boolean codeLensHighlightOn = isCodeLensHighlightOn(); if (annotationModel instanceof IAnnotationModelExtension) { - if (codeLensHighlightOn) { - addBootRangeHighlightSupport(editor, sourceViewer); - } +// if (codeLensHighlightOn) { +// addBootRangeHighlightSupport(editor, sourceViewer); +// } updateAnnotations(docUri, sourceViewer, (IAnnotationModelExtension) annotationModel); } if (updateCodeMinings && sourceViewer instanceof ISourceViewerExtension5) { @@ -255,39 +244,39 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La } } - private static void addBootRangeHighlightSupport(IEditorPart editor, ISourceViewer sourceViewer) { - if (editor instanceof AbstractDecoratedTextEditor) { - addBootRangeHighlightSupport((AbstractDecoratedTextEditor)editor, sourceViewer); - } -// else if () { -// // TODO: XML multi page editor handling for highlight support of XML source editor +// private static void addBootRangeHighlightSupport(IEditorPart editor, ISourceViewer sourceViewer) { +// if (editor instanceof AbstractDecoratedTextEditor) { +// addBootRangeHighlightSupport((AbstractDecoratedTextEditor)editor, sourceViewer); // } - } - - @SuppressWarnings("unchecked") - private static void addBootRangeHighlightSupport(AbstractDecoratedTextEditor editor, ISourceViewer sourceViewer) { - try { - Field f = AbstractDecoratedTextEditor.class.getDeclaredField("fSourceViewerDecorationSupport"); - f.setAccessible(true); - SourceViewerDecorationSupport support = (SourceViewerDecorationSupport) f.get(editor); - f = SourceViewerDecorationSupport.class.getDeclaredField("fAnnotationPainter"); - f.setAccessible(true); - AnnotationPainter painter = (AnnotationPainter) f.get(support); - - f = AnnotationPainter.class.getDeclaredField("fAnnotationType2Color"); - f.setAccessible(true); - Color highlightColor = LanguageServerCommonsActivator.getInstance().getBootHighlightRangeColor(); - if (highlightColor!=null && ((Map)f.get(painter)).get(ALT_ANNOTATION_TYPE_ID) != highlightColor) { - painter.setAnnotationTypeColor(ALT_ANNOTATION_TYPE_ID, highlightColor); - painter.addDrawingStrategy(ALT_ANNOTATION_DRAWING_STRATEGY_ID, BOOT_RANGE_HIGHLIGHT_DRAWING_STRATEGY); - painter.addAnnotationType(ALT_ANNOTATION_TYPE_ID, ALT_ANNOTATION_DRAWING_STRATEGY_ID); - } - - } catch (Exception e) { - LanguageServerCommonsActivator.logError(e, - "Failed to contribute alternative range highlight annotation. Switch off highlight CodeLense under STS Language Server preferences!"); - } - } +//// else if () { +//// // TODO: XML multi page editor handling for highlight support of XML source editor +//// } +// } +// +// @SuppressWarnings("unchecked") +// private static void addBootRangeHighlightSupport(AbstractDecoratedTextEditor editor, ISourceViewer sourceViewer) { +// try { +// Field f = AbstractDecoratedTextEditor.class.getDeclaredField("fSourceViewerDecorationSupport"); +// f.setAccessible(true); +// SourceViewerDecorationSupport support = (SourceViewerDecorationSupport) f.get(editor); +// f = SourceViewerDecorationSupport.class.getDeclaredField("fAnnotationPainter"); +// f.setAccessible(true); +// AnnotationPainter painter = (AnnotationPainter) f.get(support); +// +// f = AnnotationPainter.class.getDeclaredField("fAnnotationType2Color"); +// f.setAccessible(true); +// Color highlightColor = LanguageServerCommonsActivator.getInstance().getBootHighlightRangeColor(); +// if (highlightColor!=null && ((Map)f.get(painter)).get(ALT_ANNOTATION_TYPE_ID) != highlightColor) { +// painter.setAnnotationTypeColor(ALT_ANNOTATION_TYPE_ID, highlightColor); +// painter.addDrawingStrategy(ALT_ANNOTATION_DRAWING_STRATEGY_ID, BOOT_RANGE_HIGHLIGHT_DRAWING_STRATEGY); +// painter.addAnnotationType(ALT_ANNOTATION_TYPE_ID, ALT_ANNOTATION_DRAWING_STRATEGY_ID); +// } +// +// } catch (Exception e) { +// LanguageServerCommonsActivator.logError(e, +// "Failed to contribute alternative range highlight annotation. Switch off highlight CodeLense under STS Language Server preferences!"); +// } +// } private static boolean isCodeLensHighlightOn() { IPreferenceStore store = LanguageServerCommonsActivator.getInstance().getPreferenceStore(); @@ -302,7 +291,7 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La } HighlightParams highlightParams = currentHighlights.get(target); List highlights = highlightParams == null ? null : highlightParams.getCodeLenses(); - String annotationType = isCodeLensHighlightOn() ? ALT_ANNOTATION_TYPE_ID : ANNOTION_TYPE_ID; + String annotationType = /*isCodeLensHighlightOn() ? ALT_ANNOTATION_TYPE_ID :*/ ANNOTION_TYPE_ID; Map newAnnotations = createAnnotations(sourceViewer.getDocument(), highlights, annotationType); annotationModel.replaceAnnotations(toRemove, newAnnotations); currentAnnotations.put(target, newAnnotations.keySet().toArray(new Annotation[newAnnotations.size()])); diff --git a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/preferences/PreferenceConstants.java b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/preferences/PreferenceConstants.java index 0c63ed7a2..de504e5a9 100644 --- a/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/preferences/PreferenceConstants.java +++ b/eclipse-language-servers/org.springframework.tooling.ls.eclipse.commons/src/org/springframework/tooling/ls/eclipse/commons/preferences/PreferenceConstants.java @@ -16,4 +16,6 @@ public class PreferenceConstants { public static final String HIGHLIGHT_RANGE_COLOR_THEME = "org.springframework.tooling.ls.eclipse.commons.STS4BootMarkerIndicationColor"; + public static final String HIGHLIGHT_RANGE_COLOR_PREFERENCE = "STS4BootMarkerIndicationColor"; + } From 04c1638d379c9ad5e6d8e49de81224c58d19ef7d Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Tue, 10 Sep 2019 09:30:18 +0200 Subject: [PATCH 16/17] removed staging repo from 2019-06 distro builds --- eclipse-distribution/pom.xml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/eclipse-distribution/pom.xml b/eclipse-distribution/pom.xml index 54baaa3c7..d855198c2 100644 --- a/eclipse-distribution/pom.xml +++ b/eclipse-distribution/pom.xml @@ -305,15 +305,10 @@ e412 - - - 2019-06-staging - p2 - https://download.eclipse.org/staging/2019-06/ orbit From c887a418534eb898675e195a2e14a09e8836c408 Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Tue, 10 Sep 2019 11:07:08 +0200 Subject: [PATCH 17/17] forcing code signing for macOS app package --- .../org.springframework.boot.ide.product.e413/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/eclipse-distribution/org.springframework.boot.ide.product.e413/pom.xml b/eclipse-distribution/org.springframework.boot.ide.product.e413/pom.xml index e280d98e3..889fe50dc 100644 --- a/eclipse-distribution/org.springframework.boot.ide.product.e413/pom.xml +++ b/eclipse-distribution/org.springframework.boot.ide.product.e413/pom.xml @@ -143,6 +143,7 @@ +