Java Code Examples for org.eclipse.lsp4j.CompletionItem#setSortText()

The following examples show how to use org.eclipse.lsp4j.CompletionItem#setSortText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilePathCompletionParticipant.java    From lemminx with Eclipse Public License 2.0 6 votes vote down vote up
private void createFilePathCompletionItem(File f, Range replaceRange, ICompletionResponse response, String slash) {
	CompletionItem item = new CompletionItem();
	String fName = f.getName();
	if(isWindows && fName.isEmpty()) { // Edge case for Windows drive letter
		fName = f.getPath();
		fName = fName.substring(0, fName.length() - 1);
	}
	String insertText;
	insertText = slash + fName;
	item.setLabel(insertText);

	CompletionItemKind kind = f.isDirectory()? CompletionItemKind.Folder : CompletionItemKind.File;
	item.setKind(kind);
	
	item.setSortText(CompletionSortTextHelper.getSortText(kind));
	item.setFilterText(insertText);
	item.setTextEdit(new TextEdit(replaceRange, insertText));
	response.addCompletionItem(item);
}
 
Example 2
Source File: SnippetCompletionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static CompletionItem getInterfaceSnippet(SnippetCompletionContext scc, IProgressMonitor monitor) {
	ICompilationUnit cu = scc.getCompilationUnit();
	if (!accept(cu, scc.completionContext, false)) {
		return null;
	}
	if (monitor.isCanceled()) {
		return null;
	}
	final CompletionItem interfaceSnippetItem = new CompletionItem();
	interfaceSnippetItem.setFilterText(INTERFACE_SNIPPET_LABEL);
	interfaceSnippetItem.setLabel(INTERFACE_SNIPPET_LABEL);
	interfaceSnippetItem.setSortText(SortTextHelper.convertRelevance(0));

	try {
		CodeGenerationTemplate template = ((scc.needsPublic(monitor))) ? CodeGenerationTemplate.INTERFACESNIPPET_PUBLIC : CodeGenerationTemplate.INTERFACESNIPPET_DEFAULT;
		interfaceSnippetItem.setInsertText(getSnippetContent(scc, template, true));
		setFields(interfaceSnippetItem, cu);
	} catch (CoreException e) {
		JavaLanguageServerPlugin.log(e.getStatus());
		return null;
	}
	return interfaceSnippetItem;
}
 
Example 3
Source File: SnippetCompletionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static CompletionItem getClassSnippet(SnippetCompletionContext scc, IProgressMonitor monitor) {
	ICompilationUnit cu = scc.getCompilationUnit();
	if (!accept(cu, scc.getCompletionContext(), true)) {
		return null;
	}
	if (monitor.isCanceled()) {
		return null;
	}
	final CompletionItem classSnippetItem = new CompletionItem();
	classSnippetItem.setLabel(CLASS_SNIPPET_LABEL);
	classSnippetItem.setFilterText(CLASS_SNIPPET_LABEL);
	classSnippetItem.setSortText(SortTextHelper.convertRelevance(1));

	try {
		CodeGenerationTemplate template = (scc.needsPublic(monitor)) ? CodeGenerationTemplate.CLASSSNIPPET_PUBLIC : CodeGenerationTemplate.CLASSSNIPPET_DEFAULT;
		classSnippetItem.setInsertText(getSnippetContent(scc, template, true));
		setFields(classSnippetItem, cu);
	} catch (CoreException e) {
		JavaLanguageServerPlugin.log(e.getStatus());
		return null;
	}
	return classSnippetItem;
}
 
Example 4
Source File: DdlCompletionItemLoader.java    From syndesis with Apache License 2.0 6 votes vote down vote up
/**
 * Clones a {@link CompletionItem} for the given label from the supplied items
 *
 * @param targetLabel
 * @return a completion item
 */
