adding refactoring to add global variable from the editor
This commit is contained in:
Родитель
c08ef7e10b
Коммит
41a527588a
|
@ -2423,7 +2423,23 @@ module TDev
|
|||
}
|
||||
|
||||
if (k.primaryKind instanceof AST.LibraryRefKind)
|
||||
s = s.filter(p => !(<AST.LibraryRefAction>p)._extensionAction);
|
||||
s = s.filter(p => !(<AST.LibraryRefAction>p)._extensionAction);
|
||||
|
||||
if (k.primaryKind.getName() == "data" && TheEditor.widgetEnabled("promoteRefactoring")) {
|
||||
var e1 = this.mkIntelliItem(1e-10, Ticks.calcAddDataVar);
|
||||
e1.matchAny = true;
|
||||
e1.nameOverride = lf("new global var");
|
||||
e1.descOverride = lf("create new data variable");
|
||||
e1.cbOverride = () => {
|
||||
var ds = TheEditor.freshVar(api.core.Number);
|
||||
ds.setName(Script.freshName(this.searchApi.query() || "v"));
|
||||
|
||||
this.insertToken(AST.mkPropRef(ds.getName()))
|
||||
|
||||
TheEditor.addNode(ds);
|
||||
};
|
||||
}
|
||||
|
||||
var downgradeConcat = false;
|
||||
if (k.definition != null)
|
||||
this.addGoTo(k.definition);
|
||||
|
@ -2454,10 +2470,10 @@ module TDev
|
|||
s.push(api.core.StringConcatProp); // always available
|
||||
downgradeConcat = true;
|
||||
}
|
||||
|
||||
|
||||
s = s.filter(p => p.isBrowsable() && (!profile || profile.hasProperty(p)));
|
||||
s = Calculator.sortDecls(s);
|
||||
|
||||
|
||||
s.forEach((p: IProperty) => {
|
||||
if (p.getInfixPriority() > 0 && p.getParameters().length == 1) {
|
||||
// unary prefix operator; skip
|
||||
|
|
|
@ -20,7 +20,8 @@ module TDev
|
|||
public isAttachedTo:Kind = null;
|
||||
public usageKey:string;
|
||||
public cornerIcon:string;
|
||||
public noButton:boolean;
|
||||
public noButton: boolean;
|
||||
public matchAny: boolean;
|
||||
|
||||
public getName()
|
||||
{
|
||||
|
@ -39,6 +40,7 @@ module TDev
|
|||
if (this.decl && this.decl.getKind() instanceof ThingSetKind) return 10;
|
||||
if (this.prop instanceof AST.LibraryRef) return 5;
|
||||
if (this.prop && !Script.canUseProperty(this.prop)) return -10;
|
||||
if (this.matchAny) return -1e10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -266,6 +268,7 @@ module TDev
|
|||
// Returns match quality
|
||||
public match(terms:string[], fullName:string)
|
||||
{
|
||||
if (this.matchAny) return this.score;
|
||||
if (!!this.prop) return IntelliItem.matchProp(this.prop, terms, fullName);
|
||||
if (terms.length == 0) return 1;
|
||||
var lowerName = this.getName().toLowerCase();
|
||||
|
|
|
@ -277,6 +277,8 @@ module TDev
|
|||
super.moveCarret(d);
|
||||
this.calc.onIntelliScroll();
|
||||
}
|
||||
|
||||
public query() : string { return this.searchBox.value; }
|
||||
|
||||
private searchKey() {
|
||||
this.searchBox.placeholder = "";
|
||||
|
|
|
@ -62,6 +62,7 @@ module TDev {
|
|||
calcPromoteToParameter,
|
||||
calcGoToDef,
|
||||
calcFindRefs,
|
||||
calcAddDataVar,
|
||||
calcUnselect,
|
||||
calcExtend,
|
||||
calcReplaceInScript,
|
||||
|
|
Загрузка…
Ссылка в новой задаче