Menci
6 years ago
13 changed files with 376 additions and 16 deletions
Binary file not shown.
@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" ?> |
||||
<JediCodeFormatSettings> |
||||
<WriteVersion> 2.44 </WriteVersion> |
||||
<WriteDateTime> 39387.7118126273 </WriteDateTime> |
||||
<Description> JEDI Code Format Settings </Description> |
||||
<Obfuscate> |
||||
<Enabled> False </Enabled> |
||||
<Caps> 1 </Caps> |
||||
<RemoveComments> True </RemoveComments> |
||||
<RemoveWhiteSpace> True </RemoveWhiteSpace> |
||||
<RemoveIndent> True </RemoveIndent> |
||||
<RebreakLines> True </RebreakLines> |
||||
</Obfuscate> |
||||
<Clarify> |
||||
<OnceOffs> 0 </OnceOffs> |
||||
<Warnings> True </Warnings> |
||||
<WarnUnusedParams> True </WarnUnusedParams> |
||||
<IgnoreUnusedParams> Sender </IgnoreUnusedParams> |
||||
<FileExtensions> dpr, pas, pp </FileExtensions> |
||||
</Clarify> |
||||
<Indent> |
||||
<IndentationSpaces> 2 </IndentationSpaces> |
||||
<FirstLevelIndent> 2 </FirstLevelIndent> |
||||
<HasFirstLevelIndent> False </HasFirstLevelIndent> |
||||
<IndentGlobals> True </IndentGlobals> |
||||
<IndentClasses> True </IndentClasses> |
||||
<IndentProcedures> False </IndentProcedures> |
||||
<KeepCommentsWithCodeInGlobals> True </KeepCommentsWithCodeInGlobals> |
||||
<KeepCommentsWithCodeInProcs> True </KeepCommentsWithCodeInProcs> |
||||
<KeepCommentsWithCodeInClassDef> True </KeepCommentsWithCodeInClassDef> |
||||
<KeepCommentsWithCodeElsewhere> True </KeepCommentsWithCodeElsewhere> |
||||
<IndentBeginEnd> False </IndentBeginEnd> |
||||
<IndentbeginEndSpaces> 2 </IndentbeginEndSpaces> |
||||
<IndentElse> False </IndentElse> |
||||
<IndentCaseElse> True </IndentCaseElse> |
||||
</Indent> |
||||
<Spaces> |
||||
<TabsToSpaces> True </TabsToSpaces> |
||||
<SpacesToTabs> False </SpacesToTabs> |
||||
<SpacesPerTab> 2 </SpacesPerTab> |
||||
<SpacesForTab> 2 </SpacesForTab> |
||||
<FixSpacing> True </FixSpacing> |
||||
<SpaceBeforeClassHeritage> False </SpaceBeforeClassHeritage> |
||||
<SpacesBeforeColonVar> 0 </SpacesBeforeColonVar> |
||||
<SpacesBeforeColonConst> 0 </SpacesBeforeColonConst> |
||||
<SpacesBeforeColonParam> 0 </SpacesBeforeColonParam> |
||||
<SpacesBeforeColonFn> 0 </SpacesBeforeColonFn> |
||||
<SpacesBeforeColonClassVar> 0 </SpacesBeforeColonClassVar> |
||||
<SpacesBeforeColonRecordField> 0 </SpacesBeforeColonRecordField> |
||||
<SpacesBeforeColonCaseLabel> 0 </SpacesBeforeColonCaseLabel> |
||||
<SpacesBeforeColonLabel> 0 </SpacesBeforeColonLabel> |
||||
<MaxSpacesInCode> 2 </MaxSpacesInCode> |
||||
<UseMaxSpacesInCode> True </UseMaxSpacesInCode> |
||||
<SpaceForOperator> 0 </SpaceForOperator> |
||||
<SpaceBeforeOpenBracketsInFunctionDeclaration> False </SpaceBeforeOpenBracketsInFunctionDeclaration> |
||||
<SpaceBeforeOpenBracketsInFunctionCall> False </SpaceBeforeOpenBracketsInFunctionCall> |
||||
<SpaceBeforeOpenSquareBracketsInExpression> False </SpaceBeforeOpenSquareBracketsInExpression> |
||||
<SpaceAfterOpenBrackets> False </SpaceAfterOpenBrackets> |
||||
<SpaceBeforeCloseBrackets> False </SpaceBeforeCloseBrackets> |
||||
</Spaces> |
||||
<Returns> |
||||
<WhenRebreakLines> 2 </WhenRebreakLines> |
||||
<MaxLineLength> 90 </MaxLineLength> |
||||
<NumReturnsAfterFinalEnd> 1 </NumReturnsAfterFinalEnd> |
||||
<RemoveBadReturns> True </RemoveBadReturns> |
||||
<AddGoodReturns> True </AddGoodReturns> |
||||
<UsesOnePerLine> False </UsesOnePerLine> |
||||
<RemoveExpressionReturns> True </RemoveExpressionReturns> |
||||
<RemoveVarReturns> True </RemoveVarReturns> |
||||
<NoReturnsInProperty> True </NoReturnsInProperty> |
||||
<RemoveProcedureDefReturns> True </RemoveProcedureDefReturns> |
||||
<RemoveReturns> True </RemoveReturns> |
||||
<RemoveVarBlankLines> True </RemoveVarBlankLines> |
||||
<RemoveProcHeaderBlankLines> True </RemoveProcHeaderBlankLines> |
||||
<Block> 1 </Block> |
||||
<BlockBegin> 1 </BlockBegin> |
||||
<Label> 1 </Label> |
||||
<LabelBegin> 1 </LabelBegin> |
||||
<CaseLabel> 1 </CaseLabel> |
||||
<CaseBegin> 1 </CaseBegin> |
||||
<CaseElse> 0 </CaseElse> |
||||
<CaseElseBegin> 0 </CaseElseBegin> |
||||
<EndElse> 1 </EndElse> |
||||
<ElseIf> 1 </ElseIf> |
||||
<ElseBegin> 0 </ElseBegin> |
||||
<BeforeCompilerDirectUses> 1 </BeforeCompilerDirectUses> |
||||
<BeforeCompilerDirectStatements> 0 </BeforeCompilerDirectStatements> |
||||
<BeforeCompilerDirectGeneral> 1 </BeforeCompilerDirectGeneral> |
||||
<AfterCompilerDirectUses> 1 </AfterCompilerDirectUses> |
||||
<AfterCompilerDirectStatements> 0 </AfterCompilerDirectStatements> |
||||
<AfterCompilerDirectGeneral> 1 </AfterCompilerDirectGeneral> |
||||
<ReturnChars> 0 </ReturnChars> |
||||
<RemoveConsecutiveBlankLines> True </RemoveConsecutiveBlankLines> |
||||
<MaxConsecutiveBlankLines> 4 </MaxConsecutiveBlankLines> |
||||
<MaxBlankLinesInSection> 1 </MaxBlankLinesInSection> |
||||
<LinesBeforeProcedure> 1 </LinesBeforeProcedure> |
||||
</Returns> |
||||
<Comments> |
||||
<RemoveEmptyDoubleSlashComments> True </RemoveEmptyDoubleSlashComments> |
||||
<RemoveEmptyCurlyBraceComments> True </RemoveEmptyCurlyBraceComments> |
||||
</Comments> |
||||
<Capitalisation> |
||||
<Enabled> True </Enabled> |
||||
<ReservedWords> 1 </ReservedWords> |
||||
<Operators> 1 </Operators> |
||||
<Directives> 1 </Directives> |
||||
<Constants> 1 </Constants> |
||||
<Types> 1 </Types> |
||||
</Capitalisation> |
||||
<SpecificWordCaps> |
||||
<Enabled> True </Enabled> |
||||
<Words> </Words> |
||||
</SpecificWordCaps> |
||||
<Identifiers> |
||||
<Enabled> True </Enabled> |
||||
<Words> ActivePage, AnsiCompareStr, AnsiCompareText, AnsiUpperCase, AsBoolean, AsDateTime, AsFloat, AsInteger, Assign, AsString, AsVariant, BeginDrag, Buttons, Caption, Checked, Classes, ClassName, Clear, Close, Components, Controls, Count, Create, Data, Dec, Delete, Destroy, Dialogs, Enabled, EndDrag, EOF, Exception, Execute, False, FieldByName, First, Forms, Free, FreeAndNil, GetFirstChild, Graphics, Height, idAbort, idCancel, idIgnore, IDispatch, idNo, idOk, idRetry, idYes, Inc, Initialize, IntToStr, ItemIndex, IUnknown, Lines, Math, MaxValue, mbAbort, mbAll, mbCancel, mbHelp, mbIgnore, mbNo, mbOK, mbRetry, mbYes, mbYesToAll, Messages, MinValue, mnNoToAll, mrAbort, mrAll, mrCancel, mrIgnore, mrNo, mrNone, mrNoToAll, mrOk, mrRetry, mrYes, mrYesToAll, mtConfirmation, mtCustom, mtError, mtInformation, mtWarning, Name, Next, Open, Ord, ParamStr, PChar, Perform, ProcessMessages, Read, ReadOnly, RecordCount, Register, Release, Result, Sender, SetFocus, Show, ShowMessage, Source, StdCtrls, StrToInt, SysUtils, TAutoObject, TButton, TComponent, TDataModule, Text, TForm, TFrame, TList, TNotifyEvent, TObject, TObjectList, TPageControl, TPersistent, True, TStringList, TStrings, TTabSheet, Unassigned, Value, Visible, WideString, Width, Windows, Write </Words> |
||||
</Identifiers> |
||||
<NotIdent> |
||||
<Enabled> True </Enabled> |
||||
<Words> False, Name, nil, PChar, Read, ReadOnly, True, WideString, Write </Words> |
||||
</NotIdent> |
||||
<UnitNameCaps> |
||||
<Enabled> True </Enabled> |
||||
<Words> ActnColorMaps, ActnCtrls, ActnList, ActnMan, ActnMenus, ActnPopup, ActnRes, ADOConst, ADODB, ADOInt, AppEvnts, AxCtrls, BandActn, bdeconst, bdemts, Buttons, CheckLst, Classes, Clipbrd.pas, CmAdmCtl, ComCtrls, ComStrs, Consts, Controls, CtlConsts, CtlPanel, CustomizeDlg, DataBkr, DB, DBActns, dbcgrids, DBClient, DBClientActnRes, DBClientActns, DBCommon, DBConnAdmin, DBConsts, DBCtrls, DbExcept, DBGrids, DBLocal, DBLocalI, DBLogDlg, dblookup, DBOleCtl, DBPWDlg, DBTables, DBXpress, DdeMan, Dialogs, DrTable, DSIntf, ExtActns, ExtCtrls, ExtDlgs, FileCtrl, FMTBcd, Forms, Graphics, GraphUtil, Grids, HTTPIntr, IB, IBBlob, IBCustomDataSet, IBDatabase, IBDatabaseInfo, IBDCLConst, IBErrorCodes, IBEvents, IBExternals, IBExtract, IBGeneratorEditor, IBHeader, IBIntf, IBQuery, IBRestoreEditor, IBSecurityEditor, IBServiceEditor, IBSQL, IBSQLMonitor, IBStoredProc, IBTable, IBUpdateSQL, IBUtils, IBXConst, ImgList, Jcl8087, JclAbstractContainers, JclAlgorithms, JclAnsiStrings, JclAppInst, JclArrayLists, JclArraySets, JclBase, JclBinaryTrees, JclBorlandTools, JclCIL, JclCLR, JclCOM, JclComplex, JclCompression, JclConsole, JclContainerIntf, JclCounter, JclDateTime, JclDebug, JclDotNet, JclEDI, JclEDI_ANSIX12, JclEDI_ANSIX12_Ext, JclEDI_UNEDIFACT, JclEDI_UNEDIFACT_Ext, JclEDISEF, JclEDITranslators, JclEDIXML, JclExprEval, JclFileUtils, JclFont, JclGraphics, JclGraphUtils, JclHashMaps, JclHashSets, JclHookExcept, JclIniFiles, JclLANMan, JclLinkedLists, JclLocales, JclLogic, JclMapi, JclMath, JclMetadata, JclMIDI, JclMime, JclMiscel, JclMsdosSys, JclMultimedia, JclNTFS, JclPCRE, JclPeImage, JclPrint, JclQGraphics, JclQGraphUtils, JclQueues, JclRegistry, JclResources, JclRTTI, JclSchedule, JclSecurity, JclShell, JclSimpleXml, JclStacks, JclStatistics, JclStreams, JclStrHashMap, JclStringLists, JclStrings, JclStructStorage, JclSvcCtrl, JclSynch, JclSysInfo, JclSysUtils, JclTask, JclTD32, JclUnicode, JclUnitConv, JclUnitVersioning, JclUnitVersioningProviders, JclValidation, JclVectors, JclWideFormat, JclWideStrings, JclWin32, JclWin32Ex, JclWinMIDI, ListActns, Mask, MConnect, Menus, Midas, MidasCon, MidConst, MPlayer, MtsRdm, Mxconsts, ObjBrkr, OleAuto, OleConst, OleCtnrs, OleCtrls, OleDB, OleServer, Outline, Printers, Provider, recerror, ScktCnst, ScktComp, ScktMain, SConnect, ShadowWnd, SimpleDS, SMINTF, SqlConst, SqlExpr, SqlTimSt, StdActnMenus, StdActns, StdCtrls, StdStyleActnCtrls, SvcMgr, SysUtils, TabNotBk, Tabs, TConnect, Themes, ToolWin, ValEdit, VDBConsts, WinHelpViewer, XPActnCtrls, XPMan, XPStyleActnCtrls </Words> |
||||
</UnitNameCaps> |
||||
<Asm> |
||||
<Caps> 0 </Caps> |
||||
<BreaksAfterLabel> 0 </BreaksAfterLabel> |
||||
<BreaksAfterLabelEnabled> False </BreaksAfterLabelEnabled> |
||||
<StatementIndentEnabled> False </StatementIndentEnabled> |
||||
<StatementIndent> 0 </StatementIndent> |
||||
<ParamsIndentEnabled> False </ParamsIndentEnabled> |
||||
<ParamsIndent> 0 </ParamsIndent> |
||||
</Asm> |
||||
<PreProcessor> |
||||
<Enabled> True </Enabled> |
||||
<DefinedSymbols> DELPHI5_UP, MSWINDOWS </DefinedSymbols> |
||||
<DefinedOptions> </DefinedOptions> |
||||
</PreProcessor> |
||||
<Align> |
||||
<AlignAssign> True </AlignAssign> |
||||
<AlignConst> True </AlignConst> |
||||
<AlignTypedef> True </AlignTypedef> |
||||
<AlignVars> True </AlignVars> |
||||
<AlignComment> True </AlignComment> |
||||
<AlignFields> True </AlignFields> |
||||
<InterfaceOnly> False </InterfaceOnly> |
||||
<MinColumn> 2 </MinColumn> |
||||
<MaxColumn> 60 </MaxColumn> |
||||
<MaxVariance> 1 </MaxVariance> |
||||
<MaxVarianceInterface> 10 </MaxVarianceInterface> |
||||
<MaxUnalignedStatements> 0 </MaxUnalignedStatements> |
||||
</Align> |
||||
<Replace> |
||||
<Enabled> False </Enabled> |
||||
<Words> </Words> |
||||
</Replace> |
||||
<Uses> |
||||
<RemoveEnabled> False </RemoveEnabled> |
||||
<InsertInterfaceEnabled> False </InsertInterfaceEnabled> |
||||
<InsertImplementationEnabled> False </InsertImplementationEnabled> |
||||
<FindReplaceEnabled> False </FindReplaceEnabled> |
||||
<Remove> </Remove> |
||||
<InsertInterface> </InsertInterface> |
||||
<InsertImplementation> </InsertImplementation> |
||||
<Find> </Find> |
||||
<Replace> </Replace> |
||||
</Uses> |
||||
<Transform> |
||||
<BeginEndStyle> 1 </BeginEndStyle> |
||||
<AddBlockEndSemicolon> True </AddBlockEndSemicolon> |
||||
<SortUsesInterface> False </SortUsesInterface> |
||||
<SortUsesImplmentation> False </SortUsesImplmentation> |
||||
<SortUsesProgram> False </SortUsesProgram> |
||||
<SortUsesBreakOnReturn> False </SortUsesBreakOnReturn> |
||||
<SortUsesBreakOnComment> True </SortUsesBreakOnComment> |
||||
<SortUsesSortOrder> 0 </SortUsesSortOrder> |
||||
<SortUsesNoComments> False </SortUsesNoComments> |
||||
</Transform> |
||||
</JediCodeFormatSettings> |
@ -0,0 +1,54 @@
|
||||
let child_process = require('child_process'); |
||||
let streamToString = require('stream-to-string'); |
||||
let tempfile = require('tempfile'); |
||||
let fs = require('fs-extra'); |
||||
|
||||
module.exports = async (code, lang) => { |
||||
let timer, result, tempFile; |
||||
try { |
||||
let process, pascalAddProgram; |
||||
if (lang === 'pas') { |
||||
tempFile = tempfile('.pas'); |
||||
|
||||
if (code.indexOf('program') === -1) { |
||||
code = 'program format\n' + code; |
||||
pascalAddProgram = true; |
||||
} |
||||
|
||||
await fs.writeFile(tempFile, code); |
||||
process = child_process.spawn(`${__dirname}/../bin/jcf`, [tempFile, '-inplace']); |
||||
} else { |
||||
process = child_process.spawn(`clang-format -style="{BasedOnStyle: Google, IndentWidth: 4, AccessModifierOffset: -4, SortIncludes: false, AllowShortIfStatementsOnASingleLine: true, ColumnLimit: 110, Cpp11BracedListStyle: false }" -assume-filename="a.${lang}"`, { shell: true }); |
||||
process.stdin.setEncoding('utf-8'); |
||||
process.stdin.write(code); |
||||
process.stdin.end(); |
||||
} |
||||
|
||||
timer = setTimeout(() => process.kill(), 5000); |
||||
|
||||
if (lang === 'pas') { |
||||
await streamToString(process.stdout); |
||||
result = await fs.readFile(tempFile, 'utf-8'); |
||||
if (pascalAddProgram) result = result.replace('program format\n', ''); |
||||
} else { |
||||
result = await streamToString(process.stdout); |
||||
} |
||||
|
||||
await new Promise((resolve, reject) => { |
||||
let exit = code => { |
||||
if (code === 0) resolve(); |
||||
else reject(code); |
||||
} |
||||
|
||||
if (process.exitCode !== null) exit(process.exitCode); |
||||
else process.on('close', exit); |
||||
}); |
||||
} catch (e) { |
||||
console.log(e.stack); |
||||
result = null; |
||||
} |
||||
|
||||
clearTimeout(timer); |
||||
try { if (tempFile) await fs.delete(tempFile); } catch (e) {} |
||||
return result; |
||||
} |
@ -0,0 +1,31 @@
|
||||
let Sequelize = require('sequelize'); |
||||
let db = syzoj.db; |
||||
|
||||
let model = db.define('formatted_code', { |
||||
key: { type: Sequelize.STRING(50), primaryKey: true }, |
||||
code: { type: Sequelize.TEXT('medium') } |
||||
}, { |
||||
timestamps: false, |
||||
tableName: 'formatted_code', |
||||
indexes: [ |
||||
{ |
||||
fields: ['key'] |
||||
} |
||||
] |
||||
}); |
||||
|
||||
let Model = require('./common'); |
||||
class FormattedCode extends Model { |
||||
static async create(val) { |
||||
return FormattedCode.fromRecord(FormattedCode.model.build(Object.assign({ |
||||
key: "", |
||||
code: "" |
||||
}, val))); |
||||
} |
||||
|
||||
getModel() { return model; } |
||||
} |
||||
|
||||
FormattedCode.model = model; |
||||
|
||||
module.exports = FormattedCode; |
Loading…
Reference in new issue