private static CompletionItem cloneCompletionItem(List<CompletionItem> items, String targetLabel) {
    for (CompletionItem item : items) {
        if (item.getLabel().equalsIgnoreCase(targetLabel)) {
            CompletionItem clone = new CompletionItem(targetLabel);
            clone.setAdditionalTextEdits(item.getAdditionalTextEdits());
            clone.setCommand(item.getCommand());
            clone.setData(item.getData());
            clone.setDetail(item.getDetail());
            clone.setFilterText(item.getFilterText());
            clone.setInsertText(item.getInsertText());
            clone.setInsertTextFormat(item.getInsertTextFormat());
            clone.setDocumentation(item.getDocumentation());
            clone.setDeprecated(item.getDeprecated());
            clone.setKind(item.getKind());
            clone.setSortText(item.getSortText());
            clone.setPreselect(item.getPreselect());
            clone.setTextEdit(item.getTextEdit());
            return clone;
        }
    }
    return null;
}
 
Example 5
Source File: DdlCompletionItemLoader.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public CompletionItem getCreateViewInnerJoinCompletionItem(int data, String sortValue) {
    CompletionItem ci = new CompletionItem();
    ci.setLabel("CREATE VIEW with INNER JOIN");
    ci.setInsertText(QueryExpressionHelper.CREATE_VIEW_INNER_JOIN_INSERT_TEXT);
    ci.setKind(CompletionItemKind.Snippet);
    ci.setInsertTextFormat(InsertTextFormat.Snippet);
    ci.setDetail(" CREATE VIEW with inner join");
    ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText()));
    ci.setData(data);
    ci.setPreselect(true);
    ci.setSortText(sortValue);
    return ci;
}
 
Example 6
Source File: CompletionProvider.java    From vscode-as3mxml with Apache License 2.0 5 votes vote down vote up
private void addMXMLLanguageTagToAutoComplete(String tagName, String prefix, boolean includeOpenTagBracket, boolean includeOpenTagPrefix, CompletionList result)
{
    List<CompletionItem> items = result.getItems();
    CompletionItem item = new CompletionItem();
    item.setKind(CompletionItemKind.Keyword);
    item.setLabel("fx:" + tagName);
    if (completionSupportsSnippets)
    {
        item.setInsertTextFormat(InsertTextFormat.Snippet);
    }
    item.setFilterText(tagName);
    item.setSortText(tagName);
    StringBuilder builder = new StringBuilder();
    if (includeOpenTagBracket)
    {
        builder.append("<");
    }
    if (includeOpenTagPrefix)
    {
        builder.append(prefix);
        builder.append(IMXMLCoreConstants.colon);
    }
    builder.append(tagName);
    builder.append(">");
    builder.append("\n");
    builder.append("\t");
    if (completionSupportsSnippets)
    {
        builder.append("$0");
    }
    builder.append("\n");
    builder.append("<");
    builder.append(IMXMLCoreConstants.slash);
    builder.append(prefix);
    builder.append(IMXMLCoreConstants.colon);
    builder.append(tagName);
    builder.append(">");
    item.setInsertText(builder.toString());
    items.add(item);
}
 
Example 7
Source File: SnippetCompletionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static CompletionItem getRecordSnippet(SnippetCompletionContext scc, IProgressMonitor monitor) {
	ICompilationUnit cu = scc.getCompilationUnit();
	IJavaProject javaProject = cu.getJavaProject();
	if (javaProject == null) {
		return null;
	}
	String version = javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true);
	if (JavaModelUtil.isVersionLessThan(version, JavaCore.VERSION_14)) {
		//not checking if preview features are enabled, as Java 14+ might support records without preview flag
		return null;
	}
	if (!accept(cu, scc.getCompletionContext(), false /* Or should it be true???*/)) {
		return null;
	}
	if (monitor.isCanceled()) {
		return null;
	}
	final CompletionItem recordSnippet = new CompletionItem();
	recordSnippet.setFilterText(RECORD_SNIPPET_LABEL);
	recordSnippet.setLabel(RECORD_SNIPPET_LABEL);
	recordSnippet.setSortText(SortTextHelper.convertRelevance(0));

	try {
		CodeGenerationTemplate template = (scc.needsPublic(monitor)) ? CodeGenerationTemplate.RECORDSNIPPET_PUBLIC : CodeGenerationTemplate.RECORDSNIPPET_DEFAULT;
		recordSnippet.setInsertText(getSnippetContent(scc, template, true));
		setFields(recordSnippet, cu);
	} catch (CoreException e) {
		JavaLanguageServerPlugin.log(e.getStatus());
		return null;
	}
	return recordSnippet;
}
 
