Skip to content

Commit

Permalink
StrConcat removed from Utils
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvarga committed Jan 8, 2016
1 parent e579369 commit 4fbf029
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 34 deletions.
12 changes: 12 additions & 0 deletions @MBeautify/MBeautify.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@

configurationStruct = getConfigurationStruct();

% StrConcat Util
function retStr = strConcat( srcStr, varargin )

retStr = srcStr;

if nargin > 1
retStr = [retStr, varargin{:}];
else
return;
end
end

end


Expand Down
22 changes: 11 additions & 11 deletions @MBeautify/performFormatting.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@
tempRow = strtrim(contLineArray{iLine, 1});
tempRow = [tempRow(1:end-3), [ ' ', contTokenStruct.Token, ' ' ]];
tempRow = regexprep(tempRow, ['\s+', contTokenStruct.Token, '\s+'], [ ' ', contTokenStruct.Token, ' ' ]);
replacedLines = strConcat(replacedLines, tempRow);
replacedLines = MBeautify.strConcat(replacedLines, tempRow);

end

replacedLines = strConcat(replacedLines, actCode);
replacedLines = MBeautify.strConcat(replacedLines, actCode);

actCodeFinal = performReplacements(replacedLines, settingConf);

splitToLine = regexp(actCodeFinal, contTokenStruct.Token, 'split');

line = '';
for iSplitLine = 1:numel(splitToLine) - 1
line = strConcat(line, strtrim(splitToLine{iSplitLine}), [' ', contTokenStruct.StoredValue, ' '], contLineArray{iSplitLine,2}, newLine);
line = MBeautify.strConcat(line, strtrim(splitToLine{iSplitLine}), [' ', contTokenStruct.StoredValue, ' '], contLineArray{iSplitLine,2}, newLine);
end
line = strConcat(line, strtrim(splitToLine{end}), actComment);
line = MBeautify.strConcat(line, strtrim(splitToLine{end}), actComment);

[replacedTextArray, lastIndexUsed] = arrayAppend(replacedTextArray, {line, sprintf('\n')}, lastIndexUsed);

