在源代码中查找符号依赖项 [英] Find symbol dependencies in source code

查看:22
本文介绍了在源代码中查找符号依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天遇到了一个错误,这让我想知道检查源代码一致性的工具.一、bug:

I had a bug today that made me wonder about tools to check for the consistency of source code. First, the bug:

我的 jQuery 选择器期望 .attached_reports,但 HTML 模板正在创建一个带有 attached-reports 类的 div.发生的事情是我们热心的主题决定标准化所有类名以使用连字符而不是下划线,结果我们的代码崩溃了.

My jQuery selector was expecting .attached_reports, but the HTML template was creating a div with class attached-reports. What happened is that our zealous themer decided to standardize all class names to use hyphens instead of underscores, and our code broke as a result.

问题:是否有一种工具或方法可以解析源代码,并将每次出现的 attached-reports 关联在一起.然后,如果其中一个符号发生更改(例如在版本控制提交时),它可以提醒团队更改?

The question: Is there a tool or methodology that would parse the source code, and associate each occurrence of attached-reports together. Then, if one of the symbols is changed (e.g. upon version control commit), it can alert the team of the change?

推荐答案

您需要的是跨语言一致性检查器,它可以静态检查运行时可能发生的错误.

What you want is cross-language consistency checker, that can statically check for errors that might occur at runtime.

要做到这一点,您需要一个可以处理所有相关语言的工具(您有两个:Javascript?[对于 Jquery] 带有对 HTML 模板的特殊引用,以及 HTML 模板语言(不完全是 HTML).该工具必须知道 JavaScript 代码将使用名称引用模板(大概这只是一个字符串;你怎么知道模板名称不是由某个神秘的过程计算出来的?),并且 HTML 模板条目将被引用(如果有一个模板槽没有被引用,可以吗?)

To do this, you need a tool that can process all the languages in question (you have two: Javascript? [for Jquery] with special references to HTML templates, and the HTML template langauges (which is not exactly HTML). The tool has to know the JavaScript code will reference templates using a name (presumably this is just a string; how do you know the template name isn't computed by some arcane process?), and that HTML template entries will be referenced (if there is a template slot that isn't referenced, is that OK?)

这个世界充满了有趣的小语言和它们内部和之间更有趣的约束(随着人们发明越来越多的 DSL 和集成规则,情况变得更糟).您不太可能为每种组合找到现成的工具.

The world is full of funny little languages and funnier constraints in and between them (and its getting worse as people invent ever-more DSLs and integration rules). Your're unlikely to find an off-the-shelf tool for every combination.

我们的 DMS 软件再造工具包旨在接受新的语言描述或方言变体(因此您可以定义 HTML 模板变体)和自定义分析器(以便您可以检测违规).[DMS 已经拥有一套稳定的传统和非常规语言前端,其中包括一个用于JavaScript.DMS 在多个维度上具有可扩展性;一个是它可以同时处理的语言数量……例如您的情况中的两种".

Our DMS Software Reengineering Toolkit is designed to accept new language descriptions or dialect variations easily (so you can define the HTML template variant) and custom analyzers (so that you might detection violations). [DMS already has a stable of conventional and unconventional Language Front Ends including one for JavaScript. DMS is scalable in several dimensions; one is the number of languages it can process at the same time... such as "two" as in your case.

DMS 使人们能够对自定义分析器或转换器进行编码.当然,无论实施何种分析,都会受到可计算性的限制;如果您的模板名称是由神秘的 JavaScript 代码计算出来的,那么该工具不太可能确定该计算出的名称是否与模板中的某些内容匹配.

DMS enables one to code custom analyzers or transformers. Of course whatever analysis is implemented is subject to computability constraints; it is unlikely that if your template name is computed by arcane JavaScript code that the tool would be able to determine if that computed name matched something in the templates.

这篇关于在源代码中查找符号依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