Example 8
Source File: CompletionProposalRequestor.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * To completion item.
 * @param proposal proposal
 * @param index index
 * @return CompletionItem
 */
public CompletionItem toCompletionItem(CompletionProposal proposal, int index) {
    final CompletionItem $ = new CompletionItem();
    $.setKind(mapKind(proposal.getKind()));
    Map<String, String> data = new HashMap<>();
    data.put(CompletionResolveHandler.DATA_FIELD_REQUEST_ID, String.valueOf(response.getId()));
    data.put(CompletionResolveHandler.DATA_FIELD_PROPOSAL_ID, String.valueOf(index));
    $.setData(data);
    this.descriptionProvider.updateDescription(proposal, $);
    adjustCompleteItem($);
    $.setSortText(SortTextHelper.computeSortText(proposal));
    return $;
}
 
Example 9
Source File: DdlCompletionItemLoader.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public CompletionItem getCreateViewUnionCompletionItem(int data, String sortValue) {
    CompletionItem ci = new CompletionItem();
    ci.setLabel("CREATE VIEW with UNION");
    ci.setInsertText(QueryExpressionHelper.CREATE_VIEW_UNION_INSERT_TEXT);
    ci.setKind(CompletionItemKind.Snippet);
    ci.setInsertTextFormat(InsertTextFormat.Snippet);
    ci.setDetail(" Union of two tables from single source");
    ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText()));
    ci.setData(data);
    ci.setPreselect(true);
    ci.setSortText(sortValue);
    return ci;
}
 
Example 10
Source File: DdlCompletionItemLoader.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public CompletionItem getCreateViewJoinCompletionItem(int data, String sortValue) {
    CompletionItem ci = new CompletionItem();
    ci.setLabel("CREATE VIEW with JOIN");
    ci.setInsertText(QueryExpressionHelper.CREATE_VIEW_LEFT_OUTER_JOIN_INSERT_TEXT);
    ci.setKind(CompletionItemKind.Snippet);
    ci.setInsertTextFormat(InsertTextFormat.Snippet);
    ci.setDetail(" CREATE VIEW with left join");
    ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText()));
    ci.setData(data);
    ci.setPreselect(true);
    ci.setSortText(sortValue);
    return ci;
}
 
Example 11
Source File: XMLCompletions.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
private void collectionRegionProposals(ICompletionRequest request, ICompletionResponse response) {
	// Completion for #region
	try {
		int offset = request.getOffset();
		TextDocument document = request.getXMLDocument().getTextDocument();
		Position pos = document.positionAt(offset);
		String lineText = document.lineText(pos.getLine());
		String lineUntilPos = lineText.substring(0, pos.getCharacter());
		Matcher match = regionCompletionRegExpr.matcher(lineUntilPos);
		if (match.find()) {
			InsertTextFormat insertFormat = request.getInsertTextFormat();
			Range range = new Range(new Position(pos.getLine(), pos.getCharacter() + match.regionStart()), pos);

			String text = request.isCompletionSnippetsSupported() ? "<!-- #region $1-->" : "<!-- #region -->";
			CompletionItem beginProposal = new CompletionItem("#region");
			beginProposal.setTextEdit(new TextEdit(range, text));
			beginProposal.setDocumentation("Insert Folding Region Start");
			beginProposal.setFilterText(match.group());
			beginProposal.setSortText("za");
			beginProposal.setKind(CompletionItemKind.Snippet);
			beginProposal.setInsertTextFormat(insertFormat);
			response.addCompletionAttribute(beginProposal);

			CompletionItem endProposal = new CompletionItem("#endregion");
			endProposal.setTextEdit(new TextEdit(range, "<!-- #endregion-->"));
			endProposal.setDocumentation("Insert Folding Region End");
			endProposal.setFilterText(match.group());
			endProposal.setSortText("zb");
			endProposal.setKind(CompletionItemKind.Snippet);
			endProposal.setInsertTextFormat(InsertTextFormat.PlainText);
			response.addCompletionAttribute(endProposal);
		}
	} catch (BadLocationException e) {
		LOGGER.log(Level.SEVERE, "While performing collectRegionCompletion", e);
	}
}
 
