Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Change deprecated .className to .type #3722

Merged
merged 1 commit into from
May 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/editor/EditorCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ define(function (require, exports, module) {
var result, text, line;

// Move the context to the first non-empty token.
if (!ctx.token.className && ctx.token.string.trim().length === 0) {
if (!ctx.token.type && ctx.token.string.trim().length === 0) {
result = TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctx);
}

Expand All @@ -300,7 +300,7 @@ define(function (require, exports, module) {
}

// If we aren't in a block-comment.
if (!result || ctx.token.className !== "comment" || ctx.token.string.match(suffixExp)) {
if (!result || ctx.token.type !== "comment" || ctx.token.string.match(suffixExp)) {
// Is a range of text selected? (vs just an insertion pt)
var hasSelection = (sel.start.line !== sel.end.line) || (sel.start.ch !== sel.end.ch);

Expand All @@ -325,12 +325,12 @@ define(function (require, exports, module) {

// If we are in a selection starting and ending in invalid tokens and with no content (not considering spaces),
// find if we are inside a block-comment.
} else if (startCtx.token.className === null && endCtx.token.className === null &&
} else if (startCtx.token.type === null && endCtx.token.type === null &&
!editor.posWithinRange(ctx.pos, startCtx.pos, endCtx.pos, true)) {
result = TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, startCtx);

// We found a comment, find the start and end and check if the selection is inside the block-comment.
if (startCtx.token.className === "comment") {
if (startCtx.token.type === "comment") {
prefixPos = _findCommentStart(startCtx, prefixExp);
suffixPos = _findCommentEnd(startCtx, suffixExp, suffix.length);

Expand All @@ -342,7 +342,7 @@ define(function (require, exports, module) {
}

// If the start is inside a comment, find the prefix and suffix positions.
} else if (ctx.token.className === "comment") {
} else if (ctx.token.type === "comment") {
prefixPos = _findCommentStart(ctx, prefixExp);
suffixPos = _findCommentEnd(ctx, suffixExp, suffix.length);

Expand Down Expand Up @@ -489,7 +489,7 @@ define(function (require, exports, module) {
// If the selection includes a comment or is already a line selection, delegate to Block-Comment
var ctx = TokenUtils.getInitialContext(editor._codeMirror, {line: selStart.line, ch: selStart.ch});
var result = TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctx);
var className = ctx.token.className;
var className = ctx.token.type;
result = result && _findNextBlockComment(ctx, selEnd, prefixExp);

if (className === "comment" || result || isLineSelection) {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/JavaScriptCodeHints/HintUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ define(function (require, exports, module) {
* @return {boolean} - could the token be hintable?
*/
function hintable(token) {
switch (token.className) {
switch (token.type) {
case "comment":
case "number":
case "regexp":
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/JavaScriptCodeHints/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ define(function (require, exports, module) {
}
}
}
if (token.className === "property") {
if (token.type === "property") {
propertyLookup = true;
}
if (this.findPreviousDot()) {
Expand Down
6 changes: 3 additions & 3 deletions src/extensions/default/JavaScriptCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,18 @@ define(function (require, exports, module) {
return true;
}

if (token.className === null) {
if (token.type === null) {
token = session.getNextTokenOnLine(cursor);
}

if (lastToken && lastToken.className === null) {
if (lastToken && lastToken.type === null) {
lastToken = session.getNextTokenOnLine(cachedCursor);
}

// Both of the tokens should never be null (happens when token is off
// the end of the line), so one is null then close the hints.
if (!lastToken || !token ||
token.className !== lastToken.className) {
token.type !== lastToken.type) {
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions src/extensions/default/JavaScriptQuickEdit/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ define(function (require, exports, module) {
}

// Return valid function expressions only (function call or reference)
if (!((token.className === "variable") ||
(token.className === "variable-2") ||
(token.className === "property"))) {
if (!((token.type === "variable") ||
(token.type === "variable-2") ||
(token.type === "property"))) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/QuickView/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ define(function (require, exports, module) {
tokenString,
urlMatch;

if (token.className === "string") {
if (token.type === "string") {
tokenString = token.string;
} else {
urlMatch = urlRegEx.exec(line);
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/samples/InlineImageViewer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ define(function (require, exports, module) {
token = hostEditor._codeMirror.getTokenAt({line: pos.line, ch: pos.ch + 1});
}

if (token.className === "string") {
if (token.type === "string") {
var string = token.string;

// Strip quotes
Expand Down
26 changes: 13 additions & 13 deletions src/language/CSSUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ define(function (require, exports, module) {
function _isInPropName(ctx) {
var state,
lastToken;
if (!ctx || !ctx.token || !ctx.token.state || ctx.token.className === "comment") {
if (!ctx || !ctx.token || !ctx.token.state || ctx.token.type === "comment") {
return false;
}

Expand All @@ -78,8 +78,8 @@ define(function (require, exports, module) {
*/
function _isInPropValue(ctx) {
var state;
if (!ctx || !ctx.token || !ctx.token.state || ctx.token.className === "comment" ||
ctx.token.className === "property" || ctx.token.className === "property error" || ctx.token.className === "tag") {
if (!ctx || !ctx.token || !ctx.token.state || ctx.token.type === "comment" ||
ctx.token.type === "property" || ctx.token.type === "property error" || ctx.token.type === "tag") {
return false;
}

Expand Down Expand Up @@ -136,14 +136,14 @@ define(function (require, exports, module) {
do {
// If we get a property name or "{" or ";" before getting a colon, then we don't
// have a valid property name. Just return an empty string.
if (ctxClone.token.className === "property" || ctxClone.token.className === "property error" ||
if (ctxClone.token.type === "property" || ctxClone.token.type === "property error" ||
ctxClone.token.string === "{" || ctxClone.token.string === ";") {
return "";
}
} while (ctxClone.token.string !== ":" && TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctxClone));

if (ctxClone.token.string === ":" && TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctxClone) &&
(ctxClone.token.className === "property" || ctxClone.token.className === "property error")) {
(ctxClone.token.type === "property" || ctxClone.token.type === "property error")) {
return ctxClone.token.string;
}

Expand All @@ -162,7 +162,7 @@ define(function (require, exports, module) {
curValue,
propValues = [];
while (ctx.token.string !== ":" && TokenUtils.movePrevToken(ctx)) {
if (ctx.token.className === "property" || ctx.token.className === "property error" || ctx.token.className === "tag" ||
if (ctx.token.type === "property" || ctx.token.type === "property error" || ctx.token.type === "tag" ||
ctx.token.string === ":" || ctx.token.string === "{" ||
ctx.token.string === ";") {
break;
Expand Down Expand Up @@ -215,7 +215,7 @@ define(function (require, exports, module) {
}
// If we're already in the next rule, then we don't want to add the last value
// since it is the property name of the next rule.
if (ctx.token.className === "property" || ctx.token.className === "property error" || ctx.token.className === "tag" ||
if (ctx.token.type === "property" || ctx.token.type === "property error" || ctx.token.type === "tag" ||
ctx.token.string === ":") {
lastValue = "";
break;
Expand Down Expand Up @@ -357,13 +357,13 @@ define(function (require, exports, module) {
}

if (_isInPropName(ctx)) {
if (ctx.token.className === "property" || ctx.token.className === "property error" || ctx.token.className === "tag") {
if (ctx.token.type === "property" || ctx.token.type === "property error" || ctx.token.type === "tag") {
propName = ctx.token.string;
} else {
var testPos = {ch: ctx.pos.ch + 1, line: ctx.pos.line},
testToken = editor._codeMirror.getTokenAt(testPos);

if (testToken.className === "property" || testToken.className === "property error" || testToken.className === "tag") {
if (testToken.type === "property" || testToken.type === "property error" || testToken.type === "tag") {
propName = testToken.string;
offset = 0;
}
Expand Down Expand Up @@ -947,7 +947,7 @@ define(function (require, exports, module) {
TokenUtils.movePrevToken(ctx);

while (true) {
if (ctx.token.className !== "comment") {
if (ctx.token.type !== "comment") {
// Stop once we've reached a {, }, or ;
if (/[\{\}\;]/.test(ctx.token.string)) {
break;
Expand All @@ -964,7 +964,7 @@ define(function (require, exports, module) {

// scan backwards to see if the cursor is in a rule
while (true) {
if (ctx.token.className !== "comment") {
if (ctx.token.type !== "comment") {
if (ctx.token.string === "}") {
break;
} else if (ctx.token.string === "{") {
Expand All @@ -990,7 +990,7 @@ define(function (require, exports, module) {
// special case - we aren't in a selector and haven't found any chars,
// look at the next immediate token to see if it is non-whitespace
if (!selector && !foundChars) {
if (TokenUtils.moveNextToken(ctx) && ctx.token.className !== "comment" && ctx.token.string.trim() !== "") {
if (TokenUtils.moveNextToken(ctx) && ctx.token.type !== "comment" && ctx.token.string.trim() !== "") {
foundChars = true;
ctx = TokenUtils.getInitialContext(cm, $.extend({}, pos));
}
Expand All @@ -1001,7 +1001,7 @@ define(function (require, exports, module) {
if (!selector && foundChars) {
// scan forward to see if the cursor is in a selector
while (true) {
if (ctx.token.className !== "comment") {
if (ctx.token.type !== "comment") {
if (ctx.token.string === "{") {
selector = _parseSelector(ctx);
break;
Expand Down
42 changes: 21 additions & 21 deletions src/language/HTMLUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,25 @@ define(function (require, exports, module) {
forwardCtx = $.extend({}, backwardCtx);

if (editor.getModeForSelection() === "html") {
if (backwardCtx.token && backwardCtx.token.className !== "tag") {
while (TokenUtils.movePrevToken(backwardCtx) && backwardCtx.token.className !== "tag") {
if (backwardCtx.token.className === "error" && backwardCtx.token.string.indexOf("<") === 0) {
if (backwardCtx.token && backwardCtx.token.type !== "tag") {
while (TokenUtils.movePrevToken(backwardCtx) && backwardCtx.token.type !== "tag") {
if (backwardCtx.token.type === "error" && backwardCtx.token.string.indexOf("<") === 0) {
break;
}
if (backwardCtx.token.className === "attribute") {
if (backwardCtx.token.type === "attribute") {
attrs.push(backwardCtx.token.string);
}
}

while (TokenUtils.moveNextToken(forwardCtx) && forwardCtx.token.className !== "tag") {
if (forwardCtx.token.className === "attribute") {
while (TokenUtils.moveNextToken(forwardCtx) && forwardCtx.token.type !== "tag") {
if (forwardCtx.token.type === "attribute") {
// If the current tag is not closed, codemirror may return the next opening
// tag as an attribute. Stop the search loop in that case.
if (forwardCtx.token.string.indexOf("<") === 0) {
break;
}
attrs.push(forwardCtx.token.string);
} else if (forwardCtx.token.className === "error") {
} else if (forwardCtx.token.type === "error") {
if (forwardCtx.token.string.indexOf("<") === 0 || forwardCtx.token.string.indexOf(">") === 0) {
break;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ define(function (require, exports, module) {
hasEndQuote = attrInfo.hasEndQuote,
strLength = ctx.token.string.length;

if ((ctx.token.className === "string" || ctx.token.className === "error") &&
if ((ctx.token.type === "string" || ctx.token.type === "error") &&
ctx.pos.ch === ctx.token.end && strLength > 1) {
var firstChar = ctx.token.string[0],
lastChar = ctx.token.string[strLength - 1];
Expand All @@ -227,7 +227,7 @@ define(function (require, exports, module) {
}

//Move to the prev token, and check if it's an attribute
if (!TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctx) || ctx.token.className !== "attribute") {
if (!TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctx) || ctx.token.type !== "attribute") {
return createTagInfo();
}

Expand All @@ -248,7 +248,7 @@ define(function (require, exports, module) {
function _getTagInfoStartingFromAttrName(ctx, isPriorAttr) {
//Verify We're in the attribute name, move forward and try to extract the rest of
//the info. If the user it typing the attr the rest might not be here
if (isPriorAttr === false && ctx.token.className !== "attribute") {
if (isPriorAttr === false && ctx.token.type !== "attribute") {
return createTagInfo();
}

Expand All @@ -261,8 +261,8 @@ define(function (require, exports, module) {
// an undefined token class, then we've already scanned past our original cursor location.
// So just return an empty tag info.
if (isPriorAttr &&
(!ctx.token.className ||
(ctx.token.className !== "attribute" && ctx.token.string.indexOf("<") !== -1))) {
(!ctx.token.type ||
(ctx.token.type !== "attribute" && ctx.token.string.indexOf("<") !== -1))) {
return createTagInfo();
}
return createTagInfo(ATTR_NAME, offset, tagName, attrName);
Expand Down Expand Up @@ -328,12 +328,12 @@ define(function (require, exports, module) {
// pos has whitespace before it and non-whitespace after it, so use token after
ctx.token = testToken;

if (ctx.token.className === "tag" || ctx.token.className === "error") {
if (ctx.token.type === "tag" || ctx.token.type === "error") {
// Check to see if the cursor is just before a "<" but not in any tag.
if (ctx.token.string.charAt(0) === "<") {
return createTagInfo();
}
} else if (ctx.token.className === "attribute") {
} else if (ctx.token.type === "attribute") {
// Check to see if the user is going to add a new attr before an existing one
return _getTagInfoStartingFromAttrName(ctx, false);
} else if (ctx.token.string === "=") {
Expand All @@ -359,17 +359,17 @@ define(function (require, exports, module) {
return createTagInfo();
}

if (ctx.token.className === "comment") {
if (ctx.token.type === "comment") {
return createTagInfo();
} else if (ctx.token.className !== "tag" && ctx.token.string !== "=") {
} else if (ctx.token.type !== "tag" && ctx.token.string !== "=") {
// If it wasn't the tag name, assume it was an attr value
// Also we don't handle the "=" here.
tagInfo = _getTagInfoStartingFromAttrValue(ctx);

// Check to see if this is the closing of a tag (either the start or end)
// or a comment tag.
if (ctx.token.className === "comment" ||
(ctx.token.className === "tag" &&
if (ctx.token.type === "comment" ||
(ctx.token.type === "tag" &&
(ctx.token.string === ">" || ctx.token.string === "/>" ||
(ctx.token.string.charAt(0) === "<" && ctx.token.string.charAt(1) === "/")))) {
return createTagInfo();
Expand All @@ -394,7 +394,7 @@ define(function (require, exports, module) {
}
}

if (ctx.token.className === "tag" || ctx.token.className === "error") {
if (ctx.token.type === "tag" || ctx.token.type === "error") {
// Check if the user just typed a white space after "<" that made an existing tag invalid.
if (ctx.token.string.match(/^<\s+/) && offset !== 1) {
return createTagInfo();
Expand Down Expand Up @@ -426,7 +426,7 @@ define(function (require, exports, module) {
if (ctx.token.string === "=") {
// We could be between the attr and the value
// Step back and check
if (!TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctx) || ctx.token.className !== "attribute") {
if (!TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctx) || ctx.token.type !== "attribute") {
return createTagInfo();
}

Expand All @@ -435,7 +435,7 @@ define(function (require, exports, module) {
offset = 0;
}

if (ctx.token.className === "attribute") {
if (ctx.token.type === "attribute") {
tagInfo = _getTagInfoStartingFromAttrName(ctx, false);

// If we're in attr value, then we may need to calculate the correct offset
Expand Down
2 changes: 1 addition & 1 deletion src/utils/TokenUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ define(function (require, exports, module) {
if (!moveFxn(ctx)) {
return false;
}
while (!ctx.token.className && ctx.token.string.trim().length === 0) {
while (!ctx.token.type && ctx.token.string.trim().length === 0) {
if (!moveFxn(ctx)) {
return false;
}
Expand Down