Demo/bin/Debug/front_end/source_frame/CodeMirrorDictionary.js
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @constructor
* @param {!CodeMirror} codeMirror
* @param {string=} additionalWordChars
*/
WebInspector.CodeMirrorDictionary = function(codeMirror, additionalWordChars)
{
this._codeMirror = codeMirror;
this._additionalWordChars = new Set(/** @type {!Iterable} */ (additionalWordChars));
this._dictionary = new WebInspector.TextDictionary();
this._addText(this._codeMirror.getValue());
this._changes = this._changes.bind(this);
this._beforeChange = this._beforeChange.bind(this);
this._codeMirror.on("beforeChange", this._beforeChange);
this._codeMirror.on("changes", this._changes);
}
WebInspector.CodeMirrorDictionary.prototype = {
/**
* @param {!CodeMirror} codeMirror
* @param {!CodeMirror.BeforeChangeObject} changeObject
*/
_beforeChange: function(codeMirror, changeObject)
{
this._updatedLines = this._updatedLines || {};
for (var i = changeObject.from.line; i <= changeObject.to.line; ++i)
this._updatedLines[i] = this._codeMirror.getLine(i);
},
/**
* @param {!CodeMirror} codeMirror
* @param {!Array.<!CodeMirror.ChangeObject>} changes
*/
_changes: function(codeMirror, changes)
{
if (!changes.length || !this._updatedLines)
return;
for (var lineNumber in this._updatedLines)
this._removeText(this._updatedLines[lineNumber]);
delete this._updatedLines;
var linesToUpdate = {};
for (var changeIndex = 0; changeIndex < changes.length; ++changeIndex) {
var changeObject = changes[changeIndex];
var editInfo = WebInspector.CodeMirrorUtils.changeObjectToEditOperation(changeObject);
for (var i = editInfo.newRange.startLine; i <= editInfo.newRange.endLine; ++i)
linesToUpdate[i] = this._codeMirror.getLine(i);
}
for (var lineNumber in linesToUpdate)
this._addText(linesToUpdate[lineNumber]);
},
/**
* @param {string} word
后面还有 86 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。