Example 12
Source File: DdlCompletionItemLoader.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public CompletionItem getCreateViewCompletionItem(int data, String sortValue) {
    CompletionItem ci = new CompletionItem();
    ci.setLabel("CREATE VIEW...");
    ci.setInsertText(QueryExpressionHelper.CREATE_VIEW_INSERT_TEXT);
    ci.setKind(CompletionItemKind.Snippet);
    ci.setInsertTextFormat(InsertTextFormat.Snippet);
    ci.setDetail("Simple CREATE VIEW statement");
    ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText()));
    ci.setData(data);
    ci.setPreselect(true);
    ci.setSortText(sortValue);
    return ci;
}
 
Example 13
Source File: ContentAssistService.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public CompletionList createCompletionList(Document document, XtextResource resource, CompletionParams params,
		CancelIndicator cancelIndicator) {
	try {
		CompletionList result = new CompletionList();
		result.setIsIncomplete(true);
		IdeContentProposalAcceptor acceptor = proposalAcceptorProvider.get();
		int caretOffset = document.getOffSet(params.getPosition());
		Position caretPosition = params.getPosition();
		TextRegion position = new TextRegion(caretOffset, 0);
		try {
			createProposals(document.getContents(), position, caretOffset, resource, acceptor);
		} catch (Throwable t) {
			if (!operationCanceledManager.isOperationCanceledException(t)) {
				throw t;
			}
		}
		int idx = 0;
		for (ContentAssistEntry it : acceptor.getEntries()) {
			CompletionItem item = toCompletionItem(it, caretOffset, caretPosition, document);
			item.setSortText(Strings.padStart(Integer.toString(idx), 5, '0'));
			result.getItems().add(item);
			idx++;
		}
		return result;
	} catch (Throwable e) {
		throw Exceptions.sneakyThrow(e);
	}
}
 
Example 14
Source File: TableBodyCompletionProvider.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public CompletionItem getPrimaryKeyCompletionItem(int data) {
    CompletionItem ci = new CompletionItem();
    ci.setLabel("PRIMARY KEY (column, ...)");
    ci.setInsertText("PRIMARY KEY (${1:column})");
    ci.setKind(CompletionItemKind.Snippet);
    ci.setInsertTextFormat(InsertTextFormat.Snippet);
    ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText()));
    ci.setData(data);
    ci.setPreselect(true);
    ci.setSortText("1120");
    return ci;
}
 
Example 15
Source File: TableBodyCompletionProvider.java    From syndesis with Apache License 2.0 5 votes vote down vote up
public CompletionItem getColumnCompletionItem(int data) {
    CompletionItem ci = new CompletionItem();
    ci.setLabel("column definition");
    ci.setInsertText("${1:column_name} ${2:datatype}");
    ci.setKind(CompletionItemKind.Snippet);
    ci.setInsertTextFormat(InsertTextFormat.Snippet);
    ci.setDocumentation(CompletionItemBuilder.beautifyDocument(ci.getInsertText()));
    ci.setData(data);
    ci.setPreselect(true);
    ci.setSortText("1100");
    return ci;
}
 
