Commit 41119bfb authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ completion refinements, #122

parent 7391ae53
Loading
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -383,11 +383,12 @@ public class TDLtxProposalProvider extends AbstractTDLtxProposalProvider {
				if (ne instanceof SimpleDataType) {
					
				} else {
					String prefix = "new ";
					String prefix = "";
					String suffix = "()";
					if (ne instanceof CollectionDataType) {
						suffix = "[]";
					}
					acceptor.accept(createCompletionProposal(suffix, new StyledString(suffix).append(" : new anonymous instance of type "+ne.getName(), StyledString.DECORATIONS_STYLER), getImage(ne), 1100, "", context));
					acceptor.accept(createCompletionProposal(prefix+ne.getName()+suffix, new StyledString(prefix+ne.getName()+suffix).append(" : new instance of type", StyledString.DECORATIONS_STYLER), getImage(ne), 1000, "", context));
				}
			} else if (ne instanceof Function && ((Function) ne).getReturnType().conformsTo(type)) {
@@ -534,6 +535,13 @@ public class TDLtxProposalProvider extends AbstractTDLtxProposalProvider {
					.map(ParameterBinding::getParameter)
					.toList();

			if (dataElement == null) {
				dataElement = ((DataElementUse) model).resolveDataType();
				//TODO: filter parentheses
				prefix = prefix.replace("(", "");
				suffix = suffix.replace(")", "");
			}
			
			//TODO: a bit of a hack.. this belongs elsewhere -> affects the whole chain, should be applied selectively
//			System.out.println(model);
//			System.out.println(context.getPreviousModel());
@@ -598,6 +606,9 @@ public class TDLtxProposalProvider extends AbstractTDLtxProposalProvider {
			ICompletionProposalAcceptor acceptor) {
		if (model instanceof DataElementUse) {
			NamedElement dataElement = ((DataElementUse) model).getDataElement();
			if (dataElement == null) {
				dataElement = ((DataElementUse) model).resolveDataType();
			}
			if (dataElement instanceof CollectionDataType) {
				DataType itemType = ((CollectionDataType) dataElement).getItemType();
				completeAssignment(model, context, acceptor, itemType);