use of org.apache.flex.compiler.definitions.IGetterDefinition in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method autoCompleteScope.
private void autoCompleteScope(IScopedNode node, boolean typesOnly, CompletionList result) {
IScopedNode currentNode = node;
ASScope scope = (ASScope) node.getScope();
while (currentNode != null) {
IASScope currentScope = currentNode.getScope();
boolean isType = currentScope instanceof TypeScope;
boolean staticOnly = currentNode == node && isType;
if (currentScope instanceof TypeScope && !typesOnly) {
TypeScope typeScope = (TypeScope) currentScope;
addDefinitionsInTypeScopeToAutoComplete(typeScope, scope, true, true, false, null, result);
if (!staticOnly) {
addDefinitionsInTypeScopeToAutoCompleteActionScript(typeScope, scope, false, result);
}
} else {
for (IDefinition localDefinition : currentScope.getAllLocalDefinitions()) {
if (localDefinition.getBaseName().length() == 0) {
continue;
}
if (typesOnly && !(localDefinition instanceof ITypeDefinition)) {
continue;
}
if (!staticOnly || localDefinition.isStatic()) {
if (localDefinition instanceof ISetterDefinition) {
ISetterDefinition setter = (ISetterDefinition) localDefinition;
IGetterDefinition getter = setter.resolveGetter(currentProject);
if (getter != null) {
//it would add a duplicate entry
continue;
}
}
addDefinitionAutoCompleteActionScript(localDefinition, result);
}
}
}
currentNode = currentNode.getContainingScope();
}
}
use of org.apache.flex.compiler.definitions.IGetterDefinition in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method addDefinitionsInTypeScopeToAutoComplete.
private void addDefinitionsInTypeScopeToAutoComplete(TypeScope typeScope, ASScope otherScope, boolean isStatic, boolean includeSuperStatics, boolean forMXML, String prefix, CompletionList result) {
IMetaTag[] excludeMetaTags = typeScope.getDefinition().getMetaTagsByName(IMetaAttributeConstants.ATTRIBUTE_EXCLUDE);
ArrayList<IDefinition> memberAccessDefinitions = new ArrayList<>();
Set<INamespaceDefinition> namespaceSet = otherScope.getNamespaceSet(currentProject);
if (typeScope.getContainingDefinition() instanceof IInterfaceDefinition) {
//interfaces have a special namespace that isn't actually the same
//as public, but should be treated the same way
IInterfaceDefinition interfaceDefinition = (IInterfaceDefinition) typeScope.getContainingDefinition();
collectInterfaceNamespaces(interfaceDefinition, namespaceSet);
}
IClassDefinition otherContainingClass = otherScope.getContainingClass();
if (otherContainingClass != null) {
IClassDefinition classDefinition = typeScope.getContainingClass();
if (classDefinition != null) {
boolean isSuperClass = Arrays.asList(otherContainingClass.resolveAncestry(currentProject)).contains(classDefinition);
if (isSuperClass) {
//namespaces from the super classes
do {
namespaceSet.add(classDefinition.getProtectedNamespaceReference());
classDefinition = classDefinition.resolveBaseClass(currentProject);
} while (classDefinition instanceof IClassDefinition);
}
}
}
typeScope.getAllPropertiesForMemberAccess(currentProject, memberAccessDefinitions, namespaceSet);
for (IDefinition localDefinition : memberAccessDefinitions) {
if (localDefinition.isOverride()) {
//overrides would add unnecessary duplicates to the list
continue;
}
if (excludeMetaTags != null && excludeMetaTags.length > 0) {
boolean exclude = false;
for (IMetaTag excludeMetaTag : excludeMetaTags) {
String excludeName = excludeMetaTag.getAttributeValue(IMetaAttributeConstants.NAME_EXCLUDE_NAME);
if (excludeName.equals(localDefinition.getBaseName())) {
exclude = true;
break;
}
}
if (exclude) {
continue;
}
}
//there are some things that we need to skip in MXML
if (forMXML) {
if (localDefinition instanceof IGetterDefinition) {
//no getters because we can only set
continue;
} else if (localDefinition instanceof IFunctionDefinition && !(localDefinition instanceof ISetterDefinition)) {
//no calling functions, unless they're setters
continue;
}
} else //actionscript
{
if (localDefinition instanceof ISetterDefinition) {
ISetterDefinition setter = (ISetterDefinition) localDefinition;
IGetterDefinition getter = setter.resolveGetter(currentProject);
if (getter != null) {
//would add a duplicate entry
continue;
}
}
}
if (isStatic) {
if (!localDefinition.isStatic()) {
//static, skip it
continue;
}
if (!includeSuperStatics && localDefinition.getParent() != typeScope.getContainingDefinition()) {
//aren't available with member access
continue;
}
}
if (!isStatic && localDefinition.isStatic()) {
//skip it!
continue;
}
if (forMXML) {
addDefinitionAutoCompleteMXML(localDefinition, prefix, null, result);
} else //actionscript
{
addDefinitionAutoCompleteActionScript(localDefinition, result);
}
}
}
Aggregations