Example 16
Source File: QueryExpressionItemProvider.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private List<CompletionItem> getWhereClauseItems(TokenContext tokenContext) {
    List<CompletionItem> items = new ArrayList<CompletionItem>();
    items.addAll(metadataItemProvider.getCompletionItems(tokenContext));
    if (tokenContext.getContext() != Context.WHERE_CLAUSE_TABLE_ALIAS) {
        items.addAll(getItemLoader().getQueryExpressionKeywordItems());
    } else if (tokenContext.getContext() == Context.WHERE_CLAUSE_START) {
        CompletionItem whereItem = getItemLoader().cloneQueryExpressionKeywordItem("WHERE");
        whereItem.setSortText("900");
        items.add(whereItem);
    }
    return items;
}
 
Example 17
Source File: JavadocCompletionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public List<CompletionItem> getProposals(ICompilationUnit cu, int offset, CompletionProposalRequestor collector, IProgressMonitor monitor) throws JavaModelException {
	if (cu == null) {
		throw new IllegalArgumentException("Compilation unit must not be null"); //$NON-NLS-1$
	}
	List<CompletionItem> result = new ArrayList<>();
	IDocument d = JsonRpcHelpers.toDocument(cu.getBuffer());
	if (offset < 0 || d.getLength() == 0) {
		return result;
	}
	try {
		int p = (offset == d.getLength() ? offset - 1 : offset);
		IRegion line = d.getLineInformationOfOffset(p);
		String lineStr = d.get(line.getOffset(), line.getLength()).trim();
		if (!lineStr.startsWith("/**")) {
			return result;
		}
		if (!hasEndJavadoc(d, offset)) {
			return result;
		}
		String text = collector.getContext().getToken() == null ? "" : new String(collector.getContext().getToken());
		StringBuilder buf = new StringBuilder(text);
		IRegion prefix = findPrefixRange(d, line);
		String indentation = d.get(prefix.getOffset(), prefix.getLength());
		int lengthToAdd = Math.min(offset - prefix.getOffset(), prefix.getLength());
		buf.append(indentation.substring(0, lengthToAdd));
		String lineDelimiter = TextUtilities.getDefaultLineDelimiter(d);
		ICompilationUnit unit = cu;
		try {
			unit.reconcile(ICompilationUnit.NO_AST, false, null, null);
			String string = createJavaDocTags(d, offset, indentation, lineDelimiter, unit);
			if (string != null && !string.trim().equals(ASTERISK)) {
				buf.append(string);
			} else {
				return result;
			}
			int nextNonWS = findEndOfWhiteSpace(d, offset, d.getLength());
			if (!Character.isWhitespace(d.getChar(nextNonWS))) {
				buf.append(lineDelimiter);
			}
		} catch (CoreException e) {
			// ignore
		}
		final CompletionItem ci = new CompletionItem();
		Range range = JDTUtils.toRange(unit, offset, 0);
		boolean isSnippetSupported = JavaLanguageServerPlugin.getPreferencesManager().getClientPreferences().isCompletionSnippetsSupported();
		String replacement = prepareTemplate(buf.toString(), lineDelimiter, isSnippetSupported);
		ci.setTextEdit(new TextEdit(range, replacement));
		ci.setFilterText(JAVA_DOC_COMMENT);
		ci.setLabel(JAVA_DOC_COMMENT);
		ci.setSortText(SortTextHelper.convertRelevance(0));
		ci.setKind(CompletionItemKind.Snippet);
		ci.setInsertTextFormat(isSnippetSupported ? InsertTextFormat.Snippet : InsertTextFormat.PlainText);
		String documentation = prepareTemplate(buf.toString(), lineDelimiter, false);
		if (documentation.indexOf(lineDelimiter) == 0) {
			documentation = documentation.replaceFirst(lineDelimiter, "");
		}
		ci.setDocumentation(documentation);
		Map<String, String> data = new HashMap<>(3);
		data.put(CompletionResolveHandler.DATA_FIELD_URI, JDTUtils.toURI(cu));
		data.put(CompletionResolveHandler.DATA_FIELD_REQUEST_ID, "0");
		data.put(CompletionResolveHandler.DATA_FIELD_PROPOSAL_ID, "0");
		ci.setData(data);
		result.add(ci);
	} catch (BadLocationException excp) {
		// stop work
	}
	return result;
}
 
