use of org.apache.flex.compiler.definitions.IClassDefinition in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method getDefinitionForMXMLTag.
private IDefinition getDefinitionForMXMLTag(IMXMLTagData tag) {
if (tag == null) {
return null;
}
IDefinition offsetDefinition = currentProject.resolveXMLNameToDefinition(tag.getXMLName(), tag.getMXMLDialect());
if (offsetDefinition != null) {
return offsetDefinition;
}
if (tag.getXMLName().getXMLNamespace().equals(tag.getMXMLDialect().getLanguageNamespace())) {
for (String typeName : LANGUAGE_TYPE_NAMES) {
if (tag.getShortName().equals(typeName)) {
return currentProject.resolveQNameToDefinition(typeName);
}
}
}
IMXMLTagData parentTag = tag.getParentTag();
if (parentTag == null) {
return null;
}
IDefinition parentDefinition = currentProject.resolveXMLNameToDefinition(parentTag.getXMLName(), parentTag.getMXMLDialect());
if (parentDefinition == null || !(parentDefinition instanceof IClassDefinition)) {
return null;
}
IClassDefinition classDefinition = (IClassDefinition) parentDefinition;
return currentProject.resolveSpecifier(classDefinition, tag.getShortName());
}
use of org.apache.flex.compiler.definitions.IClassDefinition in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method getDefinitionForMXMLTagAttribute.
private IDefinition getDefinitionForMXMLTagAttribute(IMXMLTagData tag, int offset, boolean includeValue) {
IMXMLTagAttributeData attributeData = null;
if (includeValue) {
attributeData = getMXMLTagAttributeAtOffset(tag, offset);
} else {
attributeData = getMXMLTagAttributeWithNameAtOffset(tag, offset);
}
if (attributeData == null) {
return null;
}
IDefinition tagDefinition = getDefinitionForMXMLTag(tag);
if (tagDefinition != null && tagDefinition instanceof IClassDefinition) {
IClassDefinition classDefinition = (IClassDefinition) tagDefinition;
return currentProject.resolveSpecifier(classDefinition, attributeData.getShortName());
}
return null;
}
use of org.apache.flex.compiler.definitions.IClassDefinition 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