public void GetSemanticExpansions(string filename, string tok, uint line, uint idx, string expr) { DModule ast = null; if (!_modules.TryGetValue(filename, out ast)) { throw new COMException("module not found", 1); } CodeLocation loc = new CodeLocation((int)idx + 1, (int)line); _editorData.SyntaxTree = ast as DModule; _editorData.ModuleCode = _sources[filename]; _editorData.CaretOffset = getCodeOffset(_editorData.ModuleCode, loc); // step back to beginning of identifier while (_editorData.CaretOffset > 0 && isIdentifierCharacter(_editorData.ModuleCode[_editorData.CaretOffset - 1])) { _editorData.CaretOffset--; if (idx > 0) { idx--; } } _editorData.CaretLocation = new CodeLocation((int)idx + 1, (int)line); VDServerCompletionDataGenerator cdgen = new VDServerCompletionDataGenerator(tok); AbstractCompletionProvider provider = AbstractCompletionProvider.BuildCompletionData(cdgen, _editorData, null); //tok _expansions = cdgen.expansions; }
public static void BuildCompletionData(Document EditorDocument, IAbstractSyntaxTree SyntaxTree, CodeCompletionContext ctx, CompletionDataList l, char triggerChar) { var deltaOffset = (char.IsLetter(triggerChar) || triggerChar == '_' || triggerChar == '@') ? 1 : 0; var caretOffset = ctx.TriggerOffset - deltaOffset; var caretLocation = new CodeLocation(ctx.TriggerLineOffset - deltaOffset, ctx.TriggerLine); var codeCache = EnumAvailableModules(EditorDocument); var edData = new EditorData { CaretLocation = caretLocation, CaretOffset = caretOffset, ModuleCode = EditorDocument.Editor.Text, SyntaxTree = SyntaxTree as DModule, ParseCache = codeCache, Options = DCompilerService.Instance.CompletionOptions }; AbstractCompletionProvider.BuildCompletionData( new CompletionDataGenerator { CompletionDataList = l }, edData, triggerChar == '\0'?null:triggerChar.ToString()); }
public static void BuildCompletionData(DEditorDocument EditorDocument, IList <ICompletionData> l, string EnteredText, out string lastResultPath) { lastResultPath = null; var provider = AbstractCompletionProvider.BuildCompletionData(new IDECompletionDataGenerator(l), EditorDocument, EnteredText); }
public static void BuildCompletionData(Document EditorDocument, IAbstractSyntaxTree SyntaxTree, CodeCompletionContext ctx, CompletionDataList l, char triggerChar) { bool removeChar = char.IsLetter(triggerChar) || triggerChar == '_' || triggerChar == '@'; var deltaOffset = 0; //removeChar ? 1 : 0; var caretOffset = ctx.TriggerOffset - (removeChar ? 1 : 0); var caretLocation = new CodeLocation(ctx.TriggerLineOffset - deltaOffset, ctx.TriggerLine); var codeCache = EnumAvailableModules(EditorDocument); var ed = new EditorData { CaretLocation = caretLocation, CaretOffset = caretOffset, ModuleCode = removeChar ? EditorDocument.Editor.Text.Remove(ctx.TriggerOffset - 1, 1) : EditorDocument.Editor.Text, SyntaxTree = SyntaxTree as DModule, ParseCache = codeCache, Options = DCompilerService.Instance.CompletionOptions }; if (EditorDocument.HasProject) { var cfg = EditorDocument.Project.GetConfiguration(Ide.IdeApp.Workspace.ActiveConfiguration) as DProjectConfiguration; if (cfg != null) { ed.GlobalDebugIds = cfg.CustomDebugIdentifiers; ed.IsDebug = cfg.DebugMode; ed.DebugLevel = cfg.DebugLevel; ed.GlobalVersionIds = cfg.GlobalVersionIdentifiers; double d; int v; if (Double.TryParse(EditorDocument.Project.Version, out d)) { ed.VersionNumber = (int)d; } else if (Int32.TryParse(EditorDocument.Project.Version, out v)) { ed.VersionNumber = v; } } } if (ed.GlobalVersionIds == null) { ed.GlobalVersionIds = VersionIdEvaluation.GetOSAndCPUVersions(); } AbstractCompletionProvider.BuildCompletionData( new CompletionDataGenerator { CompletionDataList = l }, ed, triggerChar == '\0'?null:triggerChar.ToString()); }
public static void BuildCompletionData(Document EditorDocument, DModule SyntaxTree, CodeCompletionContext ctx, CompletionDataList l, char triggerChar) { AbstractCompletionProvider.BuildCompletionData( new CompletionDataGenerator { CompletionDataList = l }, DResolverWrapper.CreateEditorData(EditorDocument, SyntaxTree as DModule, ctx, triggerChar), triggerChar == '\0'?null:triggerChar.ToString()); }
public void GetSemanticExpansions(string filename, string tok, uint line, uint idx, string expr) { IAbstractSyntaxTree ast = null; if (!_modules.TryGetValue(filename, out ast)) { throw new COMException("module not found", 1); } CodeLocation loc = new CodeLocation((int)idx, (int)line); EditorData editorData = new EditorData(); editorData.CaretLocation = loc; editorData.SyntaxTree = ast as DModule; editorData.ModuleCode = _sources[filename]; editorData.CaretOffset = getCodeOffset(editorData.ModuleCode, loc); VDServerCompletionDataGenerator cdgen = new VDServerCompletionDataGenerator(); AbstractCompletionProvider provider = AbstractCompletionProvider.BuildCompletionData(cdgen, editorData, tok); _expansions = cdgen.expansions; //MessageBox.Show("GetSemanticExpansions()"); //throw new NotImplementedException(); }
public override void Visit(PostfixExpression_Access x) { if (IsIncompleteExpression(x.AccessExpression)) { halt = true; if (x.PostfixForeExpression is DTokenDeclaration && (x.PostfixForeExpression as DTokenDeclaration).Token == DTokens.Dot) { // Handle module-scoped things: // When typing a dot without anything following, trigger completion and show types, methods and vars that are located in the module & import scope prv = new CtrlSpaceCompletionProvider (cdgen, scopedBlock, null, MemberFilter.Methods | MemberFilter.Types | MemberFilter.Variables | MemberFilter.TypeParameters ); } else prv = new MemberCompletionProvider (cdgen, x.PostfixForeExpression, scopedBlock, scopedStatement); } else base.Visit (x); }
public override void Visit(TokenExpression e) { if (e.Token == DTokens.Incomplete) { halt = true; const MemberFilter BaseAsmFlags = MemberFilter.Classes | MemberFilter.StructsAndUnions | MemberFilter.Enums | MemberFilter.Methods | MemberFilter.TypeParameters | MemberFilter.Types | MemberFilter.Variables; if (scopedStatement is AsmStatement || scopedStatement is AsmStatement.InstructionStatement) prv = new CtrlSpaceCompletionProvider(cdgen, scopedBlock, scopedStatement, BaseAsmFlags | MemberFilter.x86Registers | MemberFilter.x64Registers | MemberFilter.Labels); else if (scopedStatement is AsmStatement.RawDataStatement) prv = new CtrlSpaceCompletionProvider(cdgen, scopedBlock, scopedStatement, BaseAsmFlags | MemberFilter.Labels); else if (handlesInitializer) prv = new CtrlSpaceCompletionProvider (cdgen, scopedBlock, scopedStatement); } }
public override void Visit(AsmStatement.InstructionStatement s) { if (s.Operation == AsmStatement.InstructionStatement.OpCode.__UNKNOWN__) { prv = new InlineAsmCompletionProvider(s, cdgen); scopedStatement = s; halt = true; } else base.Visit(s); }
public override void Visit (ContinueStatement s) { if(s.IdentifierHash == DTokens.IncompleteIdHash) { prv = new CtrlSpaceCompletionProvider(cdgen, scopedBlock, MemberFilter.Labels); halt = true; } else base.Visit (s); }
public override void VisitDNode(DNode n) { if (n.NameHash == DTokens.IncompleteIdHash) { if (n.ContainsAttribute(DTokens.Override)) prv = new MethodOverrideCompletionProvider(n, cdgen); else explicitlyNoCompletion = true; halt = true; } else base.VisitDNode (n); }
public override void VisitAttribute(UserDeclarationAttribute a) { if (a.AttributeExpression != null && a.AttributeExpression.Length>0 && IsIncompleteExpression (a.AttributeExpression[0])) { prv = new CtrlSpaceCompletionProvider(cdgen, scopedBlock, scopedStatement, MemberFilter.BuiltInPropertyAttributes | MemberFilter.Methods | MemberFilter.Variables | MemberFilter.Types); halt = true; } else base.VisitAttribute (a); }
public override void VisitAttribute(Modifier a) { string c; if (a.ContentHash == DTokens.IncompleteIdHash || ((c = a.LiteralContent as string) != null && c.EndsWith(DTokens.IncompleteId))) { prv = new AttributeCompletionProvider (cdgen) { Attribute = a }; halt = true; } else base.VisitAttribute (a); }
public override void Visit(DTokenDeclaration td) { if (td.Token == DTokens.Incomplete) { if (handlesBaseClasses) { MemberFilter vis; if (handledClass.ClassType == DTokens.Interface) vis = MemberFilter.Interfaces | MemberFilter.Templates; else vis = MemberFilter.Classes | MemberFilter.Interfaces | MemberFilter.Templates; prv = new CtrlSpaceCompletionProvider (cdgen, handledClass, null, vis); } else if (td.InnerDeclaration != null) prv = new MemberCompletionProvider (cdgen, td.InnerDeclaration, scopedBlock, scopedStatement); else prv = new CtrlSpaceCompletionProvider (cdgen, scopedBlock, scopedStatement); halt = true; } else base.Visit (td); }
public override void Visit(DVariable n) { if (n.NameHash == 0 && n.ContainsAttribute(DTokens.Override)) { prv = new MethodOverrideCompletionProvider(n, cdgen); halt = true; return; } if (n.IsAlias) { // alias | // alias id = | // NOT alias Type | if (IsIncompleteDeclaration (n.Type)) { prv = new CtrlSpaceCompletionProvider (cdgen, scopedBlock,scopedStatement); halt = true; } }else if (n.Initializer != null) { handlesInitializer = true; n.Initializer.Accept (this); handlesInitializer = false; } if(!halt) VisitDNode(n); // auto | if(!halt && n.NameHash == 0 && n.ContainsAttribute (DTokens.Auto)) { halt = true; explicitlyNoCompletion = true; } }
public override void Visit(StructInitializer init) { if (initializedNode != null && init.MemberInitializers != null && init.MemberInitializers.Length != 0) { var lastMemberInit = init.MemberInitializers[init.MemberInitializers.Length - 1]; if (lastMemberInit.MemberNameHash == DTokens.IncompleteIdHash) { prv = new StructInitializerCompletion(cdgen,initializedNode, init); halt = true; return; } } base.Visit(init); }
public override void Visit (IsExpression x) { // is(Type | if (x.TypeAliasIdentifierHash == DTokens.IncompleteIdHash && x.TestedType != null && !IsIncompleteDeclaration(x.TestedType)) { halt = true; explicitlyNoCompletion = true; } else if (x.TypeSpecializationToken == DTokens.Incomplete) { prv = new CtrlSpaceCompletionProvider(cdgen, scopedBlock, MemberFilter.Types | MemberFilter.ExpressionKeywords | MemberFilter.StatementBlockKeywords); halt = true; } else base.Visit (x); }
public override void Visit (DebugSpecification s) { if (s.SpecifiedId == DTokens.IncompleteId) { prv = new DebugSpecificationCompletionProvider(cdgen); halt = true; } }
public override void Visit(TraitsExpression x) { if(x.Keyword == DTokens.IncompleteId) { prv = new TraitsExpressionCompletionProvider(cdgen); halt = true; } else base.Visit (x); }
public override void Visit(IdentifierDeclaration td) { if (td.IdHash == DTokens.IncompleteIdHash) { halt = true; if(td.InnerDeclaration != null) prv = new MemberCompletionProvider (cdgen, td.InnerDeclaration, scopedBlock, scopedStatement); } else base.Visit (td); }
public override void Visit(NewExpression x) { if (IsIncompleteDeclaration (x.Type)) { halt = true; prv = new CtrlSpaceCompletionProvider (cdgen, scopedBlock, scopedStatement, MemberFilter.Types | MemberFilter.TypeParameters); } else base.Visit (x); }
public override void Visit(ScopeGuardStatement s) { if (s.GuardedScope == DTokens.IncompleteId) { prv = new ScopeAttributeCompletionProvider (cdgen); halt = true; } else base.Visit (s); }
public override void VisitAttribute(PragmaAttribute a) { if (a.Arguments != null && a.Arguments.Length>0 && IsIncompleteExpression (a.Arguments[a.Arguments.Length-1])) { prv = new AttributeCompletionProvider (cdgen) { Attribute=a }; halt = true; } else base.VisitAttribute (a); }
public override void VisitImport(ImportStatement.ImportBinding i) { if (!halt) { if (IsIncompleteDeclaration (i.Symbol)) { prv = new SelectiveImportCompletionProvider (cdgen, curImport); halt = true; } else base.VisitImport (i); } }
public override void VisitAttribute(VersionCondition vis) { if (vis.VersionIdHash == DTokens.IncompleteIdHash) { halt = true; prv = new AttributeCompletionProvider (cdgen){ Attribute = vis }; } else base.VisitAttribute (vis); }
public override void Visit (DVariable n) { if (n.NameHash == 0 && n.ContainsAttribute(DTokens.Override)) { prv = new MethodOverrideCompletionProvider(n, cdgen); halt = true; return; } if (n.IsAlias) { // alias | // alias id = | // NOT alias Type | if (IsIncompleteDeclaration (n.Type)) { prv = new CtrlSpaceCompletionProvider (cdgen, scopedBlock, MemberFilter.All | MemberFilter.BlockKeywords); halt = true; return; } }else if (n.Initializer != null) { initializedNode = n; handlesInitializer = true; n.Initializer.Accept (this); handlesInitializer = false; } if(!halt) VisitDNode(n); // auto | if(!halt && n.NameHash == 0 && (n.ContainsAttribute (DTokens.Auto) || DParser.ContainsStorageClass(n.Attributes) != Modifier.Empty)) { halt = true; explicitlyNoCompletion = true; } }
public override void VisitImport(ImportStatement.Import i) { if (IsIncompleteDeclaration(i.ModuleIdentifier)) { prv = new ImportStatementCompletionProvider(cdgen, i); halt = true; } else { curImport = i; base.VisitImport(i); } }
public override void VisitAttribute (DebugCondition c) { if (c.DebugIdHash == DTokens.IncompleteIdHash) { halt = true; prv = new DebugSpecificationCompletionProvider(cdgen); } else base.VisitAttribute (c); }
public override void Visit(ModuleStatement s) { if (IsIncompleteDeclaration (s.ModuleName)) { scopedStatement = s; prv = new ModuleStatementCompletionProvider (cdgen); halt = true; } else base.Visit (s); }
public override void Visit(GotoStatement s) { if(s.StmtType == GotoStatement.GotoStmtType.Identifier && s.LabelIdentifierHash == DTokens.IncompleteIdHash) { prv = new CtrlSpaceCompletionProvider(cdgen, scopedBlock, s, MemberFilter.Labels); scopedStatement = s; halt = true; } else base.Visit (s); }