Example 18
Source File: CompletionItemBuilder.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public List<CompletionItem> setItemsSortText(List<CompletionItem> items, String sortText) {
    for (CompletionItem item : items) {
        item.setSortText(sortText);
    }
    return items;
}
 
Example 19
Source File: MetadataItemProvider.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public static List<MetadataCompletionItem> createItems(RestViewSourceInfo schemaInfo, String virtualizationName,
        String viewName) {
    List<MetadataCompletionItem> items = new ArrayList<MetadataCompletionItem>();

    logDebug("  MetadataItemProvider.createItems() for >>  virtualizationName = " + virtualizationName
            + "  viewName = " + viewName);

    if (schemaInfo == null) {
        logDebug("No metadata items returned. SCHEMA INFO == NULL");
        return items;
    }

    Set<String> allLabels = new HashSet<String>();

    for (RestSourceSchema nextSchema : schemaInfo.getSchemas()) {

        CompletionItem schemaItem = new CompletionItem(nextSchema.getName());
        schemaItem.setKind(CompletionItemKind.Text);
        schemaItem.setSortText(SORT_WEIGHT_1080);
        MetadataCompletionItem metadataCompetionItem = new MetadataCompletionItem(schemaItem, MetadataType.SCHEMA,
                nextSchema.getName(), null, null);
        addItem(items, allLabels, metadataCompetionItem);

        for (RestSourceTable nextTable : nextSchema.getTables()) {

            // We don't want to return items for the targeted View Definition
            // 1) Check the nextTable name == viewName
            // 2) Check the virtualizationName with the
            // 3) If they both match, then call break; to skip generation

            boolean doNextTable = true;

            if (virtualizationName != null && virtualizationName.equalsIgnoreCase(nextSchema.getName())) {
                doNextTable = !nextTable.getName().equalsIgnoreCase(viewName);
            }

            if (doNextTable) {
                CompletionItem tableItem = new CompletionItem(nextTable.getName());
                tableItem.setKind(CompletionItemKind.Text);
                metadataCompetionItem = new MetadataCompletionItem(tableItem, MetadataType.TABLE,
                        nextSchema.getName(), nextTable.getName(), null);
                setSortText(metadataCompetionItem);
                addItem(items, allLabels, metadataCompetionItem);

                CompletionItem schemaTableItem = new CompletionItem(getFQName(nextSchema, nextTable));
                schemaTableItem.setKind(CompletionItemKind.Text);
                schemaTableItem.setSortText(SORT_WEIGHT_1080);
                metadataCompetionItem = new MetadataCompletionItem(schemaTableItem, MetadataType.SCHEMA_TABLE,
                        nextSchema.getName(), nextTable.getName(), null);
                setSortText(metadataCompetionItem);
                addItem(items, allLabels, metadataCompetionItem);

                for (RestSourceColumn nextColumn : nextTable.getColumns()) {
                    CompletionItem columnItem = new CompletionItem(nextColumn.getName());
                    columnItem.setKind(CompletionItemKind.Text);
                    columnItem.setSortText(SORT_WEIGHT_1050);
                    metadataCompetionItem = new MetadataCompletionItem(columnItem, MetadataType.COLUMN,
                            nextSchema.getName(), nextTable.getName(), nextColumn.getName());
                    setSortText(metadataCompetionItem);
                    addItem(items, allLabels, metadataCompetionItem);

                    CompletionItem tableColumnItem = new CompletionItem(getFQName(nextTable, nextColumn));
                    tableColumnItem.setKind(CompletionItemKind.Text);
                    tableColumnItem.setSortText(SORT_WEIGHT_1080);
                    metadataCompetionItem = new MetadataCompletionItem(tableColumnItem, MetadataType.TABLE_COLUMN,
                            nextSchema.getName(), nextTable.getName(), nextColumn.getName());
                    setSortText(metadataCompetionItem);
                    addItem(items, allLabels, metadataCompetionItem);

                    CompletionItem schemaTableColumnItem = new CompletionItem(
                            getFQName(nextSchema, nextTable, nextColumn));
                    schemaTableColumnItem.setKind(CompletionItemKind.Text);
                    schemaTableColumnItem.setSortText(SORT_WEIGHT_1100);
                    metadataCompetionItem = new MetadataCompletionItem(schemaTableColumnItem,
                            MetadataType.SCHEMA_TABLE_COLUMN, nextSchema.getName(), nextTable.getName(),
                            nextColumn.getName());
                    setSortText(metadataCompetionItem);
                    addItem(items, allLabels, metadataCompetionItem);
                }
            }
        }
    }
    logDebug("  RETURNING [ " + items.size() + " ] MetadataCompletionItems from createItems() ");
    return items;
}
 
