use of org.eclipse.lsp4j.CompletionItem in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method mxmlAttributeCompletion.
private CompletableFuture<CompletionList> mxmlAttributeCompletion(IMXMLTagData offsetTag, CompletionList result) {
List<CompletionItem> items = result.getItems();
IDefinition attributeDefinition = getDefinitionForMXMLTagAttribute(offsetTag, currentOffset, true);
if (attributeDefinition instanceof IVariableDefinition) {
IVariableDefinition variableDefinition = (IVariableDefinition) attributeDefinition;
if (variableDefinition.getTypeAsDisplayString().equals(IASLanguageConstants.Boolean)) {
CompletionItem falseItem = new CompletionItem();
falseItem.setKind(CompletionItemKind.Value);
falseItem.setLabel(IASLanguageConstants.FALSE);
items.add(falseItem);
CompletionItem trueItem = new CompletionItem();
trueItem.setKind(CompletionItemKind.Value);
trueItem.setLabel(IASLanguageConstants.TRUE);
items.add(trueItem);
return CompletableFuture.completedFuture(result);
}
}
return CompletableFuture.completedFuture(result);
}
use of org.eclipse.lsp4j.CompletionItem in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method autoCompletePackageName.
private void autoCompletePackageName(String partialPackageName, CompletionList result) {
String expectedPackage = getExpectedPackage(currentUnit);
if (expectedPackage.length() == 0) {
//it's the top level package
return;
}
if (partialPackageName.startsWith(expectedPackage)) {
//we already have the correct package, maybe with some extra
return;
}
if (partialPackageName.contains(".") && expectedPackage.startsWith(partialPackageName)) {
int lastDot = partialPackageName.lastIndexOf('.');
expectedPackage = expectedPackage.substring(lastDot + 1);
}
CompletionItem item = new CompletionItem();
item.setKind(CompletionItemKind.Module);
item.setLabel(expectedPackage);
result.getItems().add(item);
}
use of org.eclipse.lsp4j.CompletionItem in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method addDefinitionAutoCompleteMXML.
private void addDefinitionAutoCompleteMXML(IDefinition definition, String prefix, String uri, CompletionList result) {
if (definition.getBaseName().startsWith(VECTOR_HIDDEN_PREFIX)) {
return;
}
CompletionItem item = new CompletionItem();
item.setKind(getDefinitionKind(definition));
item.setDetail(getDefinitionDetail(definition));
item.setLabel(definition.getBaseName());
if (prefix != null) {
item.setInsertText(prefix + IMXMLCoreConstants.colon + definition.getBaseName());
if (definition instanceof ITypeDefinition && uri != null) {
item.setCommand(createMXMLNamespaceCommand(definition, prefix, uri));
}
}
result.getItems().add(item);
}
use of org.eclipse.lsp4j.CompletionItem in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method addEventMetadataToAutoCompleteMXML.
private void addEventMetadataToAutoCompleteMXML(TypeScope typeScope, String prefix, CompletionList result) {
ArrayList<String> eventNames = new ArrayList<>();
IDefinition definition = typeScope.getDefinition();
while (definition instanceof IClassDefinition) {
IClassDefinition classDefinition = (IClassDefinition) definition;
IMetaTag[] eventMetaTags = definition.getMetaTagsByName(IMetaAttributeConstants.ATTRIBUTE_EVENT);
for (IMetaTag eventMetaTag : eventMetaTags) {
String eventName = eventMetaTag.getAttributeValue(IMetaAttributeConstants.NAME_EVENT_NAME);
if (eventNames.contains(eventName)) {
//avoid duplicates!
continue;
}
eventNames.add(eventName);
IDefinition eventDefinition = currentProject.resolveSpecifier(classDefinition, eventName);
if (eventDefinition == null) {
continue;
}
CompletionItem item = new CompletionItem();
item.setKind(CompletionItemKind.Field);
item.setLabel(eventName);
if (prefix != null) {
item.setInsertText(prefix + IMXMLCoreConstants.colon + eventName);
}
item.setDetail(getDefinitionDetail(eventDefinition));
result.getItems().add(item);
}
definition = classDefinition.resolveBaseClass(currentProject);
}
}
Aggregations