public bool FeedCodeFile(FileData fileData, CodeFile codeFile, KeywordUsage keywordUsage, CodeKeyword rootKeyword) { var scriptContent = codeFile.ScriptContent; if (keywordUsage.createNewScriptContent) { if (scriptContent == null) { scriptContent = codeFile.NewData(this); } if (scriptContent.scriptAction == null || scriptContent.scriptAction != this) { return(false); } } var data = string.Empty; if (keywordUsage.needScopeData) { foreach (var codeCommand in rootKeyword.scopeContent.innerCommands) { if (!(codeCommand is CodeLiteral codeLiteral)) { return(false); } foreach (var literalValue in codeLiteral.literals) { data += literalValue.Content; } } } return(keywordUsage.onFeedCodeFile.Invoke(fileData, codeFile, scriptContent, rootKeyword.arguments, data)); }
public static void SafeAdd(this Dictionary <string, List <KeywordUsage> > source, string key, KeywordUsage value) { if (!source.ContainsKey(key)) { source.Add(key, new List <KeywordUsage>()); } var list = source[key]; if (!list.Contains(value)) { list.Add(value); } }