Example 20
Source File: CompletionProvider.java    From vscode-as3mxml with Apache License 2.0 4 votes vote down vote up
private void addRootMXMLLanguageTagsToAutoComplete(IMXMLTagData offsetTag, String prefix, boolean includeOpenTagPrefix, boolean includeOpenTagBracket, CompletionList result)
{
    List<CompletionItem> items = result.getItems();
                        
    CompletionItem item = new CompletionItem();
    item.setKind(CompletionItemKind.Keyword);
    item.setLabel("fx:" + IMXMLLanguageConstants.SCRIPT);
    if (completionSupportsSnippets)
    {
        item.setInsertTextFormat(InsertTextFormat.Snippet);
    }
    item.setFilterText(IMXMLLanguageConstants.SCRIPT);
    item.setSortText(IMXMLLanguageConstants.SCRIPT);
    StringBuilder builder = new StringBuilder();
    if (includeOpenTagBracket)
    {
        builder.append("<");
    }
    if (includeOpenTagPrefix)
    {
        builder.append(prefix);
        builder.append(IMXMLCoreConstants.colon);
    }
    builder.append(IMXMLLanguageConstants.SCRIPT);
    builder.append(">");
    builder.append("\n");
    builder.append("\t");
    builder.append(IMXMLCoreConstants.cDataStart);
    builder.append("\n");
    builder.append("\t\t");
    if (completionSupportsSnippets)
    {
        builder.append("$0");
    }
    builder.append("\n");
    builder.append("\t");
    builder.append(IMXMLCoreConstants.cDataEnd);
    builder.append("\n");
    builder.append("<");
    builder.append(IMXMLCoreConstants.slash);
    builder.append(prefix);
    builder.append(IMXMLCoreConstants.colon);
    builder.append(IMXMLLanguageConstants.SCRIPT);
    builder.append(">");
    item.setInsertText(builder.toString());
    items.add(item);

    addMXMLLanguageTagToAutoComplete(IMXMLLanguageConstants.BINDING, prefix, includeOpenTagBracket, includeOpenTagPrefix, result);
    addMXMLLanguageTagToAutoComplete(IMXMLLanguageConstants.DECLARATIONS, prefix, includeOpenTagBracket, includeOpenTagPrefix, result);
    addMXMLLanguageTagToAutoComplete(IMXMLLanguageConstants.METADATA, prefix, includeOpenTagBracket, includeOpenTagPrefix, result);
    addMXMLLanguageTagToAutoComplete(IMXMLLanguageConstants.STYLE, prefix, includeOpenTagBracket, includeOpenTagPrefix, result);
}