Expand Down Expand Up @@ -156,7 +156,7 @@
if numel(strTokStructs)
actCodeFinal = '';
for iSplit = 1:numel(strTokStructs)
actCodeFinal = strConcat(actCodeFinal, splitByStrTok{iSplit}, '''', strTokStructs{iSplit}.StoredValue, '''');
actCodeFinal = MBeautify.strConcat(actCodeFinal, splitByStrTok{iSplit}, '''', strTokStructs{iSplit}.StoredValue, '''');
%actCodeFinal = [actCodeFinal, splitByStrTok{iSplit}, '''', strTokStructs{iSplit}.StoredValue, '''' ];
end

Expand Down Expand Up @@ -193,23 +193,23 @@
% .' => NonConj transpose
if isLastCharDot
tempCode = tempCode(1:end-1);
tempCode = strConcat(tempCode, nonConjTrnspTokStruct.Token);
tempCode = MBeautify.strConcat(tempCode, nonConjTrnspTokStruct.Token);
% tempCode = [tempCode, nonConjTrnspTokStruct.Token];
isLastCharTransp = true;
else
if isLastCharTransp
tempCode = strConcat(tempCode, trnspTokStruct.Token);
tempCode = MBeautify.strConcat(tempCode, trnspTokStruct.Token);
% tempCode = [tempCode, trnspTokStruct.Token];
isLastCharTransp = true;
else

if numel(tempCode) && numel(regexp(tempCode(end),charsIndicateTranspose)) && ~isInStr

tempCode = strConcat(tempCode, trnspTokStruct.Token);
tempCode = MBeautify.strConcat(tempCode, trnspTokStruct.Token);
% tempCode = [tempCode, trnspTokStruct.Token];
isLastCharTransp = true;
else
tempCode = strConcat(tempCode, actChar);
tempCode = MBeautify.strConcat(tempCode, actChar);
% tempCode = [tempCode, actChar];
isInStr = ~isInStr;
isLastCharTransp = false;
Expand All @@ -220,12 +220,12 @@
isLastCharDot = false;
elseif isequal(actChar,'.') && ~isInStr
isLastCharDot = true;
tempCode = strConcat(tempCode, actChar);
tempCode = MBeautify.strConcat(tempCode, actChar);
% tempCode = [tempCode, actChar];
isLastCharTransp = false;
else
isLastCharDot = false;
tempCode = strConcat(tempCode, actChar);
tempCode = MBeautify.strConcat(tempCode, actChar);
% tempCode = [tempCode, actChar];
isLastCharTransp = false;
end
Expand Down
16 changes: 8 additions & 8 deletions @MBeautify/writeConfigurationFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ function writeConfigurationFile(resStruct, fullRulesConfMFileName)

for iOp = 1:numel(opFields)

settingMFileString = strConcat(settingMFileString,sprintf('\n'));
settingMFileString = strConcat(settingMFileString, ['this.OperatorRules.', opFields{iOp}, ' = struct();'], sprintf('\n'));
settingMFileString = MBeautify.strConcat(settingMFileString,sprintf('\n'));
settingMFileString = MBeautify.strConcat(settingMFileString, ['this.OperatorRules.', opFields{iOp}, ' = struct();'], sprintf('\n'));

valueFrom = regexptranslate('escape', operetorRules.(opFields{iOp}).ValueFrom);

settingMFileString = strConcat(settingMFileString, ['this.OperatorRules.', opFields{iOp}, '.ValueFrom = ''', valueFrom, ''';'], sprintf('\n'));
settingMFileString = strConcat(settingMFileString, ['this.OperatorRules.', opFields{iOp}, '.ValueTo = ''', operetorRules.(opFields{iOp}).ValueTo, ''';'], sprintf('\n'));
settingMFileString = MBeautify.strConcat(settingMFileString, ['this.OperatorRules.', opFields{iOp}, '.ValueFrom = ''', valueFrom, ''';'], sprintf('\n'));
settingMFileString = MBeautify.strConcat(settingMFileString, ['this.OperatorRules.', opFields{iOp}, '.ValueTo = ''', operetorRules.(opFields{iOp}).ValueTo, ''';'], sprintf('\n'));
end


Expand All @@ -30,12 +30,12 @@ function writeConfigurationFile(resStruct, fullRulesConfMFileName)
spFields = fields(specialRules);

for iSp = 1:numel(spFields)
settingMFileString = strConcat(settingMFileString,sprintf('\n'));
settingMFileString = strConcat(settingMFileString, ['this.SpecialRules.', spFields{iSp}, ' = struct();'], sprintf('\n'));
settingMFileString = strConcat(settingMFileString, ['this.SpecialRules.', spFields{iSp}, 'Value = ''', specialRules.(spFields{iSp}).Value, ''';'], sprintf('\n'));
settingMFileString = MBeautify.strConcat(settingMFileString,sprintf('\n'));
settingMFileString = MBeautify.strConcat(settingMFileString, ['this.SpecialRules.', spFields{iSp}, ' = struct();'], sprintf('\n'));
settingMFileString = MBeautify.strConcat(settingMFileString, ['this.SpecialRules.', spFields{iSp}, 'Value = ''', specialRules.(spFields{iSp}).Value, ''';'], sprintf('\n'));
end

settingMFileString = strConcat(settingMFileString, 'end');
settingMFileString = MBeautify.strConcat(settingMFileString, 'end');

if exist(fullRulesConfMFileName, 'file')
fileattrib(fullRulesConfMFileName, '+w');
Expand Down
15 changes: 0 additions & 15 deletions resources/tools/strConcat.m

This file was deleted.

0 comments on commit 4fbf029

Please sign in to comment.