Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ A Visual Studio Code Extension to help **Codeforces** Users ***Code with Conveni
- Java (compiler : javac)
- Python
- Kotlin
- Haskell (compiler: ghc) [stress testing is not supported]
- Note : You may add additional compilation flags through the codepal settings (example : -std=c++14) and also choose between python, python2 or python3 depending upon the python command you use on your system to run.

# Operating Systems Supported
Expand Down
27 changes: 17 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,27 +339,27 @@
],
"editor/title": [
{
"when": "resourceExtname == .kt || resourceExtname == .cpp || resourceExtname == .c || resourceExtname == .py || resourceExtname == .java",
"when": "resourceExtname == .hs || resourceExtname == .kt || resourceExtname == .cpp || resourceExtname == .c || resourceExtname == .py || resourceExtname == .java",
"command": "codepal.runTestCases",
"group": "navigation"
},
{
"when": "resourceExtname == .kt || resourceExtname == .cpp || resourceExtname == .c || resourceExtname == .py || resourceExtname == .java",
"when": "resourceExtname == .hs || resourceExtname == .kt || resourceExtname == .cpp || resourceExtname == .c || resourceExtname == .py || resourceExtname == .java",
"command": "codepal.addTestCases",
"group": "navigation"
},
{
"when": "resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.kt$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.cpp$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.c$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.py$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.java$/'",
"when": "resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.hs$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.kt$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.cpp$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.c$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.py$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.java$/'",
"command": "codepal.submitProblem",
"group": "navigation"
},
{
"when": "resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.kt$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.cpp$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.c$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.py$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.java$/'",
"when": "resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.hs$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.kt$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.cpp$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.c$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.py$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.java$/'",
"command": "codepal.openProblemStatement",
"group": "navigation"
},
{
"when": "resourceFilename != gen.kt && resourceFilename != brute.kt && resourceExtname == .kt || resourceFilename != gen.cpp && resourceFilename != brute.cpp && resourceExtname == .cpp || resourceFilename != gen.c && resourceFilename != brute.c && resourceExtname == .c || resourceFilename != gen.py && resourceFilename != brute.py && resourceExtname == .py || resourceFilename != gen.java && resourceFilename != brute.java && resourceExtname == .java",
"when": "resourceFilename != gen.hs && resourceFilename != brute.hs && resourceExtname == .hs || resourceFilename != gen.kt && resourceFilename != brute.kt && resourceExtname == .kt || resourceFilename != gen.cpp && resourceFilename != brute.cpp && resourceExtname == .cpp || resourceFilename != gen.c && resourceFilename != brute.c && resourceExtname == .c || resourceFilename != gen.py && resourceFilename != brute.py && resourceExtname == .py || resourceFilename != gen.java && resourceFilename != brute.java && resourceExtname == .java",
"command": "codepal.stressTest",
"group": "navigation"
},
Expand Down Expand Up @@ -394,7 +394,8 @@
"python",
"python2",
"python3",
"kotlin"
"kotlin",
"haskell"
],
"markdownDescription": "Note : Incase of python please choose the python prefix you would generally use on your system to run"
},
Expand Down Expand Up @@ -438,6 +439,12 @@
"group": "language",
"markdownDescription": "Space separated additional compilation flags passed to kotlin"
},
"codepal.haskellCompilationFlags": {
"type": "string",
"default": "",
"group": "language",
"markdownDescription": "Space separated additional compilation flags passed to haskell"
},
"codepal.codeforcesHandle": {
"type": "string",
"default": "",
Expand Down Expand Up @@ -466,25 +473,25 @@
"command": "codepal.addTestCases",
"key": "ctrl+alt+a",
"mac": "cmd+alt+a",
"when": "resourceExtname == .kt || resourceExtname == .cpp || resourceExtname == .c || resourceExtname == .py || resourceExtname == .java"
"when": "resourceExtname == .hs || resourceExtname == .kt || resourceExtname == .cpp || resourceExtname == .c || resourceExtname == .py || resourceExtname == .java"
},
{
"command": "codepal.runTestCases",
"key": "ctrl+alt+r",
"mac": "cmd+alt+r",
"when": "resourceExtname == .kt || resourceExtname == .cpp || resourceExtname == .c || resourceExtname == .py || resourceExtname == .java"
"when": "resourceExtname == .hs || resourceExtname == .kt || resourceExtname == .cpp || resourceExtname == .c || resourceExtname == .py || resourceExtname == .java"
},
{
"command": "codepal.submitProblem",
"key": "ctrl+alt+s",
"mac": "cmd+alt+s",
"when": "resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.kt$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.cpp$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.c$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.py$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.java$/'"
"when": "resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.hs$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.kt$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.cpp$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.c$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.py$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.java$/'"
},
{
"command": "codepal.openProblemStatement",
"key": "ctrl+alt+o",
"mac": "cmd+alt+o",
"when": "resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.kt$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.cpp$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.c$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.py$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.java$/'"
"when": "resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.hs$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.kt$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.cpp$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.c$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.py$/' || resource =~ '/.*[A-Z][1-9]?_.*/[A-Z][1-9]?_.*\\.java$/'"
},
{
"command": "codepal.stopStressTesting",
Expand Down
4 changes: 3 additions & 1 deletion src/features/folder_creation/problem_folder_creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export const getFileExtension = (): string => {
case CompilationLanguages.kotlin:
fileExtension = 'kt';
break;

case CompilationLanguages.haskell:
fileExtension = 'hs';
break;
default:
vscode.window.showErrorMessage("Language used is not supported");
throw Error();
Expand Down
15 changes: 13 additions & 2 deletions src/features/folder_creation/test_cases_fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,19 @@ const getInputOutput = async (problem: ProblemClass) => {
let input: string[] = [];
let output: string[] = [];

postTitleInput.each((i: Number, element: string) => {
input.push($(element).html().replace(/<br>/g, '\n'));
postTitleInput.each((i: Number, element: any) => {
let testBlock: string = "";

if (element.children.length > 1){ // there is mutli-test highlighting enabled
element.children.forEach((testLine: any) => {
testBlock += $(testLine).html() + '\n';
});;
}
else{
testBlock = $(element).html().replace(/<br>/g, '\n');
}

input.push(testBlock);
});
postTitleOutput.each((i: Number, element: string) => {
output.push($(element).html().replace(/<br>/g, '\n'));
Expand Down
11 changes: 11 additions & 0 deletions src/features/run_test_cases/compile_solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ export const compileFile = async (
.get<String>(CompilationFlags.kotlin);
compileCommand = `kotlinc "${solutionFilePath}" -include-runtime -d "${testsFolderPath}${outputFileName}.jar" ${compilationFlags}`;
break;
case CompilationLanguages.haskell:
compilationFlags = vscode.workspace
.getConfiguration(codepalConfigName)
.get<String>(CompilationFlags.haskell);
if(platform() === "win32"){
compileCommand = `ghc -o "${testsFolderPath}${outputFileName}.exe" "${solutionFilePath}" ${compilationFlags}`;
}
else{
compileCommand = `ghc -o "${testsFolderPath}${outputFileName}.out" "${solutionFilePath}" ${compilationFlags}`;
}
break;

default:
vscode.window.showErrorMessage("Language used is not supported");
Expand Down
1 change: 1 addition & 0 deletions src/features/run_test_cases/run_solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const runTestsWithTimeout = async (
switch (compilationLanguage) {
case CompilationLanguages.gcc:
case CompilationLanguages.cpp:
case CompilationLanguages.haskell:
if (os === OS.linuxMac) {
// Command for linux
executable = `${executableFileName}.out`;
Expand Down
4 changes: 3 additions & 1 deletion src/utils/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export const enum CompilationLanguages {
python = "python",
python2 = "python2",
python3 = "python3",
kotlin = "kotlin"
kotlin = "kotlin",
haskell = "haskell"

}
export const enum CompilationFlags {
Expand All @@ -63,6 +64,7 @@ export const enum CompilationFlags {
java = "javaCompilationFlags",
python = "pythonCompilationFlags",
kotlin = "kotlinCompilationFlags",
haskell = "haskellCompilationFlags",
}
export const enum ContestsPhase {
finished = "FINISHED",
Expand Down