Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function interpolationCompletions(info, position) {
// Look for an interpolation in at the position.
var templatePath = utils_1.findTemplateAstAt(info.templateAst, position);
var mostSpecific = templatePath.tail;
if (mostSpecific) {
var visitor = new ExpressionVisitor(info, position, undefined, function () { return language_services_1.getExpressionScope(utils_1.diagnosticInfoFromTemplateInfo(info), templatePath, false); });
mostSpecific.visit(visitor, null);
return utils_1.uniqueByName(visitor.result);
}
}
// There is a special case of HTML where text that contains a unclosed tag is treated as
function attributeValueCompletions(info, position, attr) {
var path = utils_1.findTemplateAstAt(info.templateAst, position);
var mostSpecific = path.tail;
var dinfo = utils_1.diagnosticInfoFromTemplateInfo(info);
if (mostSpecific) {
var visitor = new ExpressionVisitor(info, position, attr, function () { return language_services_1.getExpressionScope(dinfo, path, false); });
mostSpecific.visit(visitor, null);
if (!visitor.result || !visitor.result.length) {
// Try allwoing widening the path
var widerPath_1 = utils_1.findTemplateAstAt(info.templateAst, position, /* allowWidening */ true);
if (widerPath_1.tail) {
var widerVisitor = new ExpressionVisitor(info, position, attr, function () { return language_services_1.getExpressionScope(dinfo, widerPath_1, false); });
widerPath_1.tail.visit(widerVisitor, null);
return widerVisitor.result;
}
}
return visitor.result;
}
}
function elementCompletions(info, path) {
function attributeValueCompletions(info, position, attr) {
var path = utils_1.findTemplateAstAt(info.templateAst, position);
var mostSpecific = path.tail;
var dinfo = utils_1.diagnosticInfoFromTemplateInfo(info);
if (mostSpecific) {
var visitor = new ExpressionVisitor(info, position, attr, function () { return language_services_1.getExpressionScope(dinfo, path, false); });
mostSpecific.visit(visitor, null);
if (!visitor.result || !visitor.result.length) {
// Try allwoing widening the path
var widerPath_1 = utils_1.findTemplateAstAt(info.templateAst, position, /* allowWidening */ true);
if (widerPath_1.tail) {
var widerVisitor = new ExpressionVisitor(info, position, attr, function () { return language_services_1.getExpressionScope(dinfo, widerPath_1, false); });
widerPath_1.tail.visit(widerVisitor, null);
return widerVisitor.result;
}
}
return visitor.result;
}
function attributeValueCompletions(info, position, attr) {
var path = utils_1.findTemplateAstAt(info.templateAst, position);
var mostSpecific = path.tail;
var dinfo = utils_1.diagnosticInfoFromTemplateInfo(info);
if (mostSpecific) {
var visitor = new ExpressionVisitor(info, position, attr, function () { return language_services_1.getExpressionScope(dinfo, path, false); });
mostSpecific.visit(visitor, null);
if (!visitor.result || !visitor.result.length) {
// Try allwoing widening the path
var widerPath_1 = utils_1.findTemplateAstAt(info.templateAst, position, /* allowWidening */ true);
if (widerPath_1.tail) {
var widerVisitor = new ExpressionVisitor(info, position, attr, function () { return language_services_1.getExpressionScope(dinfo, widerPath_1, false); });
widerPath_1.tail.visit(widerVisitor, null);
return widerVisitor.result;
}
}
return visitor.result;
}
}
function elementCompletions(info, path) {
function interpolationCompletions(info, position) {
// Look for an interpolation in at the position.
var templatePath = utils_1.findTemplateAstAt(info.templateAst, position);
var mostSpecific = templatePath.tail;
if (mostSpecific) {
var visitor = new ExpressionVisitor(info, position, undefined, function () { return language_services_1.getExpressionScope(utils_1.diagnosticInfoFromTemplateInfo(info), templatePath, false); });
mostSpecific.visit(visitor, null);
return utils_1.uniqueByName(visitor.result);
}
}
// There is a special case of HTML where text that contains a unclosed tag is treated as
visitBoundText: function (ast) {
var expressionPosition = templatePosition - ast.sourceSpan.start.offset;
if (utils_1.inSpan(expressionPosition, ast.value.span)) {
var dinfo = utils_1.diagnosticInfoFromTemplateInfo(info);
var scope = language_services_1.getExpressionScope(dinfo, path, /* includeEvent */ false);
var result = expressions_1.getExpressionSymbol(scope, ast.value, expressionPosition, info.template.query);
if (result) {
symbol_1 = result.symbol;
span_1 = utils_1.offsetSpan(result.span, ast.sourceSpan.start.offset);
}
}
},
visitText: function (ast) { },
var binding = bindings.find(function (binding) { return utils_1.inSpan(valueRelativePosition_1, binding.span, /* exclusive */ true); }) ||
bindings.find(function (binding) { return utils_1.inSpan(valueRelativePosition_1, binding.span); });
visitAttribute: function (ast) {
if (!ast.valueSpan || !utils_1.inSpan(templatePosition_1, utils_1.spanOf(ast.valueSpan))) {
// We are in the name of an attribute. Show attribute completions.
result = attributeCompletions(templateInfo, path_1);
}
else if (ast.valueSpan && utils_1.inSpan(templatePosition_1, utils_1.spanOf(ast.valueSpan))) {
result = attributeValueCompletions(templateInfo, templatePosition_1, ast);
}
},
visitText: function (ast) {
var directiveMetadata = selectorInfo.map.get(selector_1);
if (directiveMetadata) {
var contextTable = this.info.template.query.getTemplateContext(directiveMetadata.type.reference);
if (contextTable) {
this.result = this.symbolsToCompletions(contextTable.values());
}
}
}
else if (binding.key && valueRelativePosition_1 <= (binding.key.length - key_1.length)) {
keyCompletions();
}
}
else {
// If the position is in the expression or after the key or there is no key, return the
// expression completions
if ((binding.expression && utils_1.inSpan(valueRelativePosition_1, binding.expression.ast.span)) ||
(binding.key &&
valueRelativePosition_1 > binding.span.start + (binding.key.length - key_1.length)) ||
!binding.key) {
var span = new compiler_1.ParseSpan(0, this.attr.value.length);
this.attributeValueCompletions(binding.expression ? binding.expression.ast :
new compiler_1.PropertyRead(span, new compiler_1.ImplicitReceiver(span), ''), valueRelativePosition_1);
}
else {
keyCompletions();
}
}
}
};
ExpressionVisitor.prototype.visitBoundText = function (ast) {
visitAttribute: function (ast) {
if (!ast.valueSpan || !utils_1.inSpan(templatePosition_1, utils_1.spanOf(ast.valueSpan))) {
// We are in the name of an attribute. Show attribute completions.
result = attributeCompletions(templateInfo, path_1);
}
else if (ast.valueSpan && utils_1.inSpan(templatePosition_1, utils_1.spanOf(ast.valueSpan))) {
result = attributeValueCompletions(templateInfo, templatePosition_1, ast);
}
},
visitText: function (ast) {