├── .gitattributes ├── .github ├── release.sh └── workflows │ ├── release-build.yml │ └── test-on-commit.yml ├── .gitignore ├── LICENSE ├── README.md ├── VERSION ├── addnum ├── .classpath ├── .gitignore ├── .project ├── AddNum.jar ├── build.sh ├── check-expected-test-output.sh ├── src │ └── addnum │ │ ├── AddNum.java │ │ └── ast │ │ ├── Add.java │ │ ├── Attribute.java │ │ ├── Diagnostic.java │ │ ├── Node.java │ │ ├── Num.java │ │ └── Program.java ├── tests │ └── GeneratedTests.json └── workspace │ ├── expected_test_output.txt │ └── ts │ ├── err_ambiguous.addn │ ├── err_badattrchain.addn │ ├── err_badindex.addn │ ├── err_empty.addn │ ├── err_nosuchnode.addn │ ├── err_nosuchvar.addn │ ├── err_redefvar.addn │ ├── err_syntaxabuse.addn │ ├── err_varvar.addn │ ├── ok_add.addn │ ├── ok_large.addn │ ├── ok_num.addn │ └── ok_vars.addn ├── benchmark ├── .classpath ├── .gitignore ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── libs │ ├── .DS_Store │ └── json.jar └── src │ └── benchmark │ ├── BaseBenchmark.java │ ├── ExtendJBenchmark.java │ ├── ExtendJQueries.java │ └── Run.java ├── build-and-test.sh ├── build.sh ├── client ├── .DS_Store ├── .gitignore ├── public │ ├── editor-monaco.js │ ├── favicon.png │ ├── icons │ │ ├── content_copy_black_24dp.svg │ │ ├── content_copy_white_24dp.svg │ │ ├── description_24dp.svg │ │ ├── edit_white_24dp.svg │ │ ├── more_vert_white_24dp.svg │ │ └── my_location_white_24dp.svg │ ├── index.html │ ├── style.css │ ├── ts │ │ ├── displayRagModal.js │ │ └── main.js │ ├── upload.html │ └── vs │ │ ├── .DS_Store │ │ ├── base │ │ ├── browser │ │ │ └── ui │ │ │ │ └── codicons │ │ │ │ └── codicon │ │ │ │ └── codicon.ttf │ │ └── worker │ │ │ └── workerMain.js │ │ ├── basic-languages │ │ ├── abap │ │ │ └── abap.js │ │ ├── apex │ │ │ └── apex.js │ │ ├── azcli │ │ │ └── azcli.js │ │ ├── bat │ │ │ └── bat.js │ │ ├── bicep │ │ │ └── bicep.js │ │ ├── cameligo │ │ │ └── cameligo.js │ │ ├── clojure │ │ │ └── clojure.js │ │ ├── coffee │ │ │ └── coffee.js │ │ ├── cpp │ │ │ └── cpp.js │ │ ├── csharp │ │ │ └── csharp.js │ │ ├── csp │ │ │ └── csp.js │ │ ├── css │ │ │ └── css.js │ │ ├── dart │ │ │ └── dart.js │ │ ├── dockerfile │ │ │ └── dockerfile.js │ │ ├── ecl │ │ │ └── ecl.js │ │ ├── elixir │ │ │ └── elixir.js │ │ ├── flow9 │ │ │ └── flow9.js │ │ ├── freemarker2 │ │ │ └── freemarker2.js │ │ ├── fsharp │ │ │ └── fsharp.js │ │ ├── go │ │ │ └── go.js │ │ ├── graphql │ │ │ └── graphql.js │ │ ├── handlebars │ │ │ └── handlebars.js │ │ ├── hcl │ │ │ └── hcl.js │ │ ├── html │ │ │ └── html.js │ │ ├── ini │ │ │ └── ini.js │ │ ├── java │ │ │ └── java.js │ │ ├── javascript │ │ │ └── javascript.js │ │ ├── julia │ │ │ └── julia.js │ │ ├── kotlin │ │ │ └── kotlin.js │ │ ├── less │ │ │ └── less.js │ │ ├── lexon │ │ │ └── lexon.js │ │ ├── liquid │ │ │ └── liquid.js │ │ ├── lua │ │ │ └── lua.js │ │ ├── m3 │ │ │ └── m3.js │ │ ├── markdown │ │ │ └── markdown.js │ │ ├── mips │ │ │ └── mips.js │ │ ├── msdax │ │ │ └── msdax.js │ │ ├── mysql │ │ │ └── mysql.js │ │ ├── objective-c │ │ │ └── objective-c.js │ │ ├── pascal │ │ │ └── pascal.js │ │ ├── pascaligo │ │ │ └── pascaligo.js │ │ ├── perl │ │ │ └── perl.js │ │ ├── pgsql │ │ │ └── pgsql.js │ │ ├── php │ │ │ └── php.js │ │ ├── pla │ │ │ └── pla.js │ │ ├── postiats │ │ │ └── postiats.js │ │ ├── powerquery │ │ │ └── powerquery.js │ │ ├── powershell │ │ │ └── powershell.js │ │ ├── protobuf │ │ │ └── protobuf.js │ │ ├── pug │ │ │ └── pug.js │ │ ├── python │ │ │ └── python.js │ │ ├── qsharp │ │ │ └── qsharp.js │ │ ├── r │ │ │ └── r.js │ │ ├── razor │ │ │ └── razor.js │ │ ├── redis │ │ │ └── redis.js │ │ ├── redshift │ │ │ └── redshift.js │ │ ├── restructuredtext │ │ │ └── restructuredtext.js │ │ ├── ruby │ │ │ └── ruby.js │ │ ├── rust │ │ │ └── rust.js │ │ ├── sb │ │ │ └── sb.js │ │ ├── scala │ │ │ └── scala.js │ │ ├── scheme │ │ │ └── scheme.js │ │ ├── scss │ │ │ └── scss.js │ │ ├── shell │ │ │ └── shell.js │ │ ├── solidity │ │ │ └── solidity.js │ │ ├── sophia │ │ │ └── sophia.js │ │ ├── sparql │ │ │ └── sparql.js │ │ ├── sql │ │ │ └── sql.js │ │ ├── st │ │ │ └── st.js │ │ ├── swift │ │ │ └── swift.js │ │ ├── systemverilog │ │ │ └── systemverilog.js │ │ ├── tcl │ │ │ └── tcl.js │ │ ├── twig │ │ │ └── twig.js │ │ ├── typescript │ │ │ └── typescript.js │ │ ├── vb │ │ │ └── vb.js │ │ ├── xml │ │ │ └── xml.js │ │ └── yaml │ │ │ └── yaml.js │ │ ├── editor │ │ ├── editor.main.css │ │ ├── editor.main.js │ │ ├── editor.main.nls.de.js │ │ ├── editor.main.nls.es.js │ │ ├── editor.main.nls.fr.js │ │ ├── editor.main.nls.it.js │ │ ├── editor.main.nls.ja.js │ │ ├── editor.main.nls.js │ │ ├── editor.main.nls.ko.js │ │ ├── editor.main.nls.ru.js │ │ ├── editor.main.nls.zh-cn.js │ │ └── editor.main.nls.zh-tw.js │ │ ├── highlight-cpp.js │ │ ├── language │ │ ├── .DS_Store │ │ ├── css │ │ │ ├── cssMode.js │ │ │ └── cssWorker.js │ │ ├── html │ │ │ ├── htmlMode.js │ │ │ └── htmlWorker.js │ │ ├── json │ │ │ ├── jsonMode.js │ │ │ └── jsonWorker.js │ │ └── typescript │ │ │ ├── tsMode.js │ │ │ └── tsWorker.js │ │ └── loader.js └── ts │ ├── dist │ └── main.js │ ├── package-lock.json │ ├── package.json │ ├── src │ ├── createWebsocketHandler.ts │ ├── dependencies │ │ ├── graphviz │ │ │ ├── README.md │ │ │ └── graphviz.ts │ │ └── onp │ │ │ ├── README.md │ │ │ ├── array.ts │ │ │ ├── data.ts │ │ │ ├── index.ts │ │ │ ├── onp.ts │ │ │ └── results.ts │ ├── globals.d.ts │ ├── hacks.ts │ ├── main.ts │ ├── model │ │ ├── EditorInitializer.ts │ │ ├── EditorPreloader.ts │ │ ├── ModalEnv.ts │ │ ├── SourcedDiagnostic.ts │ │ ├── StatisticsCollectorImpl.ts │ │ ├── TextProbeEvaluator.ts │ │ ├── TextProbeManager.ts │ │ ├── ThreadPoolExecutor.ts │ │ ├── UpdatableNodeLocator.ts │ │ ├── WindowState.ts │ │ ├── Workspace.ts │ │ ├── adjustLocator.ts │ │ ├── adjustTypeAtLoc.ts │ │ ├── cullingTaskSubmitterFactory.ts │ │ ├── findLocatorWithNestingPath.ts │ │ ├── getEditorDefinitionPlace.ts │ │ ├── repositoryUrl.ts │ │ ├── runBgProbe.ts │ │ ├── syntaxHighlighting.ts │ │ └── test │ │ │ ├── TestManager.ts │ │ │ ├── compareTestResult.ts │ │ │ └── rpcBodyToAssertionLine.ts │ ├── network │ │ └── evaluateProperty.ts │ ├── protocol.ts │ ├── settings.ts │ └── ui │ │ ├── UIElements.ts │ │ ├── addConnectionCloseNotice.ts │ │ ├── configureCheckboxWithHiddenButton.ts │ │ ├── configureCheckboxWithHiddenCheckbox.ts │ │ ├── create │ │ ├── attachDragToMove.ts │ │ ├── attachDragToX.ts │ │ ├── createInlineWindowManager.ts │ │ ├── createLoadingSpinner.ts │ │ ├── createMinimizedProbeModal.ts │ │ ├── createModalTitle.ts │ │ ├── createSquigglyCheckbox.ts │ │ ├── createStickyHighlightController.ts │ │ ├── createTextSpanIndicator.ts │ │ ├── registerNodeSelector.ts │ │ ├── registerOnHover.ts │ │ └── showWindow.ts │ │ ├── getThemedColor.ts │ │ ├── installASTEditor.ts │ │ ├── popup │ │ ├── displayArgModal.ts │ │ ├── displayAstModal.ts │ │ ├── displayAttributeModal.ts │ │ ├── displayHelp.ts │ │ ├── displayMainArgsOverrideModal.ts │ │ ├── displayProbeModal.ts │ │ ├── displayRagModal.ts │ │ ├── displayStatistics.ts │ │ ├── displayTestAdditionModal.ts │ │ ├── displayTestDiffModal.ts │ │ ├── displayTestSuiteListModal.ts │ │ ├── displayTestSuiteModal.ts │ │ ├── displayWorkerStatus.ts │ │ ├── encodeRpcBodyLines.ts │ │ └── formatAttr.ts │ │ ├── renderProbeModalTitleLeft.ts │ │ ├── showVersionInfo.ts │ │ ├── startEndToSpan.ts │ │ └── trimTypeName.ts │ └── tsconfig.json ├── code-prober.jar ├── gradle-plugin ├── .gitignore ├── README.md ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ └── java │ └── org │ └── codeprober │ ├── CodeProberPlugin.java │ ├── CprDownloader.java │ └── LaunchCodeProber.java ├── minimal-probe-wrapper ├── .gitignore ├── README.md ├── build.sh └── src │ └── mpw │ ├── MinimalProbeWrapper.java │ └── RootNode.java ├── protocol ├── .classpath ├── .gitignore ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── build.sh ├── code-prober.jar └── src │ └── protocolgen │ ├── GenAll.java │ ├── GenJava.java │ ├── GenKl.java │ ├── GenTs.java │ └── spec │ ├── AsyncRpcUpdate.java │ ├── AsyncRpcUpdateValue.java │ ├── BackingFile.java │ ├── BackingFileUpdated.java │ ├── ChildStep.java │ ├── Complete.java │ ├── Diagnostic.java │ ├── EvaluateProperty.java │ ├── FNStep.java │ ├── GetTestSuite.java │ ├── GetWorkerStatus.java │ ├── GetWorkspaceFile.java │ ├── HighlightableMessage.java │ ├── Hover.java │ ├── InitInfo.java │ ├── ListNodes.java │ ├── ListProperties.java │ ├── ListTestSuites.java │ ├── ListTree.java │ ├── ListWorkspaceDirectory.java │ ├── ListedTreeChildNode.java │ ├── ListedTreeNode.java │ ├── LongPollResponse.java │ ├── NestedTest.java │ ├── NodeLocator.java │ ├── NodeLocatorStep.java │ ├── NullableNodeLocator.java │ ├── ParsingRequestData.java │ ├── ParsingSource.java │ ├── PollWorkerStatus.java │ ├── Property.java │ ├── PropertyArg.java │ ├── PropertyArgCollection.java │ ├── PutTestSuite.java │ ├── PutWorkspaceContent.java │ ├── PutWorkspaceMetadata.java │ ├── Refresh.java │ ├── RenameWorkspacePath.java │ ├── Rpc.java │ ├── RpcBodyLine.java │ ├── StopJob.java │ ├── Streamable.java │ ├── StreamableUnion.java │ ├── SubmitWorkerTask.java │ ├── SubscribeToWorkerStatus.java │ ├── TALStep.java │ ├── TestCase.java │ ├── TestCaseAssert.java │ ├── TestSuite.java │ ├── TopRequest.java │ ├── Tracing.java │ ├── TunneledWsPutRequest.java │ ├── UnlinkWorkspacePath.java │ ├── UnsubscribeFromWorkerStatus.java │ ├── WorkerTaskDone.java │ ├── WorkspaceEntry.java │ ├── WorkspacePathsUpdated.java │ ├── WsPutInit.java │ └── WsPutLongpoll.java ├── run-benchmark.jar ├── server ├── .DS_Store ├── .classpath ├── .gitignore ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── build.sh ├── libs │ ├── .DS_Store │ ├── hamcrest-2.2.jar │ ├── json.jar │ └── junit-4.13.2.jar ├── src-test │ └── codeprober │ │ ├── RunAddNumTests.java │ │ ├── TestDefaultRequestHandler.java │ │ ├── ast │ │ ├── ASTNodeAnnotation.java │ │ ├── TestAstNode.java │ │ └── TestData.java │ │ ├── locator │ │ ├── TestApplyLocator.java │ │ ├── TestCreateLocator.java │ │ └── TestNodesWithProperty.java │ │ ├── metaprogramming │ │ └── TestStreamInterceptor.java │ │ ├── requesthandler │ │ ├── TestEvaluatePropertyHandler.java │ │ ├── TestListTreeRequestHandler.java │ │ └── TestTracingBuilder.java │ │ ├── textprobe │ │ └── TestTextProbeParser.java │ │ └── toolglue │ │ └── TestAstStateResetter.java ├── src │ └── codeprober │ │ ├── AstInfo.java │ │ ├── CodeProber.java │ │ ├── ConcurrentCoordinator.java │ │ ├── ConcurrentWorker.java │ │ ├── DefaultRequestHandler.java │ │ ├── IpcReader.java │ │ ├── RunAllTests.java │ │ ├── TestClient.java │ │ ├── ast │ │ ├── AstLoopException.java │ │ ├── AstNode.java │ │ └── AstParentException.java │ │ ├── locator │ │ ├── ApplyLocator.java │ │ ├── AttrsInNode.java │ │ ├── CreateLocator.java │ │ ├── DataDrivenListTree.java │ │ ├── ListTree.java │ │ ├── MethodKindDetector.java │ │ ├── NodeEdge.java │ │ ├── NodesAtPosition.java │ │ ├── NodesWithProperty.java │ │ ├── Span.java │ │ └── TypeAtLoc.java │ │ ├── metaprogramming │ │ ├── AstNodeApiStyle.java │ │ ├── InvokeProblem.java │ │ ├── Reflect.java │ │ ├── StdIoInterceptor.java │ │ ├── StreamInterceptor.java │ │ ├── TypeIdentificationStyle.java │ │ └── TypeIdentifier.java │ │ ├── protocol │ │ ├── AstCacheStrategy.java │ │ ├── BinaryInputStream.java │ │ ├── BinaryOutputStream.java │ │ ├── ClientConnection.java │ │ ├── ClientRequest.java │ │ ├── DiagnosticType.java │ │ ├── GetTestSuiteContentsErrorCode.java │ │ ├── ListTestSuitesErrorCode.java │ │ ├── PositionRecoveryStrategy.java │ │ ├── ProbeProtocol.java │ │ ├── ProtocolBuilder.java │ │ ├── PutTestSuiteContentsErrorCode.java │ │ ├── TestCaseAssertType.java │ │ ├── TestProtocol.java │ │ ├── create │ │ │ ├── CreateType.java │ │ │ ├── CreateValue.java │ │ │ └── EncodeResponseValue.java │ │ └── data │ │ │ ├── AsyncRpcUpdate.java │ │ │ ├── AsyncRpcUpdateValue.java │ │ │ ├── BackingFile.java │ │ │ ├── BackingFileUpdated.java │ │ │ ├── CompleteReq.java │ │ │ ├── CompleteRes.java │ │ │ ├── Diagnostic.java │ │ │ ├── EvaluatePropertyReq.java │ │ │ ├── EvaluatePropertyRes.java │ │ │ ├── FNStep.java │ │ │ ├── GetTestSuiteReq.java │ │ │ ├── GetTestSuiteRes.java │ │ │ ├── GetWorkerStatusReq.java │ │ │ ├── GetWorkerStatusRes.java │ │ │ ├── GetWorkspaceFileReq.java │ │ │ ├── GetWorkspaceFileRes.java │ │ │ ├── HighlightableMessage.java │ │ │ ├── HoverReq.java │ │ │ ├── HoverRes.java │ │ │ ├── InitInfo.java │ │ │ ├── ListNodesReq.java │ │ │ ├── ListNodesRes.java │ │ │ ├── ListPropertiesReq.java │ │ │ ├── ListPropertiesRes.java │ │ │ ├── ListTestSuitesReq.java │ │ │ ├── ListTestSuitesRes.java │ │ │ ├── ListTreeReq.java │ │ │ ├── ListTreeRes.java │ │ │ ├── ListWorkspaceDirectoryReq.java │ │ │ ├── ListWorkspaceDirectoryRes.java │ │ │ ├── ListedTreeChildNode.java │ │ │ ├── ListedTreeNode.java │ │ │ ├── LongPollResponse.java │ │ │ ├── NestedTest.java │ │ │ ├── NodeLocator.java │ │ │ ├── NodeLocatorStep.java │ │ │ ├── NullableNodeLocator.java │ │ │ ├── ParsingRequestData.java │ │ │ ├── ParsingSource.java │ │ │ ├── PollWorkerStatusReq.java │ │ │ ├── PollWorkerStatusRes.java │ │ │ ├── Property.java │ │ │ ├── PropertyArg.java │ │ │ ├── PropertyArgCollection.java │ │ │ ├── PropertyEvaluationResult.java │ │ │ ├── PutTestSuiteReq.java │ │ │ ├── PutTestSuiteRes.java │ │ │ ├── PutWorkspaceContentReq.java │ │ │ ├── PutWorkspaceContentRes.java │ │ │ ├── PutWorkspaceMetadataReq.java │ │ │ ├── PutWorkspaceMetadataRes.java │ │ │ ├── Refresh.java │ │ │ ├── RenameWorkspacePathReq.java │ │ │ ├── RenameWorkspacePathRes.java │ │ │ ├── RequestAdapter.java │ │ │ ├── RpcBodyLine.java │ │ │ ├── StopJobReq.java │ │ │ ├── StopJobRes.java │ │ │ ├── SubmitWorkerTaskReq.java │ │ │ ├── SubmitWorkerTaskRes.java │ │ │ ├── SubscribeToWorkerStatusReq.java │ │ │ ├── SubscribeToWorkerStatusRes.java │ │ │ ├── SynchronousEvaluationResult.java │ │ │ ├── TALStep.java │ │ │ ├── TestCase.java │ │ │ ├── TestSuite.java │ │ │ ├── TestSuiteListOrError.java │ │ │ ├── TestSuiteOrError.java │ │ │ ├── TopRequestReq.java │ │ │ ├── TopRequestRes.java │ │ │ ├── TopRequestResponseData.java │ │ │ ├── Tracing.java │ │ │ ├── TunneledWsPutRequestReq.java │ │ │ ├── TunneledWsPutRequestRes.java │ │ │ ├── UnlinkWorkspacePathReq.java │ │ │ ├── UnlinkWorkspacePathRes.java │ │ │ ├── UnsubscribeFromWorkerStatusReq.java │ │ │ ├── UnsubscribeFromWorkerStatusRes.java │ │ │ ├── WorkerTaskDone.java │ │ │ ├── WorkspaceEntry.java │ │ │ ├── WorkspacePathsUpdated.java │ │ │ ├── WsPutInitReq.java │ │ │ ├── WsPutInitRes.java │ │ │ ├── WsPutLongpollReq.java │ │ │ ├── WsPutLongpollRes.java │ │ │ └── protocolgen_spec_InitInfo_1.java │ │ ├── requesthandler │ │ ├── CompleteHandler.java │ │ ├── EvaluatePropertyHandler.java │ │ ├── HoverHandler.java │ │ ├── LazyParser.java │ │ ├── ListNodesHandler.java │ │ ├── ListPropertiesHandler.java │ │ ├── ListTreeRequestHandler.java │ │ ├── RequestHandlerMonitor.java │ │ ├── TestRequestHandler.java │ │ ├── TracingBuilder.java │ │ └── WorkspaceHandler.java │ │ ├── resources │ │ ├── rpc │ │ └── JsonRequestHandler.java │ │ ├── server │ │ ├── BackingFileSettings.java │ │ ├── CodespacesCompat.java │ │ ├── ServerToClientEvent.java │ │ ├── ServerToClientMessagePusher.java │ │ ├── WebServer.java │ │ ├── WebSocketServer.java │ │ └── WorkspaceApi.java │ │ ├── test │ │ ├── ProbeTestCase.java │ │ ├── ProbeTestCaseRunner.java │ │ └── WorkspaceTestCase.java │ │ ├── testgen │ │ └── GenerateAddNumTestFiles.java │ │ ├── textprobe │ │ ├── ParsedTextProbes.java │ │ ├── TextAssertionMatch.java │ │ ├── TextProbeEnvironment.java │ │ ├── TextProbeParser.java │ │ ├── TextQueryMatch.java │ │ └── VarAssignMatch.java │ │ ├── toolglue │ │ ├── AstStateResetter.java │ │ ├── ParseResult.java │ │ ├── UnderlyingJar.java │ │ ├── UnderlyingTool.java │ │ └── UnderlyingToolProxy.java │ │ └── util │ │ ├── ASTProvider.java │ │ ├── BenchmarkTimer.java │ │ ├── CompilerClassLoader.java │ │ ├── DirectoryMonitor.java │ │ ├── FileMonitor.java │ │ ├── JsonUtil.java │ │ ├── MagicStdoutMessageParser.java │ │ ├── ParsedArgs.java │ │ ├── RunWorkspaceTest.java │ │ ├── SessionLogger.java │ │ ├── SystemExitControl.java │ │ ├── VersionInfo.java │ │ └── WorkspaceDirectoryMonitor.java └── test.sh └── website ├── .gitignore ├── README.md ├── public ├── favicon.png ├── index.html └── style.css ├── publish.sh └── setup.sh.example /.gitattributes: -------------------------------------------------------------------------------- 1 | # * -crlf 2 | # https://gist.github.com/dpalomar/ebc64d6f56cfc25a3e5c20fe7cdfbd4f 3 | * text=auto 4 | *.* text eol=lf 5 | 6 | *.jar binary 7 | *.png binary 8 | *.jpg binary 9 | *.jpeg binary 10 | *.gif binary 11 | *.ico binary 12 | *.mov binary 13 | *.mp4 binary 14 | *.mp3 binary 15 | *.flv binary 16 | *.fla binary 17 | *.swf binary 18 | *.gz binary 19 | *.zip binary 20 | *.7z binary 21 | *.ttf binary 22 | *.eot binary 23 | *.woff binary 24 | *.pyc binary 25 | *.pdf binary 26 | *.ez binary 27 | *.bz2 binary 28 | *.swp binary 29 | -------------------------------------------------------------------------------- /.github/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | CPR_VERSION="${GITHUB_REF/refs\/tags\//}" bash build-and-test.sh 6 | 7 | UPLOAD_URL="${ASSETS_URL/api.github.com/uploads.github.com}" 8 | 9 | # echo "Some variables for debugging, uncomment in case of issues:" 10 | # echo "sha: $GITHUB_SHA" 11 | # echo "ref: $GITHUB_REF" 12 | # echo "ctx: $GITHUB_CONTEXT" 13 | # echo "asu: $ASSETS_URL" 14 | # echo "upl: $UPLOAD_URL" 15 | 16 | if [ ! -f codeprober.jar ]; then 17 | echo "Missing codeprober.jar. Did the build silently fail?" 18 | exit 1 19 | fi 20 | 21 | curl -L \ 22 | -X POST \ 23 | -H "Accept: application/vnd.github+json" \ 24 | -H "Authorization: Bearer $GH_TOKEN" \ 25 | -H "X-GitHub-Api-Version: 2022-11-28" \ 26 | -H "Content-Type: application/octet-stream" \ 27 | "$UPLOAD_URL?name=codeprober.jar" \ 28 | --data-binary "@codeprober.jar" 29 | 30 | -------------------------------------------------------------------------------- /.github/workflows/release-build.yml: -------------------------------------------------------------------------------- 1 | 2 | name: Release builder 3 | 4 | on: 5 | release: 6 | types: [published, edited] 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | - run: bash .github/release.sh 14 | env: 15 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | ASSETS_URL: ${{ github.event.release.assets_url }} 17 | -------------------------------------------------------------------------------- /.github/workflows/test-on-commit.yml: -------------------------------------------------------------------------------- 1 | # This file is based on a node.js template, see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs 2 | 3 | name: Test on commit 4 | 5 | on: 6 | push: 7 | branches: [ "master" ] 8 | pull_request: 9 | branches: [ "master" ] 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | strategy: 17 | matrix: 18 | node-version: [23.x] 19 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | - run: sh build-and-test.sh 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | CodeProber.jar 3 | codeprober.jar 4 | server/bin 5 | .DS_Store 6 | server/src-test/codeprober/RunDemoTests.java 7 | logs 8 | test_log 9 | oneshot_res 10 | .vscode 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2022, Anton Risberg Alaküla 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | ## Automatically generated by server/build.sh. DO NOT MODIFY 2 | cb8a492 3 | -------------------------------------------------------------------------------- /addnum/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /addnum/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | actual_test_output.txt 3 | workspace/.cpr/ 4 | workspace/**/*.cpr/ 5 | -------------------------------------------------------------------------------- /addnum/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | AddNum 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | 19 | 1731509980238 20 | 21 | 30 22 | 23 | org.eclipse.core.resources.regexFilterMatcher 24 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /addnum/AddNum.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/addnum/AddNum.jar -------------------------------------------------------------------------------- /addnum/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | rm -rf build_tmp/ 5 | mkdir build_tmp 6 | 7 | echo "Gathering sources.." 8 | find src -name "*.java" > sources.txt 9 | 10 | echo "Building.." 11 | javac @sources.txt -d build_tmp -source 8 -target 8 12 | 13 | cd build_tmp 14 | 15 | echo "Generating jar.." 16 | echo "Main-Class: addnum.AddNum" >> Manifest.txt 17 | 18 | jar cfm ../AddNum.jar Manifest.txt **/* 19 | 20 | cd .. 21 | 22 | echo "Cleaning up.." 23 | rm sources.txt 24 | rm -rf build_tmp 25 | 26 | echo "Done! Built 'AddNum.jar'" 27 | -------------------------------------------------------------------------------- /addnum/check-expected-test-output.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # tail to remove startup message (Starting server, version ...) 4 | java \ 5 | -Dcpr.workspace=workspace \ 6 | -Dcpr.workspaceFilePattern="ts/.*" \ 7 | -jar ../codeprober.jar \ 8 | --test AddNum.jar \ 9 | | tail -n +2 \ 10 | > actual_test_output.txt 11 | 12 | diff workspace/expected_test_output.txt actual_test_output.txt 13 | if [ "$?" -ne "0" ]; then 14 | echo "Unexpected test output, see diff (expected vs actual) output above" 15 | exit 1 16 | fi 17 | -------------------------------------------------------------------------------- /addnum/src/addnum/ast/Add.java: -------------------------------------------------------------------------------- 1 | package addnum.ast; 2 | 3 | import java.io.PrintStream; 4 | 5 | import addnum.ast.ASTNodeAnnotation.Attribute; 6 | import addnum.ast.ASTNodeAnnotation.Child; 7 | 8 | public class Add extends Node { 9 | 10 | public Add(Node lhs, Node rhs) { 11 | super(lhs.getStart(), rhs.getEnd()); 12 | addChild(lhs); 13 | addChild(rhs); 14 | } 15 | 16 | @Child(name="lhs") 17 | public Node lhs() { 18 | return getChild(0); 19 | } 20 | 21 | @Child(name="rhs") 22 | public Node rhs() { 23 | return getChild(1); 24 | } 25 | 26 | @Attribute 27 | public int value() { 28 | return lhs().value() + rhs().value(); 29 | } 30 | 31 | private Node asNum_value = null; 32 | @Attribute 33 | public Node asNum() { 34 | if (asNum_value == null) { 35 | asNum_value = new Num(0, 0, value()); 36 | } 37 | asNum_value.parent = this; 38 | return asNum_value; 39 | } 40 | 41 | @Override 42 | public void prettyPrint(PrintStream out) { 43 | out.append("("); 44 | lhs().prettyPrint(out); 45 | out.append(" + "); 46 | rhs().prettyPrint(out); 47 | out.append(")"); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /addnum/src/addnum/ast/Attribute.java: -------------------------------------------------------------------------------- 1 | package addnum.ast; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | interface ASTNodeAnnotation { 7 | @Retention(RetentionPolicy.RUNTIME) 8 | @interface Attribute { 9 | boolean isNTA() default true; 10 | } 11 | 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @interface Child { 14 | String name(); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /addnum/src/addnum/ast/Diagnostic.java: -------------------------------------------------------------------------------- 1 | package addnum.ast; 2 | 3 | public class Diagnostic { 4 | private final Object humanReadable; 5 | private final String diagnostic; 6 | 7 | public Diagnostic(Object humanReadable, String diagnostic) { 8 | this.humanReadable = humanReadable; 9 | this.diagnostic = diagnostic; 10 | } 11 | 12 | public Object cpr_getOutput() { return humanReadable; } 13 | public String cpr_getDiagnostic() { return diagnostic; } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /addnum/src/addnum/ast/Node.java: -------------------------------------------------------------------------------- 1 | package addnum.ast; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.PrintStream; 5 | import java.util.ArrayList; 6 | import java.util.Iterator; 7 | import java.util.List; 8 | 9 | import addnum.ast.ASTNodeAnnotation.Attribute; 10 | 11 | public abstract class Node implements Iterable { 12 | 13 | private final int start, end; 14 | protected Node parent; 15 | private final List children = new ArrayList<>(); 16 | public Node(int start, int end) { 17 | this.start = start; 18 | this.end = end; 19 | } 20 | 21 | public abstract int value(); 22 | 23 | public int getStart() { 24 | return start; 25 | } 26 | 27 | public int getEnd() { 28 | return end; 29 | } 30 | 31 | public abstract void prettyPrint(PrintStream out); 32 | 33 | @Attribute 34 | public String prettyPrint() { 35 | final ByteArrayOutputStream baos = new ByteArrayOutputStream(); 36 | final PrintStream ps = new PrintStream(baos); 37 | prettyPrint(ps); 38 | return new String(baos.toByteArray()); 39 | } 40 | 41 | public void addChild(Node child) { 42 | if (child.parent != null) { 43 | throw new Error("Node is already added to another node"); 44 | } 45 | child.parent = this; 46 | children.add(child); 47 | } 48 | 49 | public Node getParent() { 50 | return parent; 51 | } 52 | 53 | public int getNumChild() { 54 | return children.size(); 55 | } 56 | public Node getChild(int idx) { 57 | return children.get(idx); 58 | } 59 | 60 | @Override 61 | public Iterator iterator() { 62 | return children.iterator(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /addnum/src/addnum/ast/Num.java: -------------------------------------------------------------------------------- 1 | package addnum.ast; 2 | 3 | import java.io.PrintStream; 4 | 5 | import addnum.ast.ASTNodeAnnotation.Attribute; 6 | 7 | public class Num extends Node { 8 | 9 | private final int val; 10 | 11 | public Num(int start, int end, int val) { 12 | super(start, end); 13 | this.val = val; 14 | } 15 | 16 | @Attribute 17 | public int value() { 18 | return val; 19 | } 20 | 21 | @Override 22 | public void prettyPrint(PrintStream out) { 23 | out.append("" + val); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /addnum/src/addnum/ast/Program.java: -------------------------------------------------------------------------------- 1 | package addnum.ast; 2 | 3 | import java.io.PrintStream; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import addnum.ast.ASTNodeAnnotation.Attribute; 8 | import addnum.ast.ASTNodeAnnotation.Child; 9 | 10 | public class Program extends Node { 11 | 12 | public Program(Node root) { 13 | super(0, 0); 14 | addChild(root); 15 | } 16 | 17 | @Child(name = "rootNode") 18 | public Node rootNode() { 19 | return getChild(0); 20 | } 21 | 22 | @Override 23 | public int value() { 24 | return rootNode().value(); 25 | } 26 | 27 | @Override 28 | public void prettyPrint(PrintStream out) { 29 | rootNode().prettyPrint(out); 30 | } 31 | 32 | @Attribute 33 | public List highlight(int needle) { 34 | final List ret = new ArrayList<>(); 35 | 36 | final List toVisit = new ArrayList<>(); 37 | toVisit.add(this); 38 | 39 | while (!toVisit.isEmpty()) { 40 | final Node last = toVisit.remove(toVisit.size() - 1); 41 | if (last.value() == needle) { 42 | ret.add(new Diagnostic(last, String.format("INFO@%d;%d;value=%d",last.getStart(), last.getEnd(), needle))); 43 | } 44 | for (Node child : last) { 45 | toVisit.add(child); 46 | } 47 | } 48 | 49 | return ret; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /addnum/workspace/expected_test_output.txt: -------------------------------------------------------------------------------- 1 | ❌ ts/err_ambiguous.addn 2 | 2 nodes of type "Num". Add [idx] to disambiguate, e.g. "Num[0]" 3 | ❌ ts/err_badattrchain.addn 4 | Invalid attribute chain 5 | ❌ ts/err_badindex.addn 6 | Invalid index 7 | Invalid index 8 | ❌ ts/err_empty.addn 9 | No matching nodes 10 | ❌ ts/err_nosuchnode.addn 11 | No matching nodes 12 | ❌ ts/err_nosuchvar.addn 13 | No such variable 14 | ❌ ts/err_redefvar.addn 15 | Duplicate definition of $x 16 | ❌ ts/err_syntaxabuse.addn 17 | Invalid syntax 18 | Invalid syntax 19 | ❌ ts/err_varvar.addn 20 | Cannot use variables on right-hand side 21 | ✅ ts/ok_add.addn 22 | ✅ ts/ok_large.addn 23 | ✅ ts/ok_num.addn 24 | ✅ ts/ok_vars.addn 25 | Done: 26 pass, 11 fail 26 | -------------------------------------------------------------------------------- /addnum/workspace/ts/err_ambiguous.addn: -------------------------------------------------------------------------------- 1 | 1+1 // [[Num.value=1]] -------------------------------------------------------------------------------- /addnum/workspace/ts/err_badattrchain.addn: -------------------------------------------------------------------------------- 1 | 1 + 1 // [[Add.asNum.asNum.value=2]] 2 | -------------------------------------------------------------------------------- /addnum/workspace/ts/err_badindex.addn: -------------------------------------------------------------------------------- 1 | 1+1 // [[Num[3].value=1]] // [[Program[1].prettyPrint=1]] -------------------------------------------------------------------------------- /addnum/workspace/ts/err_empty.addn: -------------------------------------------------------------------------------- 1 | // [[X.y=z]] 2 | 3 | -------------------------------------------------------------------------------- /addnum/workspace/ts/err_nosuchnode.addn: -------------------------------------------------------------------------------- 1 | 1 // [[Add.prettyPrint=123]] -------------------------------------------------------------------------------- /addnum/workspace/ts/err_nosuchvar.addn: -------------------------------------------------------------------------------- 1 | 1+2 // [[$v=123]] 2 | -------------------------------------------------------------------------------- /addnum/workspace/ts/err_redefvar.addn: -------------------------------------------------------------------------------- 1 | 1 // [[$x:=Num]] [[$x:=Num]] -------------------------------------------------------------------------------- /addnum/workspace/ts/err_syntaxabuse.addn: -------------------------------------------------------------------------------- 1 | 1 2 | // [[Add.value=3]] 3 | // [[Add.value!=3 ]] <-- trailing space is OK, becomes 'expected' 4 | // [[ Add.value]] <-- leading space 5 | 6 | // [[Add=$a]] 7 | // [[Add=$a ]] <-- trailing space in query, not OK 8 | // [[ Add=$a.getParent.getNumChild ]] <-- leading space, ignore 9 | 10 | // [[$a:=Add]] 11 | // [[ $a:=Add]] <-- leading space, ignore 12 | // [[$a:=a ]] <-- Space becomes part of query 13 | + 14 | 2 15 | 16 | -------------------------------------------------------------------------------- /addnum/workspace/ts/err_varvar.addn: -------------------------------------------------------------------------------- 1 | 1 // [[$a:=Num]] [[$b:=$a]] -------------------------------------------------------------------------------- /addnum/workspace/ts/ok_add.addn: -------------------------------------------------------------------------------- 1 | 1 + 2 // [[Add.value=3]] [[Add.asNum.value=3]] [[Program.prettyPrint=(1 + 2)]] -------------------------------------------------------------------------------- /addnum/workspace/ts/ok_large.addn: -------------------------------------------------------------------------------- 1 | ( 2 | 1 + 2 // [[Add[1].value=10]] 3 | + (3 + ((4))) // [[Add[1].value=10]] [[Num[0].value=3]] [[Num[1].value=4]] 4 | ) + (5) // [[Add.value=15]] [[Add[0].value=15]] [[Program.prettyPrint=(((1 + 2) + (3 + 4)) + 5)]] -------------------------------------------------------------------------------- /addnum/workspace/ts/ok_num.addn: -------------------------------------------------------------------------------- 1 | 123 // [[Num.value=123]] [[Program.prettyPrint=123]] -------------------------------------------------------------------------------- /addnum/workspace/ts/ok_vars.addn: -------------------------------------------------------------------------------- 1 | ( 2 | 1+2 // [[$one:=Num[0]]] [[$two:=Num[1]]] [[$three:=Add[1]]] 3 | ) + 5 // [[$five:=Num]] [[$eight:=Add]] [[$pretty:=Program.prettyPrint]] 4 | 5 | // 11 pass' 6 | 7 | // [[$one.value=1]] 8 | // [[$two.value=2]] 9 | // [[$three.value=3]] 10 | // [[$three.lhs=$one]] 11 | // [[$three.rhs=$two]] 12 | 13 | // [[$five.value=5]] 14 | // [[$eight.value=8]] 15 | // [[$eight.lhs.lhs=$one]] 16 | // [[$eight.lhs.rhs=$three.rhs]] 17 | 18 | // [[$eight.prettyPrint=((1 + 2) + 5)]] 19 | // [[$pretty=((1 + 2) + 5)]] 20 | -------------------------------------------------------------------------------- /benchmark/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /benchmark/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /benchmark/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Benchmark 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | 19 | 1731509980244 20 | 21 | 30 22 | 23 | org.eclipse.core.resources.regexFilterMatcher 24 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /benchmark/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=11 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 13 | org.eclipse.jdt.core.compiler.release=enabled 14 | org.eclipse.jdt.core.compiler.source=11 15 | -------------------------------------------------------------------------------- /benchmark/libs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/benchmark/libs/.DS_Store -------------------------------------------------------------------------------- /benchmark/libs/json.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/benchmark/libs/json.jar -------------------------------------------------------------------------------- /benchmark/src/benchmark/BaseBenchmark.java: -------------------------------------------------------------------------------- 1 | package benchmark; 2 | 3 | import java.util.function.Consumer; 4 | 5 | import org.json.JSONObject; 6 | 7 | public abstract class BaseBenchmark { 8 | 9 | public final Consumer postMessage; 10 | 11 | public BaseBenchmark(Consumer postMessage) { 12 | this.postMessage = postMessage; 13 | } 14 | 15 | 16 | public abstract void handleIncomingMessage(JSONObject msg); 17 | public abstract void run() throws InterruptedException; 18 | } 19 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "Building dummy version of server, needed for protocol" 5 | cd server 6 | sh build.sh 7 | cd - 8 | 9 | echo "Building protocol" 10 | cd protocol 11 | sh build.sh 12 | cd - 13 | 14 | echo "Building client" 15 | cd client/ts 16 | npm ci 17 | npm run build 18 | cd - 19 | 20 | echo "Building real server & CodeProber jar" 21 | cd server 22 | sh build.sh 23 | cd - 24 | 25 | echo "Done" 26 | -------------------------------------------------------------------------------- /client/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/client/.DS_Store -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | ts/node_modules 2 | .vscode 3 | -------------------------------------------------------------------------------- /client/public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/client/public/favicon.png -------------------------------------------------------------------------------- /client/public/icons/content_copy_black_24dp.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /client/public/icons/content_copy_white_24dp.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /client/public/icons/description_24dp.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /client/public/icons/edit_white_24dp.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /client/public/icons/more_vert_white_24dp.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /client/public/icons/my_location_white_24dp.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /client/public/vs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/client/public/vs/.DS_Store -------------------------------------------------------------------------------- /client/public/vs/base/browser/ui/codicons/codicon/codicon.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/client/public/vs/base/browser/ui/codicons/codicon/codicon.ttf -------------------------------------------------------------------------------- /client/public/vs/basic-languages/azcli/azcli.js: -------------------------------------------------------------------------------- 1 | /*!----------------------------------------------------------------------------- 2 | * Copyright (c) Microsoft Corporation. All rights reserved. 3 | * Version: 0.32.1(29a273516805a852aa8edc5e05059f119b13eff0) 4 | * Released under the MIT license 5 | * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt 6 | *-----------------------------------------------------------------------------*/ 7 | define("vs/basic-languages/azcli/azcli", ["require","require"],(require)=>{ 8 | var moduleExports=(()=>{var s=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var c=t=>s(t,"__esModule",{value:!0});var k=(t,e)=>{for(var n in e)s(t,n,{get:e[n],enumerable:!0})},p=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of r(e))!l.call(t,o)&&(n||o!=="default")&&s(t,o,{get:()=>e[o],enumerable:!(a=i(e,o))||a.enumerable});return t};var f=(t=>(e,n)=>t&&t.get(e)||(n=p(c({}),e,1),t&&t.set(e,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var m={};k(m,{conf:()=>g,language:()=>d});var g={comments:{lineComment:"#"}},d={defaultToken:"keyword",ignoreCase:!0,tokenPostfix:".azcli",str:/[^#\s]/,tokenizer:{root:[{include:"@comment"},[/\s-+@str*\s*/,{cases:{"@eos":{token:"key.identifier",next:"@popall"},"@default":{token:"key.identifier",next:"@type"}}}],[/^-+@str*\s*/,{cases:{"@eos":{token:"key.identifier",next:"@popall"},"@default":{token:"key.identifier",next:"@type"}}}]],type:[{include:"@comment"},[/-+@str*\s*/,{cases:{"@eos":{token:"key.identifier",next:"@popall"},"@default":"key.identifier"}}],[/@str+\s*/,{cases:{"@eos":{token:"string",next:"@popall"},"@default":"string"}}]],comment:[[/#.*$/,{cases:{"@eos":{token:"comment",next:"@popall"}}}]]}};return f(m);})(); 9 | return moduleExports; 10 | }); 11 | -------------------------------------------------------------------------------- /client/public/vs/language/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/client/public/vs/language/.DS_Store -------------------------------------------------------------------------------- /client/ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "build": "tsc --build", 9 | "bw": "tsc --build --watch", 10 | "serve": "ts-node ./src", 11 | "start": "node ./dist" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "devDependencies": { 17 | "ts-node": "^10.7.0", 18 | "typescript": "^4.6.3" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /client/ts/src/dependencies/graphviz/README.md: -------------------------------------------------------------------------------- 1 | These are sources from d3-graphviz: https://www.npmjs.com/package/d3-graphviz Version: 5.1.0, BSD-3-Clause License. 2 | 3 | To produce the file `graphviz.ts` the following steps were taken: 4 | 1) Check out the source repository 5 | 2) Modify rollup.config.js: 6 | - change output.format to 'es' 7 | - remove output.globals 8 | - remove external 9 | 3) Build, which produces a giant ".js" file. 10 | 4) Rename the file to ".ts", and place it here. 11 | 5) Prefix with `// @ts-nocheck` to suppress any errors 12 | 13 | All of this is done rather than npm install in order to simplify the website bundling process. 14 | -------------------------------------------------------------------------------- /client/ts/src/dependencies/onp/README.md: -------------------------------------------------------------------------------- 1 | These are the sources of onp: https://www.npmjs.com/package/onp 2 | Version: 2.0.4, MIT license. 3 | 4 | Included in raw source form rather than via npm install, in order to simplify the website bundling process. 5 | -------------------------------------------------------------------------------- /client/ts/src/dependencies/onp/data.ts: -------------------------------------------------------------------------------- 1 | 2 | export const SES_DELETE = -1; 3 | export const SES_COMMON = 0; 4 | export const SES_ADD = 1; 5 | 6 | export type Position = { 7 | x: number; 8 | y: number; 9 | k: number | null; 10 | } 11 | export function position(x: number, y: number, k: number | null): Position { 12 | return { x, y, k }; 13 | } -------------------------------------------------------------------------------- /client/ts/src/dependencies/onp/index.ts: -------------------------------------------------------------------------------- 1 | import {SES_DELETE, SES_COMMON, SES_ADD} from "./data"; 2 | import {ArrayResults, TextResults, ResultItem, createTextResults} from "./results"; 3 | import {onp} from "./onp"; 4 | import {objectifyArray, objectifyLcs, stringifyArray} from "./array"; 5 | 6 | export { 7 | SES_DELETE, 8 | SES_COMMON, 9 | SES_ADD, 10 | //types 11 | ArrayResults, 12 | ResultItem 13 | } 14 | 15 | //## TEXT 16 | 17 | export interface DiffText { 18 | distance: number; 19 | lcs: string; 20 | results: TextResults; 21 | } 22 | export function diffText(a: string, b: string): DiffText { 23 | const [results, ed, lcs] = onp(a, b); 24 | 25 | return { 26 | distance: ed, 27 | lcs: lcs, 28 | results: createTextResults(results) 29 | } 30 | } 31 | 32 | //## ARRAY 33 | 34 | export interface DiffArray { 35 | distance: number; 36 | lcs: Array; 37 | results: ArrayResults; 38 | } 39 | export function diffArray(arrayA: Array, arrayB: Array): DiffArray { 40 | const [a, b, map] = stringifyArray(arrayA, arrayB); 41 | const [res, ed] = onp(a, b); 42 | const results = objectifyArray(arrayA, arrayB, res, map); 43 | const lcs = objectifyLcs(map, results); 44 | 45 | return { 46 | distance: ed, 47 | lcs: lcs, 48 | results: results 49 | } 50 | } 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /client/ts/src/dependencies/onp/results.ts: -------------------------------------------------------------------------------- 1 | 2 | export type ResultItem = { 3 | left: T; 4 | right: T; 5 | state: -1 | 0 | 1; 6 | } 7 | export function createResultItem(left: T, right: T, state: -1 | 0 | 1): ResultItem { 8 | return { left, right, state }; 9 | } 10 | 11 | export type TextResults = Array>; 12 | export function createTextResults(results: Array>): TextResults { 13 | 14 | if (results.length === 0) { 15 | return []; 16 | } 17 | 18 | let last = createResultItem(results[0].left, results[0].right, results[0].state); 19 | let shrink: TextResults = [last]; 20 | 21 | results.slice(1).forEach((item) => { 22 | if (item.state !== last.state) { 23 | last = createResultItem(item.left, item.right, item.state); 24 | shrink.push(last); 25 | } else { 26 | last.left += item.left; 27 | last.right += item.right; 28 | } 29 | }); 30 | 31 | return shrink; 32 | } 33 | 34 | export type ArrayResults = Array>; -------------------------------------------------------------------------------- /client/ts/src/hacks.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | const assertUnreachable = (val: never) => { 4 | console.warn('Exhaustive switch matched default case - typedefs are out of date'); 5 | console.warn('Related value:', val); 6 | } 7 | 8 | export { assertUnreachable } 9 | -------------------------------------------------------------------------------- /client/ts/src/model/EditorInitializer.ts: -------------------------------------------------------------------------------- 1 | import ModalEnv from './ModalEnv'; 2 | 3 | type EditorInitializer = (initialValue: string, onChange: (newValue: string, adjusters?: LocationAdjuster[] ) => void, initialSyntaxHighlight: SyntaxHighlightingLanguageId) => { 4 | setLocalState?: (newValue: string) => void; 5 | getLocalState?: () => string; 6 | updateSpanHighlight?: (baseHighlight: Span | null, stickyHighlights: StickyHighlight[]) => void; 7 | registerStickyMarker?: (initialSpan: Span) => StickyMarker; 8 | markText?: TextMarkFn; 9 | themeToggler: (isLightTheme: boolean) => void; 10 | syntaxHighlightingToggler: (langId: SyntaxHighlightingLanguageId) => void; 11 | registerModalEnv?: (env: ModalEnv) => void; 12 | }; 13 | 14 | export default EditorInitializer; 15 | -------------------------------------------------------------------------------- /client/ts/src/model/EditorPreloader.ts: -------------------------------------------------------------------------------- 1 | 2 | type EditorPreloader = () => { 3 | script: string[]; 4 | style: string[]; 5 | predicate: () => boolean; 6 | }; 7 | -------------------------------------------------------------------------------- /client/ts/src/model/SourcedDiagnostic.ts: -------------------------------------------------------------------------------- 1 | import { Diagnostic } from '../protocol'; 2 | 3 | 4 | interface SourcedDiagnostic extends Diagnostic { 5 | source?: string; // Human readable string describing the source of this diagnostic 6 | } 7 | export default SourcedDiagnostic; 8 | -------------------------------------------------------------------------------- /client/ts/src/model/UpdatableNodeLocator.ts: -------------------------------------------------------------------------------- 1 | import { NodeLocator } from '../protocol'; 2 | import adjustLocator from './adjustLocator'; 3 | 4 | const createImmutableLocator = (source: UpdatableNodeLocator): UpdatableNodeLocator => { 5 | return { 6 | get: () => source.get(), 7 | set: () => {}, 8 | adjust: () => {}, 9 | isMutable: () => false, 10 | createMutableClone: () => createMutableLocator(JSON.parse(JSON.stringify(source.get()))), 11 | }; 12 | }; 13 | 14 | const createMutableLocator = (locator: NodeLocator): UpdatableNodeLocator => { 15 | return { 16 | get: () => locator, 17 | set: (val) => { 18 | locator = val; 19 | }, 20 | adjust: (adjusters) => { 21 | adjusters.forEach(adj => adjustLocator(adj, locator)); 22 | }, 23 | isMutable: () => true, 24 | createMutableClone: () => createMutableLocator(JSON.parse(JSON.stringify(locator))), 25 | } 26 | }; 27 | 28 | interface UpdatableNodeLocator { 29 | get: () => NodeLocator; 30 | set: (newVal: NodeLocator) => void; 31 | adjust: (adjusters: LocationAdjuster[]) => void; 32 | isMutable: () => boolean; 33 | createMutableClone: () => UpdatableNodeLocator; 34 | } 35 | 36 | export { createImmutableLocator, createMutableLocator }; 37 | export default UpdatableNodeLocator; 38 | -------------------------------------------------------------------------------- /client/ts/src/model/WindowState.ts: -------------------------------------------------------------------------------- 1 | import { NodeLocator, Property } from '../protocol'; 2 | 3 | interface WindowStateDataProbe { 4 | type: 'probe'; 5 | locator: NodeLocator; 6 | property: Property; 7 | nested: NestedWindows; 8 | showDiagnostics?: boolean; 9 | stickyHighlight?: string; 10 | } 11 | interface WindowStateDataAst { 12 | type: 'ast'; 13 | locator: NodeLocator; 14 | direction: 'upwards' | 'downwards'; 15 | transform: { [id: string]: number }, 16 | } 17 | interface WindowStateDataMinimized { 18 | type: 'minimized-probe'; 19 | data: WindowStateDataProbe; 20 | } 21 | 22 | type WindowStateData = WindowStateDataProbe | WindowStateDataAst | WindowStateDataMinimized; 23 | 24 | interface WindowState { 25 | modalPos: ModalPosition; 26 | data: WindowStateData; 27 | } 28 | 29 | type NestedWindows = { [key: string]: { data: WindowStateData }[], }; 30 | 31 | export { WindowStateData, WindowStateDataProbe, WindowStateDataAst, NestedWindows }; 32 | export default WindowState; 33 | -------------------------------------------------------------------------------- /client/ts/src/model/adjustLocator.ts: -------------------------------------------------------------------------------- 1 | import { PropertyArg, NodeLocator, NodeLocatorStep, Property } from '../protocol'; 2 | import adjustTypeAtLoc from "./adjustTypeAtLoc"; 3 | 4 | const adjustValue = (adj: LocationAdjuster, arg: PropertyArg) => { 5 | switch (arg.type) { 6 | case 'nodeLocator': { 7 | if (arg.value.value) { 8 | adjustLocator(adj, arg.value.value); 9 | } 10 | break; 11 | } 12 | case 'collection': { 13 | arg.value.entries.forEach(v => adjustValue(adj, v)); 14 | } 15 | } 16 | } 17 | 18 | const adjustLocator = (adj: LocationAdjuster, loc: NodeLocator) => { 19 | adjustTypeAtLoc(adj, loc.result); 20 | 21 | const adjustStep = (step: NodeLocatorStep) => { 22 | switch (step.type) { 23 | case 'tal': { 24 | adjustTypeAtLoc(adj, step.value); 25 | break; 26 | } 27 | case 'nta': { 28 | step.value.property.args?.forEach(arg => adjustValue(adj, arg)); 29 | break; 30 | } 31 | } 32 | }; 33 | loc.steps.forEach(adjustStep); 34 | }; 35 | 36 | const adjustLocatorAndProperty = (adj: LocationAdjuster, loc: NodeLocator, prop: Property) => { 37 | adjustLocator(adj, loc); 38 | prop.args?.forEach(arg => adjustValue(adj, arg)); 39 | } 40 | 41 | export { adjustValue, adjustLocatorAndProperty }; 42 | export default adjustLocator; 43 | -------------------------------------------------------------------------------- /client/ts/src/model/adjustTypeAtLoc.ts: -------------------------------------------------------------------------------- 1 | import { TALStep } from '../protocol'; 2 | import startEndToSpan from '../ui/startEndToSpan'; 3 | 4 | const adjustTypeAtLoc = (adjuster: LocationAdjuster, tal: TALStep) => { 5 | if (tal.external) { 6 | // Refuse to adjust things in external files. 7 | // CodeProber is only expected to get change events for our own "internal" file. 8 | return; 9 | } 10 | const span = startEndToSpan(tal.start, tal.end); 11 | 12 | let [ls, cs] = adjuster(span.lineStart, span.colStart); 13 | let [le, ce] = adjuster(span.lineEnd, span.colEnd); 14 | if (ls == le && cs == ce) { 15 | if (span.lineStart === span.lineEnd && span.colStart === span.colEnd) { 16 | // Accept it, despite it being strange 17 | } else { 18 | // Instead of accepting change to zero-width span, take same line/col diff as before 19 | le = ls + (span.lineEnd - span.lineStart); 20 | ce = cs + (span.colEnd - span.colStart); 21 | } 22 | } 23 | tal.start = (ls << 12) + Math.max(0, cs); 24 | tal.end = (le << 12) + ce; 25 | } 26 | 27 | export default adjustTypeAtLoc; 28 | 29 | -------------------------------------------------------------------------------- /client/ts/src/model/cullingTaskSubmitterFactory.ts: -------------------------------------------------------------------------------- 1 | import ModalEnv from './ModalEnv'; 2 | 3 | const createCullingTaskSubmitterFactory: (timeout: any | number) => ModalEnv['createCullingTaskSubmitter'] = (cullTime) => { 4 | if (typeof cullTime !== 'number') { 5 | return () => ({ submit: (cb) => cb(), cancel: () => {}, }); 6 | } 7 | return () => { 8 | let localChangeDebounceTimer: any = -1; 9 | return { 10 | submit: (cb) => { 11 | clearTimeout(localChangeDebounceTimer); 12 | localChangeDebounceTimer = setTimeout(() => cb(), cullTime); 13 | }, 14 | cancel: () => { 15 | clearTimeout(localChangeDebounceTimer); 16 | }, 17 | }; 18 | } 19 | }; 20 | 21 | export default createCullingTaskSubmitterFactory; 22 | -------------------------------------------------------------------------------- /client/ts/src/model/getEditorDefinitionPlace.ts: -------------------------------------------------------------------------------- 1 | import EditorInitializer from './EditorInitializer'; 2 | 3 | interface EditorDefinitionPlace { 4 | defineEditor: (id: string, preload: EditorPreloader, init: EditorInitializer) => void; 5 | definedEditors: { 6 | [editorId: string]: { 7 | preload: EditorPreloader; 8 | init: EditorInitializer; 9 | }; 10 | }; 11 | loadPreload: (preloader: EditorPreloader, onDone: () => void) => void; 12 | } 13 | 14 | const getEditorDefinitionPlace = (): EditorDefinitionPlace => window as any; 15 | 16 | export default getEditorDefinitionPlace; 17 | -------------------------------------------------------------------------------- /client/ts/src/model/repositoryUrl.ts: -------------------------------------------------------------------------------- 1 | // This file should be kept in sync with server/src/codeprober/server/WebServer.java 2 | const repositoryUrl = `https://github.com/lu-cs-sde/codeprober`; 3 | 4 | export { repositoryUrl }; 5 | -------------------------------------------------------------------------------- /client/ts/src/model/test/rpcBodyToAssertionLine.ts: -------------------------------------------------------------------------------- 1 | import { assertUnreachable } from '../../hacks'; 2 | import { RpcBodyLine, Tracing } from '../../protocol'; 3 | 4 | const rpcBodyToTestBody = (line: RpcBodyLine): RpcBodyLine | null => { 5 | switch (line.type) { 6 | case 'plain': 7 | case 'streamArg': 8 | case 'node': 9 | case 'html': 10 | return line; 11 | 12 | case 'highlightMsg': 13 | return { type: 'plain', value: line.value.msg }; 14 | 15 | case 'dotGraph': 16 | // No dot support in tests..? 17 | return { type: 'plain', value: line.value }; 18 | 19 | case 'stdout': 20 | case 'stderr': 21 | // Do not keep these 22 | return null; 23 | 24 | case 'arr': 25 | return { type: 'arr', value: line.value.map(rpcBodyToTestBody).filter(Boolean) as RpcBodyLine[] }; 26 | 27 | case 'tracing': 28 | // Should we really keep the tracing for tests? Not a very good thing to test I think. 29 | const encodeTrace = (tr: Tracing): RpcBodyLine => { 30 | const result = rpcBodyToTestBody(tr.result); 31 | return { 32 | type: 'arr', 33 | value: [ 34 | { type: 'node', value: tr.node }, 35 | { type: 'plain', value: `.${tr.prop.name}` }, 36 | { type: 'arr', value: tr.dependencies.map(encodeTrace) }, 37 | ...(result ? [result] : []), 38 | ], 39 | }; 40 | } 41 | return encodeTrace(line.value); 42 | 43 | default: { 44 | assertUnreachable(line); 45 | return line; 46 | } 47 | } 48 | } 49 | 50 | const rpcLinesToAssertionLines = (lines: RpcBodyLine[]): RpcBodyLine[] => { 51 | const mapped = lines.map(rpcBodyToTestBody); 52 | return mapped.filter(Boolean) as RpcBodyLine[]; 53 | }; 54 | 55 | export { rpcLinesToAssertionLines } 56 | export default rpcBodyToTestBody; 57 | -------------------------------------------------------------------------------- /client/ts/src/ui/addConnectionCloseNotice.ts: -------------------------------------------------------------------------------- 1 | const showConnectionCloseNotice = (didReceiveAtLeastOneMessage: boolean) => { 2 | const ch = document.createElement('div'); 3 | const msg = didReceiveAtLeastOneMessage 4 | ? 'Lost connection to server, reload to reconnect' 5 | : 'Couldn\'t connect to server'; 6 | ch.innerHTML = ` 7 |
20 | ${msg} 21 |
22 | ` 23 | document.body.appendChild(ch); 24 | }; 25 | 26 | export default showConnectionCloseNotice; 27 | -------------------------------------------------------------------------------- /client/ts/src/ui/configureCheckboxWithHiddenButton.ts: -------------------------------------------------------------------------------- 1 | 2 | const configureCheckboxWithHiddenButton = ( 3 | checkbox: HTMLInputElement, 4 | button: HTMLButtonElement, 5 | onCheckboxChange: (checked: boolean) => void, 6 | displayEditor: (onClose: () => void) => ({ forceClose: () => void }), 7 | getButtonDecoration: () => string | null, 8 | ) => { 9 | checkbox.checked = getButtonDecoration() !== null; 10 | let overrideEditorCloser: (() => void) | null = null; 11 | const refreshButton = () => { 12 | const decoration = getButtonDecoration(); 13 | if (decoration === null) { 14 | button.style.display = 'none'; 15 | } else { 16 | button.style.display = 'inline-block'; 17 | button.innerText = decoration; 18 | } 19 | }; 20 | refreshButton(); 21 | 22 | button.onclick = () => { 23 | button.disabled = true; 24 | const { forceClose } = displayEditor(() => { 25 | button.disabled = false; 26 | overrideEditorCloser = null; 27 | }); 28 | overrideEditorCloser = () => forceClose(); 29 | }; 30 | 31 | checkbox.oninput = (e) => { 32 | overrideEditorCloser?.(); 33 | onCheckboxChange(checkbox.checked); 34 | } 35 | return { refreshButton }; 36 | } 37 | 38 | export default configureCheckboxWithHiddenButton; 39 | -------------------------------------------------------------------------------- /client/ts/src/ui/configureCheckboxWithHiddenCheckbox.ts: -------------------------------------------------------------------------------- 1 | 2 | interface CheckboxConfig { 3 | checkbox: HTMLInputElement; 4 | initiallyChecked: boolean; 5 | onChange: (checked: boolean) => void; 6 | } 7 | const configureCheckboxWithHiddenCheckbox = ( 8 | outer: CheckboxConfig, 9 | hidden: CheckboxConfig & { container: HTMLElement }, 10 | ) => { 11 | outer.checkbox.checked = outer.initiallyChecked; 12 | hidden.checkbox.checked = hidden.initiallyChecked; 13 | 14 | const refreshHidden = () => { 15 | if (outer.checkbox.checked) { 16 | hidden.container.style.display = 'block'; 17 | } else { 18 | hidden.container.style.display = 'none'; 19 | } 20 | } 21 | refreshHidden(); 22 | 23 | outer.checkbox.oninput = (e) => { 24 | refreshHidden(); 25 | outer.onChange(outer.checkbox.checked); 26 | }; 27 | hidden.checkbox.oninput = (e) => { 28 | hidden.onChange(hidden.checkbox.checked); 29 | }; 30 | } 31 | 32 | export default configureCheckboxWithHiddenCheckbox; 33 | -------------------------------------------------------------------------------- /client/ts/src/ui/create/attachDragToMove.ts: -------------------------------------------------------------------------------- 1 | 2 | import attachDragToX, { lastKnownMousePos } from "./attachDragToX" 3 | 4 | const attachDragToMove = (element: HTMLElement, initialPos?: ModalPosition | null, onFinishedMove?: () => void) => { 5 | const elemPos = { x: initialPos?.x ?? lastKnownMousePos.x, y: initialPos?.y ?? lastKnownMousePos.y }; 6 | const startPos = {...elemPos}; 7 | const onBegin = () => { 8 | startPos.x = elemPos.x; 9 | startPos.y = elemPos.y; 10 | }; 11 | const onUpdate = (dx: number, dy: number) => { 12 | let newX = startPos.x + dx; 13 | let newY = startPos.y + dy; 14 | if (newY < 0) { 15 | newY = 0; 16 | } else { 17 | newY = Math.min(document.body.clientHeight - element.clientHeight, newY); 18 | } 19 | if (newX < 0) { 20 | newX = 0; 21 | } else { 22 | newX = Math.min(document.body.clientWidth - element.clientWidth, newX); 23 | } 24 | element.style.top = `${newY}px`; 25 | element.style.left = `${newX}px`; 26 | elemPos.x = newX; 27 | elemPos.y = newY; 28 | }; 29 | onUpdate(0, 0); 30 | const { cleanup, hasMouseDown } = attachDragToX(element, 31 | onBegin, 32 | onUpdate, 33 | onFinishedMove 34 | ); 35 | return { 36 | cleanup, 37 | getPos: () => elemPos, 38 | bumpIntoScreen: () => { 39 | if (!hasMouseDown()) { 40 | onBegin(); 41 | onUpdate(0, 0); 42 | } 43 | }, 44 | } 45 | } 46 | 47 | export default attachDragToMove; 48 | -------------------------------------------------------------------------------- /client/ts/src/ui/create/createLoadingSpinner.ts: -------------------------------------------------------------------------------- 1 | 2 | const createLoadingSpinner = () => { 3 | const holder = document.createElement('div'); 4 | holder.classList.add('lds-spinner'); 5 | holder.innerHTML = `
`; 6 | return holder; 7 | }; 8 | export default createLoadingSpinner; 9 | -------------------------------------------------------------------------------- /client/ts/src/ui/create/createSquigglyCheckbox.ts: -------------------------------------------------------------------------------- 1 | 2 | const createSquigglyCheckbox = (args: { 3 | onInput: (checked: boolean) => void; 4 | initiallyChecked: boolean; 5 | id?: string; 6 | }) => { 7 | const squigglyCheckboxWrapper = document.createElement('div'); 8 | squigglyCheckboxWrapper.style.flexDirection = 'column'; 9 | 10 | const squigglyCheckbox = document.createElement('input'); 11 | squigglyCheckbox.type = 'checkbox'; 12 | squigglyCheckbox.checked = args.initiallyChecked; 13 | if (args.id) squigglyCheckbox.id = args.id; 14 | squigglyCheckboxWrapper.appendChild(squigglyCheckbox); 15 | squigglyCheckbox.onmousedown = (e) => { 16 | e.preventDefault(); 17 | e.stopPropagation(); 18 | } 19 | squigglyCheckbox.oninput = (e) => { 20 | e.preventDefault(); 21 | e.stopPropagation(); 22 | args.onInput(squigglyCheckbox.checked); 23 | } 24 | 25 | // Based on https://stackoverflow.com/a/27764538 26 | const squigglyDemo = document.createElement('div'); 27 | squigglyDemo.classList.add('squigglyLineHolder') 28 | const addTiny = (type: string) => { 29 | const tiny = document.createElement('div'); 30 | tiny.classList.add('tinyLine'); 31 | tiny.classList.add(type); 32 | squigglyDemo.appendChild(tiny); 33 | } 34 | addTiny('tinyLine1'); 35 | addTiny('tinyLine2'); 36 | squigglyCheckboxWrapper.appendChild(squigglyDemo); 37 | return squigglyCheckboxWrapper; 38 | } 39 | -------------------------------------------------------------------------------- /client/ts/src/ui/create/registerNodeSelector.ts: -------------------------------------------------------------------------------- 1 | import { NodeLocator } from '../../protocol'; 2 | 3 | const registerNodeSelector = (elem: HTMLElement, getLocator: () => NodeLocator) => { 4 | elem.classList.add('nodeLocatorContainer'); 5 | elem.addEventListener('click', (e) => { 6 | if (!window.ActiveLocatorRequest) { 7 | return; 8 | } 9 | e.stopImmediatePropagation(); 10 | e.stopPropagation(); 11 | e.preventDefault(); 12 | window.ActiveLocatorRequest.submit(getLocator()); 13 | }); 14 | }; 15 | 16 | export default registerNodeSelector; 17 | -------------------------------------------------------------------------------- /client/ts/src/ui/create/registerOnHover.ts: -------------------------------------------------------------------------------- 1 | 2 | const registerOnHover = (element: HTMLElement, onHover: (isHovering: boolean) => void) => { 3 | element.onmouseenter = () => onHover(true); 4 | element.onmouseleave = () => onHover(false); 5 | }; 6 | 7 | export default registerOnHover; 8 | -------------------------------------------------------------------------------- /client/ts/src/ui/getThemedColor.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | type ColorType = 4 | 'window-border' 5 | | 'probe-result-area' 6 | | 'syntax-type' 7 | | 'syntax-attr' 8 | | 'syntax-modifier' 9 | | 'syntax-variable' 10 | | 'separator' 11 | | 'ast-node-bg' 12 | | 'ast-node-bg-hover'; 13 | 14 | const lightColors: Record = { 15 | 'window-border': '#999', 16 | 'probe-result-area': '#F4F4F4', 17 | 'syntax-type': '#267F99', 18 | 'syntax-attr': '#795E26', 19 | 'syntax-modifier': '#0000FF', 20 | 'syntax-variable': '#001080', 21 | 'separator': '#000', 22 | 'ast-node-bg': '#DDD', 23 | 'ast-node-bg-hover': '#AAA', 24 | }; 25 | 26 | const darkColors: typeof lightColors = { 27 | 'window-border': '#999', 28 | 'probe-result-area': '#333', 29 | 'syntax-type': '#4EC9B0', 30 | 'syntax-attr': '#DCDCAA', 31 | 'syntax-modifier': '#569CD6', 32 | 'syntax-variable': '#9CDCFE', 33 | 'separator': '#FFF', 34 | 'ast-node-bg': '#1C1C1C', 35 | 'ast-node-bg-hover': '#666', 36 | }; 37 | 38 | const getThemedColor = (lightTheme: boolean, type: ColorType): string => { 39 | return (lightTheme ? lightColors : darkColors)[type]; 40 | } 41 | -------------------------------------------------------------------------------- /client/ts/src/ui/startEndToSpan.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | const startEndToSpan = (start: number, end: number): Span => ({ 4 | lineStart: (start >>> 12), 5 | colStart: start & 0xFFF, 6 | lineEnd: (end >>> 12), 7 | colEnd: end & 0xFFF, 8 | }); 9 | 10 | export default startEndToSpan; 11 | -------------------------------------------------------------------------------- /client/ts/src/ui/trimTypeName.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | const trimTypeName = (typeName: string) => { 4 | const lastDot = typeName.lastIndexOf("."); 5 | return lastDot === -1 ? typeName : typeName.slice(lastDot + 1); 6 | } 7 | 8 | export default trimTypeName; 9 | -------------------------------------------------------------------------------- /code-prober.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/code-prober.jar -------------------------------------------------------------------------------- /gradle-plugin/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build 3 | codeprobergradle*.jar 4 | publish-to-reposilite.sh 5 | -------------------------------------------------------------------------------- /gradle-plugin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/gradle-plugin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle-plugin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradle-plugin/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'codeprobergradle' 2 | -------------------------------------------------------------------------------- /gradle-plugin/src/main/java/org/codeprober/CodeProberPlugin.java: -------------------------------------------------------------------------------- 1 | package org.codeprober; 2 | 3 | import org.gradle.api.Plugin; 4 | import org.gradle.api.Project; 5 | 6 | public class CodeProberPlugin implements Plugin { 7 | @Override 8 | public void apply(Project project) { 9 | LaunchCodeProber task = project.getTasks().create("launchCodeProber", LaunchCodeProber.class); 10 | task.setGroup("CodeProber"); 11 | task.setDescription("Start CodeProber and keep it running until Ctrl+C is pressed"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /minimal-probe-wrapper/.gitignore: -------------------------------------------------------------------------------- 1 | build_tmp 2 | my-minimal-wrapper.jar 3 | -------------------------------------------------------------------------------- /minimal-probe-wrapper/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Clean up from previous build 6 | rm -rf build_tmp 7 | 8 | # Build 9 | echo "Building sources" 10 | javac -d build_tmp src/mpw/*.java -source 8 -target 8 11 | 12 | # Make Jar 13 | echo "Generating jar.." 14 | cd build_tmp 15 | echo "Main-Class: mpw.MinimalProbeWrapper" >> Manifest.txt 16 | jar cfm ../my-minimal-wrapper.jar Manifest.txt **/* 17 | 18 | # Cleanup 19 | cd - 20 | rm -rf build_tmp 21 | 22 | echo "Done, build my-minimal-wrapper.jar" 23 | echo "Start with 'java -jar /path/to/codeprober.jar /path/to/my-minimial-wrapper.jar'" 24 | -------------------------------------------------------------------------------- /minimal-probe-wrapper/src/mpw/MinimalProbeWrapper.java: -------------------------------------------------------------------------------- 1 | package mpw; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.nio.file.Files; 6 | import java.util.stream.Collectors; 7 | 8 | public class MinimalProbeWrapper { 9 | 10 | public static Object CodeProber_parse(String[] args) throws IOException { 11 | // The last arg is always a file with the contents inside the CodeProber window. 12 | // The non-last arg(s) are extra arguments, either set in the command-line when starting CodeProber, 13 | // or via "Override main args" in the CodeProber client. 14 | final File srcFile = new File(args[args.length - 1]); 15 | 16 | // Here we would typically parse 'src' into an AST and return it (optionally inside a wrapper). 17 | // However in this minimal implementation there is no parser, so we just keep 'src' as-is. 18 | final String src = Files.readAllLines(srcFile.toPath()).stream().collect(Collectors.joining("\n")); 19 | return new RootNode(src); 20 | } 21 | 22 | public static void main(String[] args) throws IOException { 23 | System.out.println("MinimalProbeWrapper started normally"); 24 | System.out.println("Here you'd perform your normal application logic."); 25 | System.out.println("CodeProber uses 'CodeProber_parse' as an entry point."); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /protocol/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /protocol/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /protocol/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Protocol 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | 19 | 1731509980247 20 | 21 | 30 22 | 23 | org.eclipse.core.resources.regexFilterMatcher 24 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /protocol/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.8 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 12 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 13 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning 14 | org.eclipse.jdt.core.compiler.release=disabled 15 | org.eclipse.jdt.core.compiler.source=1.8 16 | -------------------------------------------------------------------------------- /protocol/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | rm -rf build_tmp/ 5 | mkdir build_tmp 6 | 7 | echo "Gathering sources.." 8 | find src -name "*.java" > sources.txt 9 | 10 | if [ ! -f "../codeprober.jar" ]; then 11 | echo "Missing codeprober.jar, it is needed to compile the protocol." 12 | echo "Please run the top build.sh script first, or download the latest release and place it in the root of this repo" 13 | exit 1 14 | fi 15 | 16 | echo "Building.." 17 | javac @sources.txt -cp ../codeprober.jar -d build_tmp -source 8 -target 8 18 | 19 | if [[ "$(uname -a)" =~ "CYGWIN"* ]]; then 20 | # Required for building on CYGWIN. Not sure if same is needed for WSL 21 | SEP=";" 22 | else 23 | SEP=":" 24 | fi 25 | 26 | java \ 27 | -DJAVA_DST_DIR="../server/src/codeprober/protocol/data/" \ 28 | -DJAVA_DST_PKG="codeprober.protocol.data" \ 29 | -DTS_DST_FILE="../client/ts/src/protocol.ts" \ 30 | -cp "build_tmp$(echo $SEP)../codeprober.jar" protocolgen.GenAll 31 | 32 | echo "Cleaning up.." 33 | rm sources.txt 34 | rm -rf build_tmp 35 | 36 | echo "Done" 37 | -------------------------------------------------------------------------------- /protocol/code-prober.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/protocol/code-prober.jar -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/AsyncRpcUpdate.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class AsyncRpcUpdate extends Streamable { 4 | public final Object type = "asyncUpdate"; 5 | public final Object job = Long.class; 6 | public final Object isFinalUpdate = Boolean.class; 7 | public final Object value = AsyncRpcUpdateValue.class; 8 | } 9 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/AsyncRpcUpdateValue.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class AsyncRpcUpdateValue extends StreamableUnion { 4 | 5 | public final Object status = String.class; 6 | public final Object workerStackTrace = arr(String.class); 7 | public final Object workerStatuses = arr(String.class); 8 | public final Object workerTaskDone = WorkerTaskDone.class; 9 | } 10 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/BackingFile.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class BackingFile extends Streamable { 4 | public final Object path = String.class; 5 | public final Object value = String.class; 6 | } 7 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/BackingFileUpdated.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class BackingFileUpdated extends Streamable { 4 | public final Object type = "backing_file_update"; 5 | public final Object contents = String.class; 6 | } 7 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/ChildStep.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class ChildStep extends Streamable { 4 | public final Object type = "child"; 5 | public final Object value = Integer.class; 6 | } -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/Complete.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class Complete extends Rpc{ 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = "ide:complete"; 10 | public final Object src = ParsingRequestData.class; 11 | public final Object line = Integer.class; 12 | public final Object column = Integer.class; 13 | }; 14 | } 15 | 16 | @Override 17 | public Streamable getResponseType() { 18 | return new Streamable() { 19 | public final Object lines = opt(arr(String.class)); 20 | }; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/Diagnostic.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import codeprober.protocol.DiagnosticType; 4 | 5 | public class Diagnostic extends Streamable { 6 | public final Object type = DiagnosticType.class; 7 | public final Object start = Integer.class; 8 | public final Object end = Integer.class; 9 | public final Object msg = String.class; 10 | } -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/FNStep.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class FNStep extends Streamable { 4 | public final Object property = Property.class; 5 | } 6 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/GetTestSuite.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import codeprober.protocol.GetTestSuiteContentsErrorCode; 4 | 5 | @SuppressWarnings("unused") 6 | public class GetTestSuite extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "Test:GetTestSuite"; 12 | public final Object suite = String.class; 13 | }; 14 | } 15 | 16 | @Override 17 | public Streamable getResponseType() { 18 | return new Streamable() { 19 | public final Object result = TestSuiteOrError.class; 20 | }; 21 | } 22 | 23 | public static class TestSuiteOrError extends StreamableUnion { 24 | public final Object err = GetTestSuiteContentsErrorCode.class; 25 | public final Object contents = TestSuite.class; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/GetWorkerStatus.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class GetWorkerStatus extends Rpc { 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = "Concurrent:GetWorkerStatus"; 10 | }; 11 | } 12 | 13 | @Override 14 | public Streamable getResponseType() { 15 | return new Streamable() { 16 | public final Object stackTrace = arr(String.class); 17 | }; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/GetWorkspaceFile.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import org.json.JSONObject; 4 | 5 | @SuppressWarnings("unused") 6 | public class GetWorkspaceFile extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "GetWorkspaceFile"; 12 | public final Object path = String.class; 13 | }; 14 | } 15 | 16 | @Override 17 | public Streamable getResponseType() { 18 | return new Streamable() { 19 | public final Object content = opt(String.class); 20 | public final Object metadata = opt(JSONObject.class); 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/HighlightableMessage.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class HighlightableMessage extends Streamable { 4 | public final Object start = Integer.class; 5 | public final Object end = Integer.class; 6 | public final Object msg = String.class; 7 | } 8 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/Hover.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class Hover extends Rpc{ 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = "ide:hover"; 10 | public final Object src = ParsingRequestData.class; 11 | public final Object line = Integer.class; 12 | public final Object column = Integer.class; 13 | }; 14 | } 15 | 16 | @Override 17 | public Streamable getResponseType() { 18 | return new Streamable() { 19 | public final Object lines = opt(arr(String.class)); 20 | }; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/InitInfo.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class InitInfo extends Streamable{ 5 | 6 | public final Object type = "init"; 7 | 8 | public final Object version = new Streamable() { 9 | public final Object hash = String.class; 10 | public final Object clean = Boolean.class; 11 | public final Object buildTimeSeconds = opt(Integer.class); 12 | }; 13 | 14 | public final Object changeBufferTime = opt(Integer.class); 15 | public final Object workerProcessCount = opt(Integer.class); 16 | public final Object disableVersionCheckerByDefault = opt(Boolean.class); 17 | public final Object backingFile = opt(BackingFile.class); 18 | } 19 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/ListNodes.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class ListNodes extends Rpc { 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = "ListNodes"; 10 | public final Object pos = Integer.class; 11 | public final Object src = ParsingRequestData.class; 12 | }; 13 | } 14 | 15 | @Override 16 | public Streamable getResponseType() { 17 | return new Streamable() { 18 | public final Object body = arr(RpcBodyLine.class); 19 | public final Object nodes = opt(arr(NodeLocator.class)); 20 | public final Object errors = opt(arr(Diagnostic.class)); 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/ListProperties.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class ListProperties extends Rpc { 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = "ListProperties"; 10 | public final Object all = Boolean.class; 11 | public final Object locator = NodeLocator.class; 12 | public final Object src = ParsingRequestData.class; 13 | }; 14 | } 15 | 16 | @Override 17 | public Streamable getResponseType() { 18 | return new Streamable() { 19 | public final Object body = arr(RpcBodyLine.class); 20 | public final Object properties = opt(arr(Property.class)); 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/ListTestSuites.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import codeprober.protocol.ListTestSuitesErrorCode; 4 | 5 | @SuppressWarnings("unused") 6 | public class ListTestSuites extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "Test:ListTestSuites"; 12 | }; 13 | } 14 | 15 | @Override 16 | public Streamable getResponseType() { 17 | return new Streamable() { 18 | public final Object result = TestSuiteListOrError.class; 19 | }; 20 | } 21 | 22 | public static class TestSuiteListOrError extends StreamableUnion { 23 | public final Object err = ListTestSuitesErrorCode.class; 24 | public final Object suites = arr(String.class); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/ListTree.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class ListTree extends Rpc { 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = oneOf("ListTreeUpwards", "ListTreeDownwards"); 10 | public final Object locator = NodeLocator.class; 11 | public final Object src = ParsingRequestData.class; 12 | }; 13 | } 14 | 15 | @Override 16 | public Streamable getResponseType() { 17 | return new Streamable() { 18 | public final Object body = arr(RpcBodyLine.class); 19 | public final Object locator = opt(NodeLocator.class); 20 | public final Object node = opt(ListedTreeNode.class); 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/ListWorkspaceDirectory.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class ListWorkspaceDirectory extends Rpc { 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = "ListWorkspaceDirectory"; 10 | public final Object path = opt(String.class); 11 | }; 12 | } 13 | 14 | @Override 15 | public Streamable getResponseType() { 16 | return new Streamable() { 17 | public final Object entries = opt(arr(WorkspaceEntry.class)); 18 | }; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/ListedTreeChildNode.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class ListedTreeChildNode extends StreamableUnion { 4 | public final Object children = arr(ListedTreeNode.class); 5 | public final Object placeholder = Integer.class; 6 | } -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/ListedTreeNode.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class ListedTreeNode extends Streamable { 4 | public final Object type = "node"; 5 | public final Object locator = NodeLocator.class; 6 | public final Object name = opt(String.class); 7 | public final Object children = ListedTreeChildNode.class; 8 | } 9 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/LongPollResponse.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class LongPollResponse extends StreamableUnion { 6 | 7 | public final Object etag = Integer.class; 8 | public final Object push = JSONObject.class; 9 | } 10 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/NestedTest.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class NestedTest extends Streamable { 4 | // Index chain in parent's output. 5 | public final Object path = arr(Integer.class); 6 | public final Object property = Property.class; 7 | public final Object expectedOutput = arr(RpcBodyLine.class); 8 | public final Object nestedProperties = arr(NestedTest.class); 9 | } 10 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/NodeLocator.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import java.util.Arrays; 4 | 5 | public class NodeLocator extends Streamable { 6 | public final Object result = TALStep.class; 7 | public final Object steps = Arrays.asList(NodeLocatorStep.class); 8 | } -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/NodeLocatorStep.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class NodeLocatorStep extends StreamableUnion { 4 | public final Object child = Integer.class; 5 | public final Object nta = FNStep.class; 6 | public final Object tal = TALStep.class; 7 | } 8 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/NullableNodeLocator.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class NullableNodeLocator extends Streamable { 4 | public final Object type = String.class; 5 | public final Object value = opt(NodeLocator.class); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/ParsingRequestData.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import java.util.Arrays; 4 | import java.util.Optional; 5 | 6 | import codeprober.protocol.AstCacheStrategy; 7 | import codeprober.protocol.PositionRecoveryStrategy; 8 | 9 | public class ParsingRequestData extends Streamable { 10 | public final Object posRecovery = PositionRecoveryStrategy.class; 11 | public final Object cache = AstCacheStrategy.class; 12 | public final Object src = ParsingSource.class; 13 | public final Object mainArgs = Optional.of(Arrays.asList(String.class)); 14 | public final Object tmpSuffix = String.class; 15 | } 16 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/ParsingSource.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class ParsingSource extends StreamableUnion { 4 | public final Object text = String.class; 5 | public final Object workspacePath = String.class; 6 | } 7 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/PollWorkerStatus.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class PollWorkerStatus extends Rpc { 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = "Concurrent:PollWorkerStatus"; 10 | public final Object job = Long.class; 11 | }; 12 | } 13 | 14 | @Override 15 | public Streamable getResponseType() { 16 | return new Streamable() { 17 | public final Object ok = Boolean.class; 18 | }; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/Property.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class Property extends Streamable { 4 | public final Object name = String.class; 5 | public final Object args = opt(arr(PropertyArg.class)); 6 | public final Object astChildName = opt(String.class); 7 | public final Object aspect = opt(String.class); 8 | } 9 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/PropertyArg.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class PropertyArg extends StreamableUnion{ 4 | public final Object string = String.class; 5 | public final Object integer = Integer.class; 6 | public final Object bool = Boolean.class; 7 | public final Object collection = PropertyArgCollection.class; 8 | public final Object outputstream = String.class; 9 | public final Object nodeLocator = NullableNodeLocator.class; 10 | } 11 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/PropertyArgCollection.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class PropertyArgCollection extends Streamable { 4 | public final Object type = String.class; 5 | public final Object entries = arr(PropertyArg.class); 6 | } 7 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/PutTestSuite.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import codeprober.protocol.PutTestSuiteContentsErrorCode; 4 | 5 | @SuppressWarnings("unused") 6 | public class PutTestSuite extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "Test:PutTestSuite"; 12 | public final Object suite = String.class; 13 | public final Object contents = TestSuite.class; 14 | }; 15 | } 16 | 17 | @Override 18 | public Streamable getResponseType() { 19 | return new Streamable() { 20 | public final Object err = opt(PutTestSuiteContentsErrorCode.class); 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/PutWorkspaceContent.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import org.json.JSONObject; 4 | 5 | @SuppressWarnings("unused") 6 | public class PutWorkspaceContent extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "PutWorkspaceContent"; 12 | public final Object path = String.class; 13 | public final Object content = String.class; 14 | }; 15 | } 16 | 17 | @Override 18 | public Streamable getResponseType() { 19 | return new Streamable() { 20 | public final Object ok = Boolean.class; 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/PutWorkspaceMetadata.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import org.json.JSONObject; 4 | 5 | @SuppressWarnings("unused") 6 | public class PutWorkspaceMetadata extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "PutWorkspaceMetadata"; 12 | public final Object path = String.class; 13 | public final Object metadata = opt(JSONObject.class); 14 | }; 15 | } 16 | 17 | @Override 18 | public Streamable getResponseType() { 19 | return new Streamable() { 20 | public final Object ok = Boolean.class; 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/Refresh.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class Refresh extends Streamable { 4 | public final Object type = "refresh"; 5 | } 6 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/RenameWorkspacePath.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import org.json.JSONObject; 4 | 5 | @SuppressWarnings("unused") 6 | public class RenameWorkspacePath extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "RenameWorkspacePath"; 12 | public final Object srcPath = String.class; 13 | public final Object dstPath = String.class; 14 | }; 15 | } 16 | 17 | @Override 18 | public Streamable getResponseType() { 19 | return new Streamable() { 20 | public final Object ok = Boolean.class; 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/Rpc.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public abstract class Rpc { 4 | public abstract Streamable getRequestType(); 5 | public abstract Streamable getResponseType(); 6 | } 7 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/RpcBodyLine.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class RpcBodyLine extends StreamableUnion { 4 | public final Object plain = String.class; 5 | public final Object stdout = String.class; 6 | public final Object stderr = String.class; 7 | public final Object streamArg = String.class; 8 | public final Object arr = arr(RpcBodyLine.class); 9 | public final Object node = NodeLocator.class; 10 | public final Object dotGraph = String.class; 11 | public final Object highlightMsg = HighlightableMessage.class; 12 | public final Object tracing = Tracing.class; 13 | public final Object html = String.class; 14 | } -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/StopJob.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class StopJob extends Rpc { 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = "Concurrent:StopJob"; 10 | public final Object job = Integer.class; 11 | }; 12 | } 13 | 14 | @Override 15 | public Streamable getResponseType() { 16 | return new Streamable() { 17 | public final Object err = opt(String.class); 18 | }; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/Streamable.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import java.util.Arrays; 4 | import java.util.Optional; 5 | 6 | public class Streamable { 7 | 8 | protected static Object opt(Object val) { return Optional.of(val); } 9 | protected static Object arr(Object val) { return Arrays.asList(val); } 10 | protected static Object oneOf(String... vals) { return vals; } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/StreamableUnion.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class StreamableUnion extends Streamable { 4 | } 5 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/SubmitWorkerTask.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import org.json.JSONObject; 4 | 5 | @SuppressWarnings("unused") 6 | public class SubmitWorkerTask extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "Concurrent:SubmitTask"; 12 | public final Object job = Long.class; 13 | public final Object data = JSONObject.class; 14 | }; 15 | } 16 | 17 | @Override 18 | public Streamable getResponseType() { 19 | return new Streamable() { 20 | public final Object ok = Boolean.class; 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/SubscribeToWorkerStatus.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class SubscribeToWorkerStatus extends Rpc { 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = "Concurrent:SubscribeToWorkerStatus"; 10 | public final Object job = Integer.class; 11 | }; 12 | } 13 | 14 | @Override 15 | public Streamable getResponseType() { 16 | return new Streamable() { 17 | public final Object subscriberId = Integer.class; 18 | }; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/TALStep.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class TALStep extends Streamable{ 4 | public final Object type = String.class; 5 | public final Object label = opt(String.class); 6 | public final Object start = Integer.class; 7 | public final Object end = Integer.class; 8 | public final Object depth = Integer.class; 9 | public final Object external = opt(Boolean.class); 10 | } 11 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/TestCase.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import codeprober.protocol.TestCaseAssertType; 4 | 5 | public class TestCase extends Streamable { 6 | public final Object name = String.class; 7 | public final Object src = ParsingRequestData.class; 8 | public final Object property = Property.class; 9 | public final Object locator = NodeLocator.class; 10 | public final Object assertType = TestCaseAssertType.class; 11 | public final Object expectedOutput = arr(RpcBodyLine.class); 12 | public final Object nestedProperties = arr(NestedTest.class); 13 | } 14 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/TestCaseAssert.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class TestCaseAssert extends StreamableUnion { 4 | public final Object identity = arr(RpcBodyLine.class); 5 | public final Object set = arr(RpcBodyLine.class); 6 | public final Object smoke = Boolean.class; 7 | } 8 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/TestSuite.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class TestSuite extends Streamable { 4 | // Version flag, used for upggrading files in the future 5 | public final Object v = Integer.class; 6 | public final Object cases = arr(TestCase.class); 7 | } 8 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/TopRequest.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import org.json.JSONObject; 4 | 5 | @SuppressWarnings("unused") 6 | public class TopRequest extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "rpc"; 12 | public final Object id = Long.class; 13 | public final Object data = JSONObject.class; 14 | }; 15 | } 16 | 17 | @Override 18 | public Streamable getResponseType() { 19 | return new Streamable() { 20 | public final Object type = "rpc"; 21 | public final Object id = Long.class; 22 | public final Object data = TopRequestResponseData.class; 23 | }; 24 | } 25 | 26 | public static class TopRequestResponseData extends StreamableUnion { 27 | public final Object success = JSONObject.class; 28 | public final Object failureMsg = String.class; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/Tracing.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class Tracing extends Streamable { 4 | 5 | public final Object node = NodeLocator.class; 6 | public final Object prop = Property.class; 7 | public final Object dependencies = arr(Tracing.class); 8 | public final Object result = RpcBodyLine.class; 9 | } 10 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/TunneledWsPutRequest.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import org.json.JSONObject; 4 | 5 | @SuppressWarnings("unused") 6 | public class TunneledWsPutRequest extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "wsput:tunnel"; 12 | public final Object session = String.class; 13 | public final Object request = JSONObject.class; 14 | }; 15 | } 16 | 17 | @Override 18 | public Streamable getResponseType() { 19 | return new Streamable() { 20 | public final Object response = JSONObject.class; 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/UnlinkWorkspacePath.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import org.json.JSONObject; 4 | 5 | @SuppressWarnings("unused") 6 | public class UnlinkWorkspacePath extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "UnlinkWorkspacePath"; 12 | public final Object path = String.class; 13 | }; 14 | } 15 | 16 | @Override 17 | public Streamable getResponseType() { 18 | return new Streamable() { 19 | public final Object ok = Boolean.class; 20 | }; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/UnsubscribeFromWorkerStatus.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class UnsubscribeFromWorkerStatus extends Rpc { 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = "Concurrent:UnsubscribeFromWorkerStatus"; 10 | public final Object job = Integer.class; 11 | public final Object subscriberId = Integer.class; 12 | }; 13 | } 14 | 15 | @Override 16 | public Streamable getResponseType() { 17 | return new Streamable() { 18 | public final Object ok = Boolean.class; 19 | }; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/WorkerTaskDone.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class WorkerTaskDone extends StreamableUnion { 6 | 7 | public final Object normal = JSONObject.class; 8 | public final Object unexpectedError = arr(String.class); 9 | } 10 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/WorkspaceEntry.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class WorkspaceEntry extends StreamableUnion { 4 | public final Object file = String.class; 5 | public final Object directory = String.class; 6 | } -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/WorkspacePathsUpdated.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | public class WorkspacePathsUpdated extends Streamable { 4 | public final Object type = "workspace_paths_updated"; 5 | public final Object paths = arr(String.class); 6 | } 7 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/WsPutInit.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | @SuppressWarnings("unused") 4 | public class WsPutInit extends Rpc { 5 | 6 | @Override 7 | public Streamable getRequestType() { 8 | return new Streamable() { 9 | public final Object type = "wsput:init"; 10 | public final Object session = String.class; 11 | }; 12 | } 13 | 14 | @Override 15 | public Streamable getResponseType() { 16 | return new Streamable() { 17 | public final Object info = InitInfo.class; 18 | }; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /protocol/src/protocolgen/spec/WsPutLongpoll.java: -------------------------------------------------------------------------------- 1 | package protocolgen.spec; 2 | 3 | import org.json.JSONObject; 4 | 5 | @SuppressWarnings("unused") 6 | public class WsPutLongpoll extends Rpc { 7 | 8 | @Override 9 | public Streamable getRequestType() { 10 | return new Streamable() { 11 | public final Object type = "wsput:longpoll"; 12 | public final Object session = String.class; 13 | public final Object etag = Integer.class; 14 | }; 15 | } 16 | 17 | @Override 18 | public Streamable getResponseType() { 19 | return new Streamable() { 20 | public final Object data = opt(LongPollResponse.class); 21 | }; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /run-benchmark.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/run-benchmark.jar -------------------------------------------------------------------------------- /server/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/server/.DS_Store -------------------------------------------------------------------------------- /server/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | build_tmp 2 | sources.txt 3 | -------------------------------------------------------------------------------- /server/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Pasta 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | 19 | 1731509980246 20 | 21 | 30 22 | 23 | org.eclipse.core.resources.regexFilterMatcher 24 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /server/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.release=enabled 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /server/libs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/server/libs/.DS_Store -------------------------------------------------------------------------------- /server/libs/hamcrest-2.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/server/libs/hamcrest-2.2.jar -------------------------------------------------------------------------------- /server/libs/json.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/server/libs/json.jar -------------------------------------------------------------------------------- /server/libs/junit-4.13.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/server/libs/junit-4.13.2.jar -------------------------------------------------------------------------------- /server/src-test/codeprober/RunAddNumTests.java: -------------------------------------------------------------------------------- 1 | package codeprober; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.junit.runners.Parameterized; 9 | import org.junit.runners.Parameterized.Parameters; 10 | 11 | import codeprober.test.WorkspaceTestCase; 12 | import codeprober.toolglue.UnderlyingTool; 13 | 14 | @RunWith(Parameterized.class) 15 | public class RunAddNumTests { 16 | 17 | @Parameters(name = "{0}") 18 | public static Iterable data() throws IOException { 19 | return WorkspaceTestCase.listTextProbesInWorkspace( // 20 | UnderlyingTool.fromJar("../addnum/AddNum.jar"), // 21 | new File("../addnum/workspace")); 22 | } 23 | 24 | private final WorkspaceTestCase tc; 25 | 26 | public RunAddNumTests(WorkspaceTestCase tc) { 27 | this.tc = tc; 28 | } 29 | 30 | @Test 31 | public void run() { 32 | if (tc.getSrcFilePath().contains("err_")) { 33 | tc.assertFail(); 34 | } else { 35 | tc.assertPass(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /server/src-test/codeprober/ast/ASTNodeAnnotation.java: -------------------------------------------------------------------------------- 1 | package codeprober.ast; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | 7 | interface ASTNodeAnnotation { 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @interface Attribute { 10 | boolean isNTA() default true; 11 | } 12 | } -------------------------------------------------------------------------------- /server/src/codeprober/ast/AstLoopException.java: -------------------------------------------------------------------------------- 1 | package codeprober.ast; 2 | 3 | /** 4 | * There are cases where an AST node can have itself as an (indirect) parent. 5 | * This indicates a bug in the AST construction or how attributes are 6 | * written. 7 | */ 8 | @SuppressWarnings("serial") 9 | public class AstLoopException extends RuntimeException { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /server/src/codeprober/ast/AstParentException.java: -------------------------------------------------------------------------------- 1 | package codeprober.ast; 2 | 3 | @SuppressWarnings("serial") 4 | public class AstParentException extends RuntimeException { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /server/src/codeprober/locator/NodeEdge.java: -------------------------------------------------------------------------------- 1 | package codeprober.locator; 2 | 3 | import org.json.JSONObject; 4 | 5 | import codeprober.ast.AstNode; 6 | 7 | /** 8 | * Represents a step from a parent to a child node. 9 | */ 10 | //abstract class NodeEdge { 11 | // 12 | // public static enum NodeEdgeType { 13 | // ChildIndex("child"), FN("nta"), TypeAtLoc("tal"); 14 | // 15 | // private String jsonRepresentation; 16 | // 17 | // private NodeEdgeType(String jsonRepresentation) { 18 | // this.jsonRepresentation = jsonRepresentation; 19 | // 20 | // } 21 | // } 22 | // 23 | // public final AstNode sourceNode; 24 | // public final TypeAtLoc sourceLoc; 25 | // 26 | // public final AstNode targetNode; 27 | // public final TypeAtLoc targetLoc; 28 | // public final NodeEdgeType type; 29 | // public final Object value; 30 | // 31 | // public NodeEdge(AstNode sourceNode, TypeAtLoc sourceLoc, AstNode targetNode, TypeAtLoc targetLoc, NodeEdgeType type, 32 | // Object value) { 33 | // this.sourceNode = sourceNode; 34 | // this.sourceLoc = sourceLoc; 35 | // this.targetNode = targetNode; 36 | // this.targetLoc = targetLoc; 37 | // this.type = type; 38 | // this.value = value; 39 | // } 40 | // 41 | // public boolean canBeCollapsed() { 42 | // return targetLoc.loc.isMeaningful() && type == NodeEdgeType.TypeAtLoc; 43 | // } 44 | // 45 | // public JSONObject toJson() { 46 | // final JSONObject obj = new JSONObject(); 47 | // obj.put("type", type.jsonRepresentation); 48 | // obj.put("value", value); 49 | // return obj; 50 | // } 51 | // 52 | // @Override 53 | // public String toString() { 54 | // return type + "<" + targetNode + ">"; 55 | // } 56 | //} 57 | -------------------------------------------------------------------------------- /server/src/codeprober/locator/Span.java: -------------------------------------------------------------------------------- 1 | package codeprober.locator; 2 | 3 | import java.util.Objects; 4 | 5 | public class Span { 6 | public final int start, end; 7 | 8 | public Span(int start, int end) { 9 | this.start = start; 10 | this.end = end; 11 | } 12 | 13 | public int getStartLine() { 14 | return start >>> 12; 15 | } 16 | 17 | public int getStartColumn() { 18 | return start & 0xFFF; 19 | } 20 | 21 | public int getEndLine() { 22 | return end >>> 12; 23 | } 24 | 25 | public int getEndColumn() { 26 | return end & 0xFFF; 27 | } 28 | 29 | public boolean isMeaningful() { 30 | return start != 0 || end != 0; 31 | } 32 | 33 | @Override 34 | public int hashCode() { 35 | return Objects.hash(end, start); 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return "[" + start + "," + end + "]"; 41 | } 42 | 43 | @Override 44 | public boolean equals(Object obj) { 45 | if (this == obj) 46 | return true; 47 | if (obj == null) 48 | return false; 49 | if (getClass() != obj.getClass()) 50 | return false; 51 | Span other = (Span) obj; 52 | return end == other.end && start == other.start; 53 | } 54 | 55 | public boolean overlaps(Span other) { 56 | if (end < other.start || start > other.end) { 57 | return false; 58 | } 59 | return true; 60 | } 61 | 62 | public boolean covers(int startPos, int endPos) { 63 | return !isMeaningful() || (this.start <= startPos && this.end >= endPos); 64 | } 65 | 66 | public boolean containsLine(int line) { 67 | return !isMeaningful() || (getStartLine() <= line && getEndLine() >= line); 68 | } 69 | } -------------------------------------------------------------------------------- /server/src/codeprober/locator/TypeAtLoc.java: -------------------------------------------------------------------------------- 1 | package codeprober.locator; 2 | 3 | import java.util.Objects; 4 | 5 | import codeprober.AstInfo; 6 | import codeprober.ast.AstNode; 7 | import codeprober.metaprogramming.InvokeProblem; 8 | 9 | public class TypeAtLoc { 10 | 11 | public final String type; 12 | public final Span loc; 13 | public final String label; 14 | 15 | public TypeAtLoc(String type, Span position, String label) { 16 | this.type = type; 17 | this.loc = position; 18 | this.label = label; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | String labelInsert; 24 | if (label != null) { 25 | labelInsert = "[" + label + "]"; 26 | } else { 27 | labelInsert = ""; 28 | } 29 | return type + labelInsert + "@[" + loc.start + ".." + loc.end + "]"; 30 | } 31 | 32 | public static TypeAtLoc from(AstInfo info, AstNode astNode) throws InvokeProblem { 33 | return new TypeAtLoc(astNode.underlyingAstNode.getClass().getName(), astNode.getRecoveredSpan(info), astNode.getNodeLabel()); 34 | } 35 | 36 | @Override 37 | public int hashCode() { 38 | return Objects.hash(loc, type); 39 | } 40 | 41 | @Override 42 | public boolean equals(Object obj) { 43 | if (this == obj) 44 | return true; 45 | if (obj == null) 46 | return false; 47 | if (getClass() != obj.getClass()) 48 | return false; 49 | final TypeAtLoc other = (TypeAtLoc) obj; 50 | return Objects.equals(loc, other.loc) && Objects.equals(type, other.type) && Objects.equals(label, other.label); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /server/src/codeprober/metaprogramming/AstNodeApiStyle.java: -------------------------------------------------------------------------------- 1 | package codeprober.metaprogramming; 2 | 3 | public enum AstNodeApiStyle { 4 | 5 | /** 6 | * cpr_getStartLine(), cpr_getStartColumn(), cpr_getEndLine(), 7 | * cpr_getEndColumn(), getNumChild(), getChild(int), getParent() 8 | *

9 | * This is same as {@link #JASTADD_SEPARATE_LINE_COLUMN} but with a cpr_ prefix 10 | * for position info. This is to help tools that are using position for 11 | * something else, and that don't necessarily use the same conventions as 12 | * CodeProber. For example, CodeProber expects the first column to be 1, and a 13 | * missing position to be zero. Other tools might already be implemented with a 14 | * different standard, and can then use the cpr_ prefix to support both 15 | * conventions simultaneously. 16 | */ 17 | 18 | CPR_SEPARATE_LINE_COLUMN, 19 | 20 | /** 21 | * getStart() and getEnd(), each with 20 bits for line and 12 bits for column, 22 | * e.g: 0xLLLLLCCC. 23 | *

24 | * getNumChild(), getChild(int), getParent() 25 | */ 26 | BEAVER_PACKED_BITS, 27 | 28 | /** 29 | * getStartLine(), getStartColumn(), getEndLine(), getEndColumn(), 30 | * getNumChild(), getChild(int), getParent() 31 | */ 32 | JASTADD_SEPARATE_LINE_COLUMN, 33 | 34 | /** 35 | * The style used by PMD. getBeginLine(), getBeginColumn(), getEndLine(), 36 | * getEndColumn() getNumChildren(), getChild(int), getParent() 37 | */ 38 | PMD_SEPARATE_LINE_COLUMN, 39 | 40 | /** 41 | * No line/column functions. 42 | * getNumChild(), getChild(int), getParent() 43 | */ 44 | JASTADD_NO_POSITION, 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/metaprogramming/InvokeProblem.java: -------------------------------------------------------------------------------- 1 | package codeprober.metaprogramming; 2 | 3 | @SuppressWarnings("serial") 4 | public class InvokeProblem extends RuntimeException { 5 | 6 | public InvokeProblem(Throwable cause) { 7 | super(cause); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /server/src/codeprober/metaprogramming/Reflect.java: -------------------------------------------------------------------------------- 1 | package codeprober.metaprogramming; 2 | 3 | import java.lang.reflect.InvocationTargetException; 4 | import java.lang.reflect.Method; 5 | 6 | public class Reflect { 7 | 8 | public static final Object VOID_RETURN_VALUE = new Object() { 9 | @Override 10 | public String toString() { 11 | return ""; 12 | } 13 | }; 14 | 15 | public static Object getParent(Object astNode) { 16 | return Reflect.invoke0(astNode, "getParent"); 17 | } 18 | 19 | public static Object invokeN(Object astNode, String mth, Class[] argTypes, Object[] argValues) { 20 | try { 21 | final Method m = astNode.getClass().getMethod(mth, argTypes); 22 | m.setAccessible(true); 23 | final Object val = m.invoke(astNode, argValues); 24 | return m.getReturnType() == Void.TYPE ? VOID_RETURN_VALUE : val; 25 | } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException 26 | | SecurityException e) { 27 | throw new InvokeProblem(e); 28 | } 29 | } 30 | 31 | public static Object invoke0(Object astNode, String mth) { 32 | try { 33 | final Method m = astNode.getClass().getMethod(mth); 34 | m.setAccessible(true); 35 | final Object val = m.invoke(astNode); 36 | return m.getReturnType() == Void.TYPE ? VOID_RETURN_VALUE : val; 37 | } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException 38 | | SecurityException e) { 39 | throw new InvokeProblem(e); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /server/src/codeprober/metaprogramming/TypeIdentifier.java: -------------------------------------------------------------------------------- 1 | package codeprober.metaprogramming; 2 | 3 | import codeprober.ast.AstNode; 4 | 5 | public interface TypeIdentifier { 6 | boolean matchesDesiredType(AstNode node); 7 | } 8 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/AstCacheStrategy.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | /** 4 | * Caching the AST is great for performance, but can hurt the debugging process 5 | * sometimes. This enum represents the choices the user can make for caching. 6 | */ 7 | public enum AstCacheStrategy { 8 | 9 | /** 10 | * Cache everything when possible. 11 | */ 12 | FULL, 13 | 14 | /** 15 | * Keep the AST if the input file is identical, but call 'flushTreeCache' before 16 | * evaluating any attribute. 17 | *

18 | * This is a good default choice. 19 | */ 20 | PARTIAL, 21 | 22 | /** 23 | * Don't cache the AST at all. 24 | */ 25 | NONE, 26 | 27 | /** 28 | * Don't cache the AST or the underlying jar file. Really bad choice for 29 | * performance! 30 | */ 31 | PURGE; 32 | 33 | public boolean canCacheAST() { 34 | switch (this) { 35 | case FULL: 36 | case PARTIAL: 37 | return true; 38 | 39 | default: 40 | return false; 41 | } 42 | } 43 | 44 | public static AstCacheStrategy fallbackParse(String paramValue) { 45 | try { 46 | return AstCacheStrategy.valueOf(paramValue); 47 | } catch (IllegalArgumentException e) { 48 | System.out.println("Got invalid position recovery argument: " + paramValue); 49 | return PARTIAL; 50 | } 51 | } 52 | 53 | public static AstCacheStrategy parseFromJson(String string) { 54 | return fallbackParse(string); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/BinaryInputStream.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.IOException; 5 | 6 | public interface BinaryInputStream { 7 | int readInt() throws IOException; 8 | long readLong() throws IOException; 9 | boolean readBoolean() throws IOException; 10 | String readUTF() throws IOException; 11 | 12 | public static class DataInputStreamWrapper implements BinaryInputStream { 13 | 14 | private final DataInputStream dis; 15 | 16 | public DataInputStreamWrapper(DataInputStream dos) { 17 | this.dis = dos; 18 | } 19 | 20 | @Override 21 | public int readInt() throws IOException { 22 | return dis.readInt(); 23 | } 24 | 25 | @Override 26 | public long readLong() throws IOException { 27 | return dis.readLong(); 28 | } 29 | 30 | @Override 31 | public boolean readBoolean() throws IOException { 32 | return dis.readBoolean(); 33 | } 34 | 35 | @Override 36 | public String readUTF() throws IOException { 37 | return dis.readUTF(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/BinaryOutputStream.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | import java.io.DataOutputStream; 4 | import java.io.IOException; 5 | 6 | public interface BinaryOutputStream { 7 | void writeInt(int v) throws IOException; 8 | void writeLong(long v) throws IOException; 9 | void writeBoolean(boolean v) throws IOException; 10 | void writeUTF(String v) throws IOException; 11 | 12 | public static class DataOutputStreamWrapper implements BinaryOutputStream { 13 | 14 | private final DataOutputStream dos; 15 | 16 | public DataOutputStreamWrapper(DataOutputStream dos) { 17 | this.dos = dos; 18 | } 19 | 20 | @Override 21 | public void writeInt(int v) throws IOException { 22 | this.dos.writeInt(v); 23 | } 24 | 25 | @Override 26 | public void writeLong(long v) throws IOException { 27 | this.dos.writeLong(v); 28 | } 29 | 30 | @Override 31 | public void writeBoolean(boolean v) throws IOException { 32 | this.dos.writeBoolean(v); 33 | } 34 | 35 | @Override 36 | public void writeUTF(String v) throws IOException { 37 | this.dos.writeUTF(v); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/ClientConnection.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | import org.json.JSONObject; 4 | 5 | public interface ClientConnection { 6 | void sendAsyncMessage(JSONObject message); 7 | void setOnDisconnectListener(Runnable onDisconnect); 8 | } 9 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/ClientRequest.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | import java.util.concurrent.atomic.AtomicBoolean; 4 | import java.util.function.Consumer; 5 | 6 | import org.json.JSONObject; 7 | 8 | import codeprober.protocol.data.AsyncRpcUpdate; 9 | 10 | public class ClientRequest { 11 | 12 | public final JSONObject data; 13 | private final Consumer asyncResponseConsumer; 14 | public final AtomicBoolean connectionIsAlive; 15 | 16 | public ClientRequest(JSONObject data, Consumer asyncResponseConsumer, AtomicBoolean connectionIsAlive) { 17 | this.data = data; 18 | this.asyncResponseConsumer = asyncResponseConsumer; 19 | this.connectionIsAlive = connectionIsAlive; 20 | } 21 | 22 | public void sendAsyncResponse(AsyncRpcUpdate message) { 23 | asyncResponseConsumer.accept(message);; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/DiagnosticType.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | import java.util.Locale; 4 | 5 | public enum DiagnosticType { 6 | 7 | // Squigglys 8 | ERROR, WARNING, INFO, HINT, 9 | 10 | // Lines 11 | LINE_PP, LINE_AA, LINE_AP, LINE_PA, 12 | 13 | ; 14 | 15 | public static DiagnosticType parseFromJson(String string) { 16 | try { 17 | return DiagnosticType.valueOf(string.toUpperCase(Locale.ENGLISH)); 18 | } catch (IllegalArgumentException e) { 19 | System.out.println("Invalid DiagnosticSeverity value '" + string + "'"); 20 | e.printStackTrace(); 21 | return null; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/GetTestSuiteContentsErrorCode.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | import java.util.Locale; 4 | 5 | public enum GetTestSuiteContentsErrorCode { 6 | 7 | NO_TEST_DIR_SET, 8 | 9 | NO_SUCH_TEST_SUITE, 10 | 11 | ERROR_WHEN_READING_FILE, 12 | ; 13 | 14 | public static GetTestSuiteContentsErrorCode parseFromJson(String string) { 15 | try { 16 | return GetTestSuiteContentsErrorCode.valueOf(string.toUpperCase(Locale.ENGLISH)); 17 | } catch (IllegalArgumentException e) { 18 | System.out.println("Invalid GetTestSuiteContentsErrorCode value '" + string + "'"); 19 | e.printStackTrace(); 20 | return null; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/ListTestSuitesErrorCode.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | import java.util.Locale; 4 | 5 | public enum ListTestSuitesErrorCode { 6 | 7 | NO_TEST_DIR_SET, 8 | 9 | ERROR_WHEN_LISTING_TEST_DIR, 10 | ; 11 | 12 | public static ListTestSuitesErrorCode parseFromJson(String string) { 13 | try { 14 | return ListTestSuitesErrorCode.valueOf(string.toUpperCase(Locale.ENGLISH)); 15 | } catch (IllegalArgumentException e) { 16 | System.out.println("Invalid ListTestSuitesErrorCode value '" + string + "'"); 17 | e.printStackTrace(); 18 | return null; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/ProbeProtocol.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | import org.json.JSONArray; 4 | import org.json.JSONObject; 5 | 6 | public class ProbeProtocol extends ProtocolBuilder { 7 | 8 | // Query 9 | public static final String type = "query"; 10 | public static final Entry positionRecovery = str("posRecovery"); 11 | public static final Entry cache = str("cache"); 12 | public static final Entry text = str("text"); 13 | public static final Entry captureStdout = bool("stdout"); 14 | public static final Entry mainArgs = arr("mainArgs"); 15 | public static final Entry tmpSuffix = str("tmpSuffix"); 16 | public static final Entry query = obj("query"); 17 | 18 | public static class Query { 19 | public static final Entry attribute = obj("attr"); 20 | public static final Entry locator = obj("locator"); 21 | } 22 | 23 | public static class Attribute { 24 | public static final Entry name = str("name"); 25 | public static final Entry args = arr("args"); 26 | } 27 | 28 | // Response 29 | public static final Entry body = arr("body"); 30 | } 31 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/PutTestSuiteContentsErrorCode.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | import java.util.Locale; 4 | 5 | public enum PutTestSuiteContentsErrorCode { 6 | 7 | NO_TEST_DIR_SET, 8 | 9 | ERROR_WHEN_WRITING_FILE, 10 | ; 11 | 12 | public static PutTestSuiteContentsErrorCode parseFromJson(String string) { 13 | try { 14 | return PutTestSuiteContentsErrorCode.valueOf(string.toUpperCase(Locale.ENGLISH)); 15 | } catch (IllegalArgumentException e) { 16 | System.out.println("Invalid PutTestSuiteContentsErrorCode value '" + string + "'"); 17 | e.printStackTrace(); 18 | return null; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/TestCaseAssertType.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | public enum TestCaseAssertType { 4 | 5 | /** 6 | * Output should be exactly identical 7 | */ 8 | IDENTITY, 9 | 10 | /** 11 | * Output should have same content, but top-level lines may be out of order 12 | */ 13 | SET, 14 | 15 | /** 16 | * Evaluation should not throw a RuntimeException. 17 | */ 18 | SMOKE, 19 | 20 | ; 21 | 22 | public static TestCaseAssertType parseFromJson(String val) { 23 | try { 24 | return TestCaseAssertType.valueOf(val); 25 | } catch (IllegalArgumentException e) { 26 | System.out.println("Got invalid " + TestCaseAssertType.class.getSimpleName() + " value: " + val); 27 | return IDENTITY; 28 | } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/TestProtocol.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol; 2 | 3 | import org.json.JSONArray; 4 | 5 | //public class TestProtocol extends ProtocolBuilder { 6 | // 7 | // // Query 8 | // public static final String type = "testMeta"; 9 | // 10 | // public static class ListTestSuites { 11 | // // Query 12 | // public static final String type = "meta:listTestSuites"; 13 | // 14 | // // Response 15 | // public static final Entry suites = arr("suites"); 16 | // } 17 | // 18 | // public static class GetTestSuite { 19 | // // Query 20 | // public static final String type = "meta:getTestSuite"; 21 | // public static final Entry suite = str("suite"); 22 | // 23 | // // Response 24 | // public static final Entry contents = str("contents"); 25 | // } 26 | //} 27 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/BackingFile.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class BackingFile implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String path; 7 | public final String value; 8 | public BackingFile(String path, String value) { 9 | this.path = path; 10 | this.value = value; 11 | } 12 | public BackingFile(java.io.DataInputStream src) throws java.io.IOException { 13 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 14 | } 15 | public BackingFile(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 16 | this.path = src.readUTF(); 17 | this.value = src.readUTF(); 18 | } 19 | 20 | public static BackingFile fromJSON(JSONObject obj) { 21 | return new BackingFile( 22 | obj.getString("path") 23 | , obj.getString("value") 24 | ); 25 | } 26 | public JSONObject toJSON() { 27 | JSONObject _ret = new JSONObject(); 28 | _ret.put("path", path); 29 | _ret.put("value", value); 30 | return _ret; 31 | } 32 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 33 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 34 | } 35 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 36 | dst.writeUTF(path); 37 | dst.writeUTF(value); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/BackingFileUpdated.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class BackingFileUpdated implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final String contents; 8 | public BackingFileUpdated(String contents) { 9 | this.type = "backing_file_update"; 10 | this.contents = contents; 11 | } 12 | public BackingFileUpdated(java.io.DataInputStream src) throws java.io.IOException { 13 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 14 | } 15 | public BackingFileUpdated(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 16 | this.type = "backing_file_update"; 17 | this.contents = src.readUTF(); 18 | } 19 | 20 | public static BackingFileUpdated fromJSON(JSONObject obj) { 21 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "backing_file_update"); 22 | return new BackingFileUpdated( 23 | obj.getString("contents") 24 | ); 25 | } 26 | public JSONObject toJSON() { 27 | JSONObject _ret = new JSONObject(); 28 | _ret.put("type", type); 29 | _ret.put("contents", contents); 30 | return _ret; 31 | } 32 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 33 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 34 | } 35 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 36 | 37 | dst.writeUTF(contents); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/CompleteRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class CompleteRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final java.util.List lines; 7 | public CompleteRes() { 8 | this((java.util.List)null); 9 | } 10 | public CompleteRes(java.util.List lines) { 11 | this.lines = lines; 12 | } 13 | public CompleteRes(java.io.DataInputStream src) throws java.io.IOException { 14 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 15 | } 16 | public CompleteRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 17 | this.lines = src.readBoolean() ? codeprober.util.JsonUtil.readDataArr(src, () -> src.readUTF()) : null; 18 | } 19 | 20 | public static CompleteRes fromJSON(JSONObject obj) { 21 | return new CompleteRes( 22 | obj.has("lines") ? (codeprober.util.JsonUtil.mapArr(obj.getJSONArray("lines"), (arr, idx) -> arr.getString(idx))) : null 23 | ); 24 | } 25 | public JSONObject toJSON() { 26 | JSONObject _ret = new JSONObject(); 27 | _ret.put("lines", new org.json.JSONArray(lines)); 28 | return _ret; 29 | } 30 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 31 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 32 | } 33 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 34 | if (lines != null) { dst.writeBoolean(true); codeprober.util.JsonUtil.writeDataArr(dst, lines, ent -> dst.writeUTF(ent));; } else { dst.writeBoolean(false); } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/EvaluatePropertyRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class EvaluatePropertyRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final PropertyEvaluationResult response; 7 | public EvaluatePropertyRes(PropertyEvaluationResult response) { 8 | this.response = response; 9 | } 10 | public EvaluatePropertyRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public EvaluatePropertyRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.response = new PropertyEvaluationResult(src); 15 | } 16 | 17 | public static EvaluatePropertyRes fromJSON(JSONObject obj) { 18 | return new EvaluatePropertyRes( 19 | PropertyEvaluationResult.fromJSON(obj.getJSONObject("response")) 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("response", response.toJSON()); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | response.writeTo(dst); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/FNStep.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class FNStep implements codeprober.util.JsonUtil.ToJsonable { 6 | public final Property property; 7 | public FNStep(Property property) { 8 | this.property = property; 9 | } 10 | public FNStep(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public FNStep(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.property = new Property(src); 15 | } 16 | 17 | public static FNStep fromJSON(JSONObject obj) { 18 | return new FNStep( 19 | Property.fromJSON(obj.getJSONObject("property")) 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("property", property.toJSON()); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | property.writeTo(dst); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/GetTestSuiteReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class GetTestSuiteReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final String suite; 8 | public GetTestSuiteReq(String suite) { 9 | this.type = "Test:GetTestSuite"; 10 | this.suite = suite; 11 | } 12 | public GetTestSuiteReq(java.io.DataInputStream src) throws java.io.IOException { 13 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 14 | } 15 | public GetTestSuiteReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 16 | this.type = "Test:GetTestSuite"; 17 | this.suite = src.readUTF(); 18 | } 19 | 20 | public static GetTestSuiteReq fromJSON(JSONObject obj) { 21 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "Test:GetTestSuite"); 22 | return new GetTestSuiteReq( 23 | obj.getString("suite") 24 | ); 25 | } 26 | public JSONObject toJSON() { 27 | JSONObject _ret = new JSONObject(); 28 | _ret.put("type", type); 29 | _ret.put("suite", suite); 30 | return _ret; 31 | } 32 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 33 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 34 | } 35 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 36 | 37 | dst.writeUTF(suite); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/GetTestSuiteRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class GetTestSuiteRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final TestSuiteOrError result; 7 | public GetTestSuiteRes(TestSuiteOrError result) { 8 | this.result = result; 9 | } 10 | public GetTestSuiteRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public GetTestSuiteRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.result = new TestSuiteOrError(src); 15 | } 16 | 17 | public static GetTestSuiteRes fromJSON(JSONObject obj) { 18 | return new GetTestSuiteRes( 19 | TestSuiteOrError.fromJSON(obj.getJSONObject("result")) 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("result", result.toJSON()); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | result.writeTo(dst); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/GetWorkerStatusReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class GetWorkerStatusReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public GetWorkerStatusReq() { 8 | this.type = "Concurrent:GetWorkerStatus"; 9 | } 10 | public GetWorkerStatusReq(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public GetWorkerStatusReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.type = "Concurrent:GetWorkerStatus"; 15 | } 16 | 17 | public static GetWorkerStatusReq fromJSON(JSONObject obj) { 18 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "Concurrent:GetWorkerStatus"); 19 | return new GetWorkerStatusReq( 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("type", type); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/GetWorkerStatusRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class GetWorkerStatusRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final java.util.List stackTrace; 7 | public GetWorkerStatusRes(java.util.List stackTrace) { 8 | this.stackTrace = stackTrace; 9 | } 10 | public GetWorkerStatusRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public GetWorkerStatusRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.stackTrace = codeprober.util.JsonUtil.readDataArr(src, () -> src.readUTF()); 15 | } 16 | 17 | public static GetWorkerStatusRes fromJSON(JSONObject obj) { 18 | return new GetWorkerStatusRes( 19 | codeprober.util.JsonUtil.mapArr(obj.getJSONArray("stackTrace"), (arr, idx) -> arr.getString(idx)) 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("stackTrace", new org.json.JSONArray(stackTrace)); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | codeprober.util.JsonUtil.writeDataArr(dst, stackTrace, ent -> dst.writeUTF(ent)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/GetWorkspaceFileReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class GetWorkspaceFileReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final String path; 8 | public GetWorkspaceFileReq(String path) { 9 | this.type = "GetWorkspaceFile"; 10 | this.path = path; 11 | } 12 | public GetWorkspaceFileReq(java.io.DataInputStream src) throws java.io.IOException { 13 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 14 | } 15 | public GetWorkspaceFileReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 16 | this.type = "GetWorkspaceFile"; 17 | this.path = src.readUTF(); 18 | } 19 | 20 | public static GetWorkspaceFileReq fromJSON(JSONObject obj) { 21 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "GetWorkspaceFile"); 22 | return new GetWorkspaceFileReq( 23 | obj.getString("path") 24 | ); 25 | } 26 | public JSONObject toJSON() { 27 | JSONObject _ret = new JSONObject(); 28 | _ret.put("type", type); 29 | _ret.put("path", path); 30 | return _ret; 31 | } 32 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 33 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 34 | } 35 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 36 | 37 | dst.writeUTF(path); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/HighlightableMessage.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class HighlightableMessage implements codeprober.util.JsonUtil.ToJsonable { 6 | public final int start; 7 | public final int end; 8 | public final String msg; 9 | public HighlightableMessage(int start, int end, String msg) { 10 | this.start = start; 11 | this.end = end; 12 | this.msg = msg; 13 | } 14 | public HighlightableMessage(java.io.DataInputStream src) throws java.io.IOException { 15 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 16 | } 17 | public HighlightableMessage(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 18 | this.start = src.readInt(); 19 | this.end = src.readInt(); 20 | this.msg = src.readUTF(); 21 | } 22 | 23 | public static HighlightableMessage fromJSON(JSONObject obj) { 24 | return new HighlightableMessage( 25 | obj.getInt("start") 26 | , obj.getInt("end") 27 | , obj.getString("msg") 28 | ); 29 | } 30 | public JSONObject toJSON() { 31 | JSONObject _ret = new JSONObject(); 32 | _ret.put("start", start); 33 | _ret.put("end", end); 34 | _ret.put("msg", msg); 35 | return _ret; 36 | } 37 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 38 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 39 | } 40 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 41 | dst.writeInt(start); 42 | dst.writeInt(end); 43 | dst.writeUTF(msg); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/HoverRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class HoverRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final java.util.List lines; 7 | public HoverRes() { 8 | this((java.util.List)null); 9 | } 10 | public HoverRes(java.util.List lines) { 11 | this.lines = lines; 12 | } 13 | public HoverRes(java.io.DataInputStream src) throws java.io.IOException { 14 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 15 | } 16 | public HoverRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 17 | this.lines = src.readBoolean() ? codeprober.util.JsonUtil.readDataArr(src, () -> src.readUTF()) : null; 18 | } 19 | 20 | public static HoverRes fromJSON(JSONObject obj) { 21 | return new HoverRes( 22 | obj.has("lines") ? (codeprober.util.JsonUtil.mapArr(obj.getJSONArray("lines"), (arr, idx) -> arr.getString(idx))) : null 23 | ); 24 | } 25 | public JSONObject toJSON() { 26 | JSONObject _ret = new JSONObject(); 27 | _ret.put("lines", new org.json.JSONArray(lines)); 28 | return _ret; 29 | } 30 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 31 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 32 | } 33 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 34 | if (lines != null) { dst.writeBoolean(true); codeprober.util.JsonUtil.writeDataArr(dst, lines, ent -> dst.writeUTF(ent));; } else { dst.writeBoolean(false); } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/ListNodesReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class ListNodesReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final int pos; 8 | public final ParsingRequestData src; 9 | public ListNodesReq(int pos, ParsingRequestData src) { 10 | this.type = "ListNodes"; 11 | this.pos = pos; 12 | this.src = src; 13 | } 14 | public ListNodesReq(java.io.DataInputStream src) throws java.io.IOException { 15 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 16 | } 17 | public ListNodesReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 18 | this.type = "ListNodes"; 19 | this.pos = src.readInt(); 20 | this.src = new ParsingRequestData(src); 21 | } 22 | 23 | public static ListNodesReq fromJSON(JSONObject obj) { 24 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "ListNodes"); 25 | return new ListNodesReq( 26 | obj.getInt("pos") 27 | , ParsingRequestData.fromJSON(obj.getJSONObject("src")) 28 | ); 29 | } 30 | public JSONObject toJSON() { 31 | JSONObject _ret = new JSONObject(); 32 | _ret.put("type", type); 33 | _ret.put("pos", pos); 34 | _ret.put("src", src.toJSON()); 35 | return _ret; 36 | } 37 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 38 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 39 | } 40 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 41 | 42 | dst.writeInt(pos); 43 | src.writeTo(dst); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/ListTestSuitesReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class ListTestSuitesReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public ListTestSuitesReq() { 8 | this.type = "Test:ListTestSuites"; 9 | } 10 | public ListTestSuitesReq(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public ListTestSuitesReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.type = "Test:ListTestSuites"; 15 | } 16 | 17 | public static ListTestSuitesReq fromJSON(JSONObject obj) { 18 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "Test:ListTestSuites"); 19 | return new ListTestSuitesReq( 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("type", type); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/ListTestSuitesRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class ListTestSuitesRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final TestSuiteListOrError result; 7 | public ListTestSuitesRes(TestSuiteListOrError result) { 8 | this.result = result; 9 | } 10 | public ListTestSuitesRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public ListTestSuitesRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.result = new TestSuiteListOrError(src); 15 | } 16 | 17 | public static ListTestSuitesRes fromJSON(JSONObject obj) { 18 | return new ListTestSuitesRes( 19 | TestSuiteListOrError.fromJSON(obj.getJSONObject("result")) 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("result", result.toJSON()); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | result.writeTo(dst); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/ListWorkspaceDirectoryReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class ListWorkspaceDirectoryReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final String path; 8 | public ListWorkspaceDirectoryReq() { 9 | this((String)null); 10 | } 11 | public ListWorkspaceDirectoryReq(String path) { 12 | this.type = "ListWorkspaceDirectory"; 13 | this.path = path; 14 | } 15 | public ListWorkspaceDirectoryReq(java.io.DataInputStream src) throws java.io.IOException { 16 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 17 | } 18 | public ListWorkspaceDirectoryReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 19 | this.type = "ListWorkspaceDirectory"; 20 | this.path = src.readBoolean() ? src.readUTF() : null; 21 | } 22 | 23 | public static ListWorkspaceDirectoryReq fromJSON(JSONObject obj) { 24 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "ListWorkspaceDirectory"); 25 | return new ListWorkspaceDirectoryReq( 26 | obj.has("path") ? (obj.getString("path")) : null 27 | ); 28 | } 29 | public JSONObject toJSON() { 30 | JSONObject _ret = new JSONObject(); 31 | _ret.put("type", type); 32 | if (path != null) _ret.put("path", path); 33 | return _ret; 34 | } 35 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 36 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 37 | } 38 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 39 | 40 | if (path != null) { dst.writeBoolean(true); dst.writeUTF(path);; } else { dst.writeBoolean(false); } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/NullableNodeLocator.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class NullableNodeLocator implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final NodeLocator value; 8 | public NullableNodeLocator(String type) { 9 | this(type, (NodeLocator)null); 10 | } 11 | public NullableNodeLocator(String type, NodeLocator value) { 12 | this.type = type; 13 | this.value = value; 14 | } 15 | public NullableNodeLocator(java.io.DataInputStream src) throws java.io.IOException { 16 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 17 | } 18 | public NullableNodeLocator(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 19 | this.type = src.readUTF(); 20 | this.value = src.readBoolean() ? new NodeLocator(src) : null; 21 | } 22 | 23 | public static NullableNodeLocator fromJSON(JSONObject obj) { 24 | return new NullableNodeLocator( 25 | obj.getString("type") 26 | , obj.has("value") ? (NodeLocator.fromJSON(obj.getJSONObject("value"))) : null 27 | ); 28 | } 29 | public JSONObject toJSON() { 30 | JSONObject _ret = new JSONObject(); 31 | _ret.put("type", type); 32 | if (value != null) _ret.put("value", value.toJSON()); 33 | return _ret; 34 | } 35 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 36 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 37 | } 38 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 39 | dst.writeUTF(type); 40 | if (value != null) { dst.writeBoolean(true); value.writeTo(dst);; } else { dst.writeBoolean(false); } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/PollWorkerStatusReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class PollWorkerStatusReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final long job; 8 | public PollWorkerStatusReq(long job) { 9 | this.type = "Concurrent:PollWorkerStatus"; 10 | this.job = job; 11 | } 12 | public PollWorkerStatusReq(java.io.DataInputStream src) throws java.io.IOException { 13 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 14 | } 15 | public PollWorkerStatusReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 16 | this.type = "Concurrent:PollWorkerStatus"; 17 | this.job = src.readLong(); 18 | } 19 | 20 | public static PollWorkerStatusReq fromJSON(JSONObject obj) { 21 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "Concurrent:PollWorkerStatus"); 22 | return new PollWorkerStatusReq( 23 | obj.getLong("job") 24 | ); 25 | } 26 | public JSONObject toJSON() { 27 | JSONObject _ret = new JSONObject(); 28 | _ret.put("type", type); 29 | _ret.put("job", job); 30 | return _ret; 31 | } 32 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 33 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 34 | } 35 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 36 | 37 | dst.writeLong(job); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/PollWorkerStatusRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class PollWorkerStatusRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final boolean ok; 7 | public PollWorkerStatusRes(boolean ok) { 8 | this.ok = ok; 9 | } 10 | public PollWorkerStatusRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public PollWorkerStatusRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.ok = src.readBoolean(); 15 | } 16 | 17 | public static PollWorkerStatusRes fromJSON(JSONObject obj) { 18 | return new PollWorkerStatusRes( 19 | obj.getBoolean("ok") 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("ok", ok); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | dst.writeBoolean(ok); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/PutTestSuiteReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class PutTestSuiteReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final String suite; 8 | public final TestSuite contents; 9 | public PutTestSuiteReq(String suite, TestSuite contents) { 10 | this.type = "Test:PutTestSuite"; 11 | this.suite = suite; 12 | this.contents = contents; 13 | } 14 | public PutTestSuiteReq(java.io.DataInputStream src) throws java.io.IOException { 15 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 16 | } 17 | public PutTestSuiteReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 18 | this.type = "Test:PutTestSuite"; 19 | this.suite = src.readUTF(); 20 | this.contents = new TestSuite(src); 21 | } 22 | 23 | public static PutTestSuiteReq fromJSON(JSONObject obj) { 24 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "Test:PutTestSuite"); 25 | return new PutTestSuiteReq( 26 | obj.getString("suite") 27 | , TestSuite.fromJSON(obj.getJSONObject("contents")) 28 | ); 29 | } 30 | public JSONObject toJSON() { 31 | JSONObject _ret = new JSONObject(); 32 | _ret.put("type", type); 33 | _ret.put("suite", suite); 34 | _ret.put("contents", contents.toJSON()); 35 | return _ret; 36 | } 37 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 38 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 39 | } 40 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 41 | 42 | dst.writeUTF(suite); 43 | contents.writeTo(dst); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/PutTestSuiteRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class PutTestSuiteRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final codeprober.protocol.PutTestSuiteContentsErrorCode err; 7 | public PutTestSuiteRes() { 8 | this((codeprober.protocol.PutTestSuiteContentsErrorCode)null); 9 | } 10 | public PutTestSuiteRes(codeprober.protocol.PutTestSuiteContentsErrorCode err) { 11 | this.err = err; 12 | } 13 | public PutTestSuiteRes(java.io.DataInputStream src) throws java.io.IOException { 14 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 15 | } 16 | public PutTestSuiteRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 17 | this.err = src.readBoolean() ? codeprober.protocol.PutTestSuiteContentsErrorCode.values()[src.readInt()] : null; 18 | } 19 | 20 | public static PutTestSuiteRes fromJSON(JSONObject obj) { 21 | return new PutTestSuiteRes( 22 | obj.has("err") ? (codeprober.protocol.PutTestSuiteContentsErrorCode.parseFromJson(obj.getString("err"))) : null 23 | ); 24 | } 25 | public JSONObject toJSON() { 26 | JSONObject _ret = new JSONObject(); 27 | if (err != null) _ret.put("err", err.name()); 28 | return _ret; 29 | } 30 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 31 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 32 | } 33 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 34 | if (err != null) { dst.writeBoolean(true); dst.writeInt(err.ordinal());; } else { dst.writeBoolean(false); } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/PutWorkspaceContentReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class PutWorkspaceContentReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final String path; 8 | public final String content; 9 | public PutWorkspaceContentReq(String path, String content) { 10 | this.type = "PutWorkspaceContent"; 11 | this.path = path; 12 | this.content = content; 13 | } 14 | public PutWorkspaceContentReq(java.io.DataInputStream src) throws java.io.IOException { 15 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 16 | } 17 | public PutWorkspaceContentReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 18 | this.type = "PutWorkspaceContent"; 19 | this.path = src.readUTF(); 20 | this.content = src.readUTF(); 21 | } 22 | 23 | public static PutWorkspaceContentReq fromJSON(JSONObject obj) { 24 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "PutWorkspaceContent"); 25 | return new PutWorkspaceContentReq( 26 | obj.getString("path") 27 | , obj.getString("content") 28 | ); 29 | } 30 | public JSONObject toJSON() { 31 | JSONObject _ret = new JSONObject(); 32 | _ret.put("type", type); 33 | _ret.put("path", path); 34 | _ret.put("content", content); 35 | return _ret; 36 | } 37 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 38 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 39 | } 40 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 41 | 42 | dst.writeUTF(path); 43 | dst.writeUTF(content); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/PutWorkspaceContentRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class PutWorkspaceContentRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final boolean ok; 7 | public PutWorkspaceContentRes(boolean ok) { 8 | this.ok = ok; 9 | } 10 | public PutWorkspaceContentRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public PutWorkspaceContentRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.ok = src.readBoolean(); 15 | } 16 | 17 | public static PutWorkspaceContentRes fromJSON(JSONObject obj) { 18 | return new PutWorkspaceContentRes( 19 | obj.getBoolean("ok") 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("ok", ok); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | dst.writeBoolean(ok); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/PutWorkspaceMetadataRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class PutWorkspaceMetadataRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final boolean ok; 7 | public PutWorkspaceMetadataRes(boolean ok) { 8 | this.ok = ok; 9 | } 10 | public PutWorkspaceMetadataRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public PutWorkspaceMetadataRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.ok = src.readBoolean(); 15 | } 16 | 17 | public static PutWorkspaceMetadataRes fromJSON(JSONObject obj) { 18 | return new PutWorkspaceMetadataRes( 19 | obj.getBoolean("ok") 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("ok", ok); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | dst.writeBoolean(ok); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/Refresh.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class Refresh implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public Refresh() { 8 | this.type = "refresh"; 9 | } 10 | public Refresh(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public Refresh(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.type = "refresh"; 15 | } 16 | 17 | public static Refresh fromJSON(JSONObject obj) { 18 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "refresh"); 19 | return new Refresh( 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("type", type); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/RenameWorkspacePathReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class RenameWorkspacePathReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final String srcPath; 8 | public final String dstPath; 9 | public RenameWorkspacePathReq(String srcPath, String dstPath) { 10 | this.type = "RenameWorkspacePath"; 11 | this.srcPath = srcPath; 12 | this.dstPath = dstPath; 13 | } 14 | public RenameWorkspacePathReq(java.io.DataInputStream src) throws java.io.IOException { 15 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 16 | } 17 | public RenameWorkspacePathReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 18 | this.type = "RenameWorkspacePath"; 19 | this.srcPath = src.readUTF(); 20 | this.dstPath = src.readUTF(); 21 | } 22 | 23 | public static RenameWorkspacePathReq fromJSON(JSONObject obj) { 24 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "RenameWorkspacePath"); 25 | return new RenameWorkspacePathReq( 26 | obj.getString("srcPath") 27 | , obj.getString("dstPath") 28 | ); 29 | } 30 | public JSONObject toJSON() { 31 | JSONObject _ret = new JSONObject(); 32 | _ret.put("type", type); 33 | _ret.put("srcPath", srcPath); 34 | _ret.put("dstPath", dstPath); 35 | return _ret; 36 | } 37 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 38 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 39 | } 40 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 41 | 42 | dst.writeUTF(srcPath); 43 | dst.writeUTF(dstPath); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/RenameWorkspacePathRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class RenameWorkspacePathRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final boolean ok; 7 | public RenameWorkspacePathRes(boolean ok) { 8 | this.ok = ok; 9 | } 10 | public RenameWorkspacePathRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public RenameWorkspacePathRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.ok = src.readBoolean(); 15 | } 16 | 17 | public static RenameWorkspacePathRes fromJSON(JSONObject obj) { 18 | return new RenameWorkspacePathRes( 19 | obj.getBoolean("ok") 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("ok", ok); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | dst.writeBoolean(ok); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/StopJobReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class StopJobReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final int job; 8 | public StopJobReq(int job) { 9 | this.type = "Concurrent:StopJob"; 10 | this.job = job; 11 | } 12 | public StopJobReq(java.io.DataInputStream src) throws java.io.IOException { 13 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 14 | } 15 | public StopJobReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 16 | this.type = "Concurrent:StopJob"; 17 | this.job = src.readInt(); 18 | } 19 | 20 | public static StopJobReq fromJSON(JSONObject obj) { 21 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "Concurrent:StopJob"); 22 | return new StopJobReq( 23 | obj.getInt("job") 24 | ); 25 | } 26 | public JSONObject toJSON() { 27 | JSONObject _ret = new JSONObject(); 28 | _ret.put("type", type); 29 | _ret.put("job", job); 30 | return _ret; 31 | } 32 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 33 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 34 | } 35 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 36 | 37 | dst.writeInt(job); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/StopJobRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class StopJobRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String err; 7 | public StopJobRes() { 8 | this((String)null); 9 | } 10 | public StopJobRes(String err) { 11 | this.err = err; 12 | } 13 | public StopJobRes(java.io.DataInputStream src) throws java.io.IOException { 14 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 15 | } 16 | public StopJobRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 17 | this.err = src.readBoolean() ? src.readUTF() : null; 18 | } 19 | 20 | public static StopJobRes fromJSON(JSONObject obj) { 21 | return new StopJobRes( 22 | obj.has("err") ? (obj.getString("err")) : null 23 | ); 24 | } 25 | public JSONObject toJSON() { 26 | JSONObject _ret = new JSONObject(); 27 | if (err != null) _ret.put("err", err); 28 | return _ret; 29 | } 30 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 31 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 32 | } 33 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 34 | if (err != null) { dst.writeBoolean(true); dst.writeUTF(err);; } else { dst.writeBoolean(false); } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/SubmitWorkerTaskReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class SubmitWorkerTaskReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final long job; 8 | public final org.json.JSONObject data; 9 | public SubmitWorkerTaskReq(long job, org.json.JSONObject data) { 10 | this.type = "Concurrent:SubmitTask"; 11 | this.job = job; 12 | this.data = data; 13 | } 14 | public SubmitWorkerTaskReq(java.io.DataInputStream src) throws java.io.IOException { 15 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 16 | } 17 | public SubmitWorkerTaskReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 18 | this.type = "Concurrent:SubmitTask"; 19 | this.job = src.readLong(); 20 | this.data = new org.json.JSONObject(src.readUTF()); 21 | } 22 | 23 | public static SubmitWorkerTaskReq fromJSON(JSONObject obj) { 24 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "Concurrent:SubmitTask"); 25 | return new SubmitWorkerTaskReq( 26 | obj.getLong("job") 27 | , obj.getJSONObject("data") 28 | ); 29 | } 30 | public JSONObject toJSON() { 31 | JSONObject _ret = new JSONObject(); 32 | _ret.put("type", type); 33 | _ret.put("job", job); 34 | _ret.put("data", data); 35 | return _ret; 36 | } 37 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 38 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 39 | } 40 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 41 | 42 | dst.writeLong(job); 43 | dst.writeUTF(data.toString()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/SubmitWorkerTaskRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class SubmitWorkerTaskRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final boolean ok; 7 | public SubmitWorkerTaskRes(boolean ok) { 8 | this.ok = ok; 9 | } 10 | public SubmitWorkerTaskRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public SubmitWorkerTaskRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.ok = src.readBoolean(); 15 | } 16 | 17 | public static SubmitWorkerTaskRes fromJSON(JSONObject obj) { 18 | return new SubmitWorkerTaskRes( 19 | obj.getBoolean("ok") 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("ok", ok); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | dst.writeBoolean(ok); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/SubscribeToWorkerStatusReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class SubscribeToWorkerStatusReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final int job; 8 | public SubscribeToWorkerStatusReq(int job) { 9 | this.type = "Concurrent:SubscribeToWorkerStatus"; 10 | this.job = job; 11 | } 12 | public SubscribeToWorkerStatusReq(java.io.DataInputStream src) throws java.io.IOException { 13 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 14 | } 15 | public SubscribeToWorkerStatusReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 16 | this.type = "Concurrent:SubscribeToWorkerStatus"; 17 | this.job = src.readInt(); 18 | } 19 | 20 | public static SubscribeToWorkerStatusReq fromJSON(JSONObject obj) { 21 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "Concurrent:SubscribeToWorkerStatus"); 22 | return new SubscribeToWorkerStatusReq( 23 | obj.getInt("job") 24 | ); 25 | } 26 | public JSONObject toJSON() { 27 | JSONObject _ret = new JSONObject(); 28 | _ret.put("type", type); 29 | _ret.put("job", job); 30 | return _ret; 31 | } 32 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 33 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 34 | } 35 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 36 | 37 | dst.writeInt(job); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/SubscribeToWorkerStatusRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class SubscribeToWorkerStatusRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final int subscriberId; 7 | public SubscribeToWorkerStatusRes(int subscriberId) { 8 | this.subscriberId = subscriberId; 9 | } 10 | public SubscribeToWorkerStatusRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public SubscribeToWorkerStatusRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.subscriberId = src.readInt(); 15 | } 16 | 17 | public static SubscribeToWorkerStatusRes fromJSON(JSONObject obj) { 18 | return new SubscribeToWorkerStatusRes( 19 | obj.getInt("subscriberId") 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("subscriberId", subscriberId); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | dst.writeInt(subscriberId); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/TestSuite.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class TestSuite implements codeprober.util.JsonUtil.ToJsonable { 6 | public final int v; 7 | public final java.util.List cases; 8 | public TestSuite(int v, java.util.List cases) { 9 | this.v = v; 10 | this.cases = cases; 11 | } 12 | public TestSuite(java.io.DataInputStream src) throws java.io.IOException { 13 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 14 | } 15 | public TestSuite(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 16 | this.v = src.readInt(); 17 | this.cases = codeprober.util.JsonUtil.readDataArr(src, () -> new TestCase(src)); 18 | } 19 | 20 | public static TestSuite fromJSON(JSONObject obj) { 21 | return new TestSuite( 22 | obj.getInt("v") 23 | , codeprober.util.JsonUtil.mapArr(obj.getJSONArray("cases"), (arr, idx) -> TestCase.fromJSON(arr.getJSONObject(idx))) 24 | ); 25 | } 26 | public JSONObject toJSON() { 27 | JSONObject _ret = new JSONObject(); 28 | _ret.put("v", v); 29 | _ret.put("cases", new org.json.JSONArray(cases.stream().map(x->x.toJSON()).collect(java.util.stream.Collectors.toList()))); 30 | return _ret; 31 | } 32 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 33 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 34 | } 35 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 36 | dst.writeInt(v); 37 | codeprober.util.JsonUtil.writeDataArr(dst, cases, ent -> ent.writeTo(dst)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/TopRequestReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class TopRequestReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final long id; 8 | public final org.json.JSONObject data; 9 | public TopRequestReq(long id, org.json.JSONObject data) { 10 | this.type = "rpc"; 11 | this.id = id; 12 | this.data = data; 13 | } 14 | public TopRequestReq(java.io.DataInputStream src) throws java.io.IOException { 15 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 16 | } 17 | public TopRequestReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 18 | this.type = "rpc"; 19 | this.id = src.readLong(); 20 | this.data = new org.json.JSONObject(src.readUTF()); 21 | } 22 | 23 | public static TopRequestReq fromJSON(JSONObject obj) { 24 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "rpc"); 25 | return new TopRequestReq( 26 | obj.getLong("id") 27 | , obj.getJSONObject("data") 28 | ); 29 | } 30 | public JSONObject toJSON() { 31 | JSONObject _ret = new JSONObject(); 32 | _ret.put("type", type); 33 | _ret.put("id", id); 34 | _ret.put("data", data); 35 | return _ret; 36 | } 37 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 38 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 39 | } 40 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 41 | 42 | dst.writeLong(id); 43 | dst.writeUTF(data.toString()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/TopRequestRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class TopRequestRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final long id; 8 | public final TopRequestResponseData data; 9 | public TopRequestRes(long id, TopRequestResponseData data) { 10 | this.type = "rpc"; 11 | this.id = id; 12 | this.data = data; 13 | } 14 | public TopRequestRes(java.io.DataInputStream src) throws java.io.IOException { 15 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 16 | } 17 | public TopRequestRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 18 | this.type = "rpc"; 19 | this.id = src.readLong(); 20 | this.data = new TopRequestResponseData(src); 21 | } 22 | 23 | public static TopRequestRes fromJSON(JSONObject obj) { 24 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "rpc"); 25 | return new TopRequestRes( 26 | obj.getLong("id") 27 | , TopRequestResponseData.fromJSON(obj.getJSONObject("data")) 28 | ); 29 | } 30 | public JSONObject toJSON() { 31 | JSONObject _ret = new JSONObject(); 32 | _ret.put("type", type); 33 | _ret.put("id", id); 34 | _ret.put("data", data.toJSON()); 35 | return _ret; 36 | } 37 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 38 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 39 | } 40 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 41 | 42 | dst.writeLong(id); 43 | data.writeTo(dst); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/TunneledWsPutRequestReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class TunneledWsPutRequestReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final String session; 8 | public final org.json.JSONObject request; 9 | public TunneledWsPutRequestReq(String session, org.json.JSONObject request) { 10 | this.type = "wsput:tunnel"; 11 | this.session = session; 12 | this.request = request; 13 | } 14 | public TunneledWsPutRequestReq(java.io.DataInputStream src) throws java.io.IOException { 15 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 16 | } 17 | public TunneledWsPutRequestReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 18 | this.type = "wsput:tunnel"; 19 | this.session = src.readUTF(); 20 | this.request = new org.json.JSONObject(src.readUTF()); 21 | } 22 | 23 | public static TunneledWsPutRequestReq fromJSON(JSONObject obj) { 24 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "wsput:tunnel"); 25 | return new TunneledWsPutRequestReq( 26 | obj.getString("session") 27 | , obj.getJSONObject("request") 28 | ); 29 | } 30 | public JSONObject toJSON() { 31 | JSONObject _ret = new JSONObject(); 32 | _ret.put("type", type); 33 | _ret.put("session", session); 34 | _ret.put("request", request); 35 | return _ret; 36 | } 37 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 38 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 39 | } 40 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 41 | 42 | dst.writeUTF(session); 43 | dst.writeUTF(request.toString()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/TunneledWsPutRequestRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class TunneledWsPutRequestRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final org.json.JSONObject response; 7 | public TunneledWsPutRequestRes(org.json.JSONObject response) { 8 | this.response = response; 9 | } 10 | public TunneledWsPutRequestRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public TunneledWsPutRequestRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.response = new org.json.JSONObject(src.readUTF()); 15 | } 16 | 17 | public static TunneledWsPutRequestRes fromJSON(JSONObject obj) { 18 | return new TunneledWsPutRequestRes( 19 | obj.getJSONObject("response") 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("response", response); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | dst.writeUTF(response.toString()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/UnlinkWorkspacePathReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class UnlinkWorkspacePathReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final String path; 8 | public UnlinkWorkspacePathReq(String path) { 9 | this.type = "UnlinkWorkspacePath"; 10 | this.path = path; 11 | } 12 | public UnlinkWorkspacePathReq(java.io.DataInputStream src) throws java.io.IOException { 13 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 14 | } 15 | public UnlinkWorkspacePathReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 16 | this.type = "UnlinkWorkspacePath"; 17 | this.path = src.readUTF(); 18 | } 19 | 20 | public static UnlinkWorkspacePathReq fromJSON(JSONObject obj) { 21 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "UnlinkWorkspacePath"); 22 | return new UnlinkWorkspacePathReq( 23 | obj.getString("path") 24 | ); 25 | } 26 | public JSONObject toJSON() { 27 | JSONObject _ret = new JSONObject(); 28 | _ret.put("type", type); 29 | _ret.put("path", path); 30 | return _ret; 31 | } 32 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 33 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 34 | } 35 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 36 | 37 | dst.writeUTF(path); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/UnlinkWorkspacePathRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class UnlinkWorkspacePathRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final boolean ok; 7 | public UnlinkWorkspacePathRes(boolean ok) { 8 | this.ok = ok; 9 | } 10 | public UnlinkWorkspacePathRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public UnlinkWorkspacePathRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.ok = src.readBoolean(); 15 | } 16 | 17 | public static UnlinkWorkspacePathRes fromJSON(JSONObject obj) { 18 | return new UnlinkWorkspacePathRes( 19 | obj.getBoolean("ok") 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("ok", ok); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | dst.writeBoolean(ok); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/UnsubscribeFromWorkerStatusRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class UnsubscribeFromWorkerStatusRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final boolean ok; 7 | public UnsubscribeFromWorkerStatusRes(boolean ok) { 8 | this.ok = ok; 9 | } 10 | public UnsubscribeFromWorkerStatusRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public UnsubscribeFromWorkerStatusRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.ok = src.readBoolean(); 15 | } 16 | 17 | public static UnsubscribeFromWorkerStatusRes fromJSON(JSONObject obj) { 18 | return new UnsubscribeFromWorkerStatusRes( 19 | obj.getBoolean("ok") 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("ok", ok); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | dst.writeBoolean(ok); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/WorkspacePathsUpdated.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class WorkspacePathsUpdated implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final java.util.List paths; 8 | public WorkspacePathsUpdated(java.util.List paths) { 9 | this.type = "workspace_paths_updated"; 10 | this.paths = paths; 11 | } 12 | public WorkspacePathsUpdated(java.io.DataInputStream src) throws java.io.IOException { 13 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 14 | } 15 | public WorkspacePathsUpdated(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 16 | this.type = "workspace_paths_updated"; 17 | this.paths = codeprober.util.JsonUtil.readDataArr(src, () -> src.readUTF()); 18 | } 19 | 20 | public static WorkspacePathsUpdated fromJSON(JSONObject obj) { 21 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "workspace_paths_updated"); 22 | return new WorkspacePathsUpdated( 23 | codeprober.util.JsonUtil.mapArr(obj.getJSONArray("paths"), (arr, idx) -> arr.getString(idx)) 24 | ); 25 | } 26 | public JSONObject toJSON() { 27 | JSONObject _ret = new JSONObject(); 28 | _ret.put("type", type); 29 | _ret.put("paths", new org.json.JSONArray(paths)); 30 | return _ret; 31 | } 32 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 33 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 34 | } 35 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 36 | 37 | codeprober.util.JsonUtil.writeDataArr(dst, paths, ent -> dst.writeUTF(ent)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/WsPutInitReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class WsPutInitReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final String session; 8 | public WsPutInitReq(String session) { 9 | this.type = "wsput:init"; 10 | this.session = session; 11 | } 12 | public WsPutInitReq(java.io.DataInputStream src) throws java.io.IOException { 13 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 14 | } 15 | public WsPutInitReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 16 | this.type = "wsput:init"; 17 | this.session = src.readUTF(); 18 | } 19 | 20 | public static WsPutInitReq fromJSON(JSONObject obj) { 21 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "wsput:init"); 22 | return new WsPutInitReq( 23 | obj.getString("session") 24 | ); 25 | } 26 | public JSONObject toJSON() { 27 | JSONObject _ret = new JSONObject(); 28 | _ret.put("type", type); 29 | _ret.put("session", session); 30 | return _ret; 31 | } 32 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 33 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 34 | } 35 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 36 | 37 | dst.writeUTF(session); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/WsPutInitRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class WsPutInitRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final InitInfo info; 7 | public WsPutInitRes(InitInfo info) { 8 | this.info = info; 9 | } 10 | public WsPutInitRes(java.io.DataInputStream src) throws java.io.IOException { 11 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 12 | } 13 | public WsPutInitRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 14 | this.info = new InitInfo(src); 15 | } 16 | 17 | public static WsPutInitRes fromJSON(JSONObject obj) { 18 | return new WsPutInitRes( 19 | InitInfo.fromJSON(obj.getJSONObject("info")) 20 | ); 21 | } 22 | public JSONObject toJSON() { 23 | JSONObject _ret = new JSONObject(); 24 | _ret.put("info", info.toJSON()); 25 | return _ret; 26 | } 27 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 28 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 29 | } 30 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 31 | info.writeTo(dst); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/WsPutLongpollReq.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class WsPutLongpollReq implements codeprober.util.JsonUtil.ToJsonable { 6 | public final String type; 7 | public final String session; 8 | public final int etag; 9 | public WsPutLongpollReq(String session, int etag) { 10 | this.type = "wsput:longpoll"; 11 | this.session = session; 12 | this.etag = etag; 13 | } 14 | public WsPutLongpollReq(java.io.DataInputStream src) throws java.io.IOException { 15 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 16 | } 17 | public WsPutLongpollReq(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 18 | this.type = "wsput:longpoll"; 19 | this.session = src.readUTF(); 20 | this.etag = src.readInt(); 21 | } 22 | 23 | public static WsPutLongpollReq fromJSON(JSONObject obj) { 24 | codeprober.util.JsonUtil.requireString(obj.getString("type"), "wsput:longpoll"); 25 | return new WsPutLongpollReq( 26 | obj.getString("session") 27 | , obj.getInt("etag") 28 | ); 29 | } 30 | public JSONObject toJSON() { 31 | JSONObject _ret = new JSONObject(); 32 | _ret.put("type", type); 33 | _ret.put("session", session); 34 | _ret.put("etag", etag); 35 | return _ret; 36 | } 37 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 38 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 39 | } 40 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 41 | 42 | dst.writeUTF(session); 43 | dst.writeInt(etag); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/protocol/data/WsPutLongpollRes.java: -------------------------------------------------------------------------------- 1 | package codeprober.protocol.data; 2 | 3 | import org.json.JSONObject; 4 | 5 | public class WsPutLongpollRes implements codeprober.util.JsonUtil.ToJsonable { 6 | public final LongPollResponse data; 7 | public WsPutLongpollRes() { 8 | this((LongPollResponse)null); 9 | } 10 | public WsPutLongpollRes(LongPollResponse data) { 11 | this.data = data; 12 | } 13 | public WsPutLongpollRes(java.io.DataInputStream src) throws java.io.IOException { 14 | this(new codeprober.protocol.BinaryInputStream.DataInputStreamWrapper(src)); 15 | } 16 | public WsPutLongpollRes(codeprober.protocol.BinaryInputStream src) throws java.io.IOException { 17 | this.data = src.readBoolean() ? new LongPollResponse(src) : null; 18 | } 19 | 20 | public static WsPutLongpollRes fromJSON(JSONObject obj) { 21 | return new WsPutLongpollRes( 22 | obj.has("data") ? (LongPollResponse.fromJSON(obj.getJSONObject("data"))) : null 23 | ); 24 | } 25 | public JSONObject toJSON() { 26 | JSONObject _ret = new JSONObject(); 27 | if (data != null) _ret.put("data", data.toJSON()); 28 | return _ret; 29 | } 30 | public void writeTo(java.io.DataOutputStream dst) throws java.io.IOException { 31 | writeTo(new codeprober.protocol.BinaryOutputStream.DataOutputStreamWrapper(dst)); 32 | } 33 | public void writeTo(codeprober.protocol.BinaryOutputStream dst) throws java.io.IOException { 34 | if (data != null) { dst.writeBoolean(true); data.writeTo(dst);; } else { dst.writeBoolean(false); } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /server/src/codeprober/requesthandler/CompleteHandler.java: -------------------------------------------------------------------------------- 1 | package codeprober.requesthandler; 2 | 3 | import codeprober.protocol.data.CompleteReq; 4 | import codeprober.protocol.data.CompleteRes; 5 | import codeprober.requesthandler.LazyParser.ParsedAst; 6 | 7 | public class CompleteHandler { 8 | 9 | public static CompleteRes apply(CompleteReq req, LazyParser parser) { 10 | final ParsedAst parsed = parser.parse(req.src); 11 | return new CompleteRes(HoverHandler.extract0(parsed, "cpr_ide_complete", req.line, req.column)); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /server/src/codeprober/requesthandler/ListNodesHandler.java: -------------------------------------------------------------------------------- 1 | package codeprober.requesthandler; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import codeprober.locator.NodesAtPosition; 7 | import codeprober.protocol.data.Diagnostic; 8 | import codeprober.protocol.data.ListNodesReq; 9 | import codeprober.protocol.data.ListNodesRes; 10 | import codeprober.protocol.data.RpcBodyLine; 11 | import codeprober.requesthandler.LazyParser.ParsedAst; 12 | import codeprober.util.MagicStdoutMessageParser; 13 | 14 | public class ListNodesHandler { 15 | 16 | public static ListNodesRes apply(ListNodesReq req, LazyParser parser) { 17 | final ParsedAst parsed = parser.parse(req.src); 18 | if (parsed.info == null) { 19 | 20 | final List diagnostics = new ArrayList<>(); 21 | for (RpcBodyLine line : parsed.captures) { 22 | switch (line.type) { 23 | case stdout: { 24 | final Diagnostic diagnostic = MagicStdoutMessageParser.parse(line.asStdout()); 25 | if (diagnostic != null) { 26 | diagnostics.add(diagnostic); 27 | } 28 | break; 29 | } 30 | 31 | case stderr: 32 | final Diagnostic diagnostic = MagicStdoutMessageParser.parse(line.asStderr()); 33 | if (diagnostic != null) { 34 | diagnostics.add(diagnostic); 35 | } 36 | break; 37 | 38 | default: 39 | break; 40 | } 41 | } 42 | 43 | return new ListNodesRes(parsed.captures, null, diagnostics); 44 | } 45 | return new ListNodesRes(parsed.captures, NodesAtPosition.get(parsed.info, parsed.info.ast, req.pos)); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /server/src/codeprober/requesthandler/ListPropertiesHandler.java: -------------------------------------------------------------------------------- 1 | package codeprober.requesthandler; 2 | 3 | import codeprober.locator.ApplyLocator; 4 | import codeprober.locator.ApplyLocator.ResolvedNode; 5 | import codeprober.locator.AttrsInNode; 6 | import codeprober.protocol.data.ListPropertiesReq; 7 | import codeprober.protocol.data.ListPropertiesRes; 8 | import codeprober.requesthandler.LazyParser.ParsedAst; 9 | 10 | public class ListPropertiesHandler { 11 | 12 | public static ListPropertiesRes apply(ListPropertiesReq req, LazyParser parser) { 13 | final ParsedAst parsed = parser.parse(req.src); 14 | if (parsed.info == null) { 15 | return new ListPropertiesRes(parsed.captures, null); 16 | } 17 | final ResolvedNode match = ApplyLocator.toNode(parsed.info, req.locator); 18 | if (match == null) { 19 | return new ListPropertiesRes(parsed.captures, null); 20 | } 21 | 22 | return new ListPropertiesRes(parsed.captures, AttrsInNode.getTyped(parsed.info, match.node, 23 | AttrsInNode.extractFilter(parsed.info, match.node), req.all)); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /server/src/codeprober/requesthandler/ListTreeRequestHandler.java: -------------------------------------------------------------------------------- 1 | package codeprober.requesthandler; 2 | 3 | import codeprober.locator.ApplyLocator; 4 | import codeprober.locator.ApplyLocator.ResolvedNode; 5 | import codeprober.locator.CreateLocator; 6 | import codeprober.locator.CreateLocator.LocatorMergeMethod; 7 | import codeprober.locator.DataDrivenListTree; 8 | import codeprober.protocol.data.ListTreeReq; 9 | import codeprober.protocol.data.ListTreeRes; 10 | import codeprober.protocol.data.ListedTreeNode; 11 | import codeprober.requesthandler.LazyParser.ParsedAst; 12 | 13 | public class ListTreeRequestHandler { 14 | 15 | public static ListTreeRes apply(ListTreeReq req, LazyParser parser) { 16 | final ParsedAst parsed = parser.parse(req.src); 17 | if (parsed.info == null) { 18 | return new ListTreeRes(parsed.captures, null, null); 19 | } 20 | final ResolvedNode match = ApplyLocator.toNode(parsed.info, req.locator); 21 | if (match == null) { 22 | return new ListTreeRes(parsed.captures, null, null); 23 | } 24 | CreateLocator.setMergeMethod(LocatorMergeMethod.SKIP); 25 | try { 26 | final ListedTreeNode listing; 27 | switch (req.type) { 28 | case "ListTreeUpwards": { 29 | listing = DataDrivenListTree.listUpwards(parsed.info, match.node); 30 | break; 31 | } 32 | case "ListTreeDownwards": { 33 | listing = DataDrivenListTree.listDownwards(parsed.info, match.node, 32); 34 | break; 35 | } 36 | default: { 37 | throw new Error("Should never happen - matched request with incorrect type"); 38 | } 39 | } 40 | return new ListTreeRes(parsed.captures, match.nodeLocator, listing); 41 | } finally { 42 | CreateLocator.setMergeMethod(LocatorMergeMethod.DEFAULT_METHOD); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /server/src/codeprober/resources: -------------------------------------------------------------------------------- 1 | ../../../client/public -------------------------------------------------------------------------------- /server/src/codeprober/server/ServerToClientMessagePusher.java: -------------------------------------------------------------------------------- 1 | package codeprober.server; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | import java.util.function.Consumer; 7 | 8 | /** 9 | * Class helping with pushing messages from the server to the client. Over 10 | * websockets, this is a native feature.
11 | * Over http, this is implemented with long polling. 12 | */ 13 | public class ServerToClientMessagePusher { 14 | private final List> onChangeListeners; 15 | private int eventCounter; 16 | 17 | public ServerToClientMessagePusher() { 18 | this.onChangeListeners = Collections.>synchronizedList(new ArrayList<>()); 19 | this.eventCounter = 1; 20 | } 21 | 22 | public void onChange(ServerToClientEvent event) { 23 | this.eventCounter++; 24 | synchronized (onChangeListeners) { 25 | onChangeListeners.forEach(l -> l.accept(event)); 26 | } 27 | synchronized (this) { 28 | notifyAll(); 29 | } 30 | } 31 | 32 | public int getEventCounter() { 33 | return eventCounter; 34 | } 35 | 36 | public void addChangeListener(Consumer r) { 37 | onChangeListeners.add(r); 38 | } 39 | 40 | public void removeChangeListener(Consumer r) { 41 | onChangeListeners.remove(r); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /server/src/codeprober/textprobe/ParsedTextProbes.java: -------------------------------------------------------------------------------- 1 | package codeprober.textprobe; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.regex.Matcher; 6 | 7 | public class ParsedTextProbes { 8 | 9 | public final List assignments = new ArrayList<>(); 10 | public final List assertions = new ArrayList<>(); 11 | 12 | public static ParsedTextProbes fromFileContents(String src) { 13 | final ParsedTextProbes ret = new ParsedTextProbes(); 14 | 15 | final String[] lines = src.split("\n"); 16 | for (int lineIdx = 0; lineIdx < lines.length; ++lineIdx) { 17 | final String line = lines[lineIdx]; 18 | final Matcher containerMatcher = TextProbeParser.getProbeContainerMatcher().matcher(line); 19 | while (containerMatcher.find()) { 20 | final String containerContents = containerMatcher.group(TextProbeParser.CONTAINER_GROUP_CONTENT); 21 | 22 | final VarAssignMatch varMatch = TextProbeParser.matchVarAssign(containerContents, lineIdx); 23 | if (varMatch != null) { 24 | ret.assignments.add(varMatch); 25 | } else { 26 | final TextAssertionMatch tp = TextProbeParser.matchTextAssertion(containerContents, lineIdx); 27 | if (tp != null) { 28 | ret.assertions.add(tp); 29 | } 30 | } 31 | } 32 | } 33 | 34 | return ret; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /server/src/codeprober/textprobe/TextAssertionMatch.java: -------------------------------------------------------------------------------- 1 | package codeprober.textprobe; 2 | 3 | import java.util.Arrays; 4 | import java.util.stream.Collectors; 5 | 6 | public class TextAssertionMatch extends TextQueryMatch { 7 | public final boolean exclamation; 8 | public final boolean tilde; 9 | public final String expectVal; 10 | 11 | public TextAssertionMatch(String full, int lineIdx, String nodeType, Integer nodeIndex, String[] attrNames, 12 | boolean exclamation, boolean tilde, String expectVal) { 13 | super(full, lineIdx, nodeType, nodeIndex, attrNames); 14 | this.exclamation = exclamation; 15 | this.tilde = tilde; 16 | this.expectVal = expectVal; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return Arrays.asList( // 22 | super.toString(), exclamation ? "!" : "", // 23 | tilde ? "~" : "", "=" + expectVal // 24 | ).stream().collect(Collectors.joining("")); 25 | } 26 | } -------------------------------------------------------------------------------- /server/src/codeprober/textprobe/TextQueryMatch.java: -------------------------------------------------------------------------------- 1 | package codeprober.textprobe; 2 | 3 | import java.util.Arrays; 4 | import java.util.stream.Collectors; 5 | 6 | public class TextQueryMatch { 7 | public final String full; 8 | public final int lineIdx; 9 | public final String nodeType; 10 | public final Integer nodeIndex; 11 | public final String[] attrNames; 12 | 13 | public TextQueryMatch(String full, int lineIdx, String nodeType, Integer nodeIndex, String[] attrNames) { 14 | this.full = full; 15 | this.lineIdx = lineIdx; 16 | this.nodeType = nodeType; 17 | this.nodeIndex = nodeIndex; 18 | this.attrNames = attrNames; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return Arrays.asList( // 24 | nodeType, // 25 | nodeIndex != null ? "[" + nodeIndex + "]" : "", // 26 | attrNames.length > 0 ? ("." + Arrays.asList(attrNames).stream().collect(Collectors.joining("."))) : "") 27 | .stream().collect(Collectors.joining()); 28 | } 29 | } -------------------------------------------------------------------------------- /server/src/codeprober/textprobe/VarAssignMatch.java: -------------------------------------------------------------------------------- 1 | package codeprober.textprobe; 2 | 3 | public class VarAssignMatch { 4 | public final String full; 5 | public final int lineIdx; 6 | public final String varName; 7 | public final String srcVal; 8 | 9 | public VarAssignMatch(String full, int lineIdx, String varName, String srcVal) { 10 | this.full = full; 11 | this.lineIdx = lineIdx; 12 | this.varName = varName; 13 | this.srcVal = srcVal; 14 | } 15 | 16 | public TextQueryMatch matchSrcAsQuery() { 17 | return TextProbeParser.matchTextQuery(srcVal, lineIdx); 18 | } 19 | 20 | @Override 21 | public String toString() { 22 | return String.format("%s:=%s", varName, srcVal); 23 | } 24 | } -------------------------------------------------------------------------------- /server/src/codeprober/toolglue/ParseResult.java: -------------------------------------------------------------------------------- 1 | package codeprober.toolglue; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | 6 | import codeprober.protocol.data.RpcBodyLine; 7 | 8 | public class ParseResult { 9 | public final Object rootNode; 10 | public final List captures; 11 | 12 | public ParseResult(Object rootNode) { 13 | this(rootNode, null); 14 | } 15 | 16 | public ParseResult(Object rootNode, List captures) { 17 | this.rootNode = rootNode; 18 | this.captures = captures != null ? captures : Collections.emptyList(); 19 | } 20 | } -------------------------------------------------------------------------------- /server/src/codeprober/toolglue/UnderlyingJar.java: -------------------------------------------------------------------------------- 1 | package codeprober.toolglue; 2 | 3 | import codeprober.util.ASTProvider; 4 | 5 | public class UnderlyingJar implements UnderlyingTool { 6 | 7 | private final String jarPath; 8 | private long changeCounter = 0; 9 | 10 | public UnderlyingJar(String jarPath) { 11 | this.jarPath = jarPath; 12 | } 13 | 14 | @Override 15 | public long getVersionId() { 16 | if (!ASTProvider.hasUnchangedJar(jarPath)) { 17 | ++changeCounter; 18 | } 19 | return changeCounter; 20 | } 21 | 22 | @Override 23 | public ParseResult parse(String[] args) { 24 | return ASTProvider.parseAst(jarPath, args); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /server/src/codeprober/toolglue/UnderlyingTool.java: -------------------------------------------------------------------------------- 1 | package codeprober.toolglue; 2 | 3 | /** 4 | * A representation of the "underlying tool" that parses files and constructs an 5 | * AST that CodeProber later will traverse and invoke attributes on. 6 | *

7 | * Usually this is represented by a jar file. However, when running tests, this 8 | * will be some in-memory handler. 9 | */ 10 | public interface UnderlyingTool { 11 | 12 | /** 13 | * Get an opaque identifier for the "version" of the tool. This is important for 14 | * caching purposes. Parsed ASTs may be reused whenever a request is received 15 | * with identical sources as before, and when the underlying tool is unchanged. 16 | *

17 | * Default implementation assumes a short-lived tool that doesn't change during. 18 | * Therefore the version is by default hard-coded to 0. 19 | */ 20 | default long getVersionId() { 21 | return 0; 22 | } 23 | 24 | ParseResult parse(String[] args); 25 | 26 | public static UnderlyingTool fromJar(String jarPath) { 27 | UnderlyingTool ret = new UnderlyingJar(jarPath); 28 | if ("true".equals(System.getProperty("cpr.resetASTStateOnParse", "true"))) { 29 | ret = new AstStateResetter(ret); 30 | } 31 | return ret; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/src/codeprober/toolglue/UnderlyingToolProxy.java: -------------------------------------------------------------------------------- 1 | package codeprober.toolglue; 2 | 3 | import java.util.Arrays; 4 | 5 | import codeprober.protocol.data.RpcBodyLine; 6 | 7 | public class UnderlyingToolProxy implements UnderlyingTool { 8 | private UnderlyingTool target; 9 | 10 | public void setProxyTarget(UnderlyingTool target) { 11 | this.target = target; 12 | } 13 | 14 | @Override 15 | public long getVersionId() { 16 | final UnderlyingTool ut = target; 17 | return ut != null ? ut.getVersionId() : 0L; 18 | } 19 | 20 | @Override 21 | public ParseResult parse(String[] args) { 22 | final UnderlyingTool ut = target; 23 | return ut != null ? ut.parse(args) 24 | : new ParseResult(null, 25 | Arrays.asList(RpcBodyLine.fromStderr("Tool not specified yet, please upload yourtool.jar"))); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /server/src/codeprober/util/MagicStdoutMessageParser.java: -------------------------------------------------------------------------------- 1 | package codeprober.util; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | import codeprober.protocol.DiagnosticType; 7 | import codeprober.protocol.data.Diagnostic; 8 | 9 | public class MagicStdoutMessageParser { 10 | 11 | public static Diagnostic parse(String line) { 12 | final Matcher matcher = Pattern.compile("(ERR|WARN|INFO|HINT|LINE-PP|LINE-AA|LINE-AP|LINE-PA)@(\\d+);(\\d+);(.*)", Pattern.DOTALL) 13 | .matcher(line); 14 | if (!matcher.matches()) { 15 | return null; 16 | } 17 | final int start = Integer.parseInt(matcher.group(2)); 18 | final int end = Integer.parseInt(matcher.group(3)); 19 | final String msg = matcher.group(4); 20 | final DiagnosticType type; 21 | switch (matcher.group(1)) { 22 | case "ERR": 23 | type = DiagnosticType.ERROR; 24 | break; 25 | case "WARN": 26 | type = DiagnosticType.WARNING; 27 | break; 28 | case "INFO": 29 | type = DiagnosticType.INFO; 30 | break; 31 | case "HINT": 32 | type = DiagnosticType.HINT; 33 | break; 34 | case "LINE-PP": 35 | type = DiagnosticType.LINE_PP; 36 | break; 37 | case "LINE-AA": 38 | type = DiagnosticType.LINE_AA; 39 | break; 40 | case "LINE-AP": 41 | type = DiagnosticType.LINE_AP; 42 | break; 43 | case "LINE-PA": 44 | type = DiagnosticType.LINE_PA; 45 | break; 46 | default: 47 | type = DiagnosticType.ERROR; 48 | break; 49 | } 50 | return new Diagnostic(type, start, end, msg); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /server/src/codeprober/util/SystemExitControl.java: -------------------------------------------------------------------------------- 1 | package codeprober.util; 2 | 3 | import java.security.Permission; 4 | 5 | public class SystemExitControl { 6 | 7 | @SuppressWarnings("serial") 8 | public static class ExitTrappedException extends SecurityException { 9 | } 10 | 11 | @SuppressWarnings("removal") 12 | public static void disableSystemExit() { 13 | final SecurityManager securityManager = new SecurityManager() { 14 | @Override public void checkPermission(Permission permission) { 15 | if (permission.getName().contains("exitVM")) { 16 | throw new ExitTrappedException(); 17 | } 18 | } 19 | }; 20 | System.setSecurityManager(securityManager); 21 | } 22 | 23 | @SuppressWarnings("removal") 24 | public static void enableSystemExit() { 25 | System.setSecurityManager(null); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /server/src/codeprober/util/VersionInfo.java: -------------------------------------------------------------------------------- 1 | package codeprober.util; 2 | 3 | import java.io.InputStream; 4 | import java.util.Properties; 5 | 6 | public class VersionInfo { 7 | 8 | public final String revision; 9 | public final boolean clean; 10 | public final Integer buildTimeSeconds; 11 | 12 | public VersionInfo(String revision, boolean clean, Integer buildTimeSeconds) { 13 | this.revision = revision; 14 | this.clean = clean; 15 | this.buildTimeSeconds = buildTimeSeconds; 16 | } 17 | 18 | public VersionInfo() { 19 | this("UNKNOWN", false, null); 20 | } 21 | 22 | public String toString() { 23 | return revision + (clean ? "" : " [DEV]"); 24 | } 25 | 26 | private static VersionInfo sInstance; 27 | 28 | public static VersionInfo getInstance() { 29 | if (sInstance == null) { 30 | 31 | try (InputStream in = VersionInfo.class.getResourceAsStream("/cpr.properties")) { 32 | if (in == null) { 33 | System.out.println("No version info available"); 34 | sInstance = new VersionInfo(); 35 | } else { 36 | final Properties props = new Properties(); 37 | props.load(in); 38 | 39 | String buildTimeStr = props.getProperty("Build-Time", null); 40 | 41 | sInstance = new VersionInfo( // 42 | props.getProperty("Git-Version", "UNKNOWN"), // 43 | props.getProperty("Git-Status", "DIRTY").equals("CLEAN"), // 44 | buildTimeStr == null ? null : Integer.parseInt(buildTimeStr) // 45 | ); 46 | } 47 | } catch (Exception e) { 48 | System.err.println("Error when loading properties"); 49 | e.printStackTrace(); 50 | sInstance = new VersionInfo(); 51 | } 52 | } 53 | return sInstance; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /server/src/codeprober/util/WorkspaceDirectoryMonitor.java: -------------------------------------------------------------------------------- 1 | package codeprober.util; 2 | 3 | import java.io.File; 4 | import java.nio.file.Path; 5 | import java.util.ArrayList; 6 | import java.util.HashSet; 7 | import java.util.Set; 8 | 9 | import codeprober.requesthandler.WorkspaceHandler; 10 | import codeprober.server.ServerToClientEvent; 11 | import codeprober.server.ServerToClientMessagePusher; 12 | 13 | public class WorkspaceDirectoryMonitor extends DirectoryMonitor { 14 | 15 | private File workspaceRoot; 16 | final Set changedWorkspacePaths = new HashSet<>(); 17 | private ServerToClientMessagePusher msgPusher; 18 | 19 | public WorkspaceDirectoryMonitor(File workspaceRoot, ServerToClientMessagePusher msgPusher) { 20 | super(workspaceRoot); 21 | this.workspaceRoot = workspaceRoot; 22 | this.msgPusher = msgPusher; 23 | } 24 | 25 | @Override 26 | protected void onChangeDetected(Path filePath) { 27 | final Path rootPath = workspaceRoot.toPath(); 28 | if (filePath.startsWith(rootPath)) { 29 | final File parent= filePath.toFile().getParentFile(); 30 | if (parent != null && parent.getName().equals(WorkspaceHandler.METADATA_DIR_NAME)) { 31 | // Metadata file update, ignore it 32 | return; 33 | } 34 | final String relpath = rootPath.relativize(filePath).toString(); 35 | synchronized (changedWorkspacePaths) { 36 | changedWorkspacePaths.add(relpath.replace(File.separatorChar, '/')); 37 | } 38 | } 39 | } 40 | 41 | @Override 42 | public void onChange() { 43 | synchronized (changedWorkspacePaths) { 44 | if (!changedWorkspacePaths.isEmpty()) { 45 | msgPusher.onChange(ServerToClientEvent.workspacePathChanged(new ArrayList<>(changedWorkspacePaths))); 46 | changedWorkspacePaths.clear(); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /server/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | LIBS=libs/json.jar:libs/junit-4.13.2.jar:libs/hamcrest-2.2.jar 5 | 6 | ## BUILD 7 | rm -rf test_tmp/ 8 | mkdir test_tmp 9 | 10 | echo "Gathering sources.." 11 | find src-test src -name "*.java" > sources.txt 12 | 13 | echo "Building.." 14 | javac @sources.txt -cp $LIBS -d test_tmp -source 8 -target 8 15 | 16 | ## TEST 17 | TEST_CLASSES="" 18 | addTest () { 19 | CLS=$(echo $1 \ 20 | | sed 's/^src-test\///' \ 21 | | sed 's/\//\./g' \ 22 | | sed 's/\.java$//' \ 23 | ) 24 | 25 | case $CLS in 26 | codeprober\.ast\.TestData|\ 27 | codeprober\.ast\.ASTNodeAnnotation|\ 28 | codeprober\.*RunDemoTests) 29 | # Exclude from tests 30 | ;; 31 | 32 | *) 33 | TEST_CLASSES="$TEST_CLASSES $CLS" 34 | esac 35 | } 36 | for i in $(find src-test -name "*.java"); do [ -f "$i" ] && addTest "$i"; done 37 | 38 | echo "Test classes: $TEST_CLASSES" 39 | java -cp $LIBS:test_tmp org.junit.runner.JUnitCore $TEST_CLASSES 40 | echo "All Tests pass successfully" 41 | -------------------------------------------------------------------------------- /website/.gitignore: -------------------------------------------------------------------------------- 1 | setup.sh 2 | public/dynsed 3 | -------------------------------------------------------------------------------- /website/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | Sources for https://codeprober.org 4 | 5 | The website files are hosted on AWS S3, and served via a CloudFront distribution. 6 | Updated files are published by running the script `publish.sh`. This requires some configuration, see `setup.sh.example`. 7 | -------------------------------------------------------------------------------- /website/public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lu-cs-sde/codeprober/88a1a2ef91992ddd6b37efd8c5126f5c72b0e0db/website/public/favicon.png -------------------------------------------------------------------------------- /website/public/style.css: -------------------------------------------------------------------------------- 1 | 2 | html { 3 | background: #AAA; 4 | } 5 | body { 6 | background: white; 7 | max-width: 64rem; 8 | min-height: 100vh; 9 | margin: 0 auto 0 auto; 10 | border-left: 1px solid darkgray; 11 | border-right: 1px solid darkgray; 12 | } 13 | 14 | #body-spacer { 15 | padding: 1rem; 16 | } 17 | -------------------------------------------------------------------------------- /website/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [ ! -f "setup.sh" ]; then 6 | echo "Missing 'setup.sh'. Copy 'setup.sh.example' to 'setup.sh' and fill in with your own configuration" 7 | exit 1 8 | fi 9 | 10 | echo "Loading aws commands and variables" 11 | source setup.sh 12 | 13 | if [ "$S3_BUCKET_NAME" = "" ]; then 14 | echo "Missing 'S3_BUCKET_NAME' in setup.sh" 15 | exit 1 16 | fi 17 | if [ "$SRC_WEBSITE_DIR" = "" ]; then 18 | echo "Missing 'SRC_WEBSITE_DIR' in setup.sh" 19 | exit 1 20 | fi 21 | if [ "$CLOUDFRONT_DISTRIBUTION" = "" ]; then 22 | echo "Missing 'CLOUDFRONT_DISTRIBUTION' in setup.sh" 23 | exit 1 24 | fi 25 | 26 | # This script uses the inverse of the traditional "dry-run" approach. Everything is dry-run by default, you must opt-in to a real ("wet") run. 27 | WETNESS="--dryrun" 28 | if [ "$WET_RUN" = "yes" ]; then 29 | WETNESS="" 30 | echo "Publishing!" 31 | else 32 | echo "Doing dry-run. Set WET_RUN=yes to really publish" 33 | fi 34 | 35 | 36 | aws s3 sync $WETNESS --delete $SRC_WEBSITE_DIR s3://$S3_BUCKET_NAME 37 | echo "S3 sync done" 38 | 39 | if [ "$WET_RUN" = "yes" ]; then 40 | echo "Performing CloudFront invalidation" 41 | aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION --paths "/*" 42 | fi 43 | -------------------------------------------------------------------------------- /website/setup.sh.example: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This file is an example/boilerplate of what is required to run `publish.sh`. 4 | # Copy this file to `setup.sh`, and then edit the values/commands below to work on your machine. 5 | # If everything is done correctly, then you should be able to run the following commands: 6 | # $ source setup.sh 7 | # $ aws s3 ls $S3_BUCKET_NAME 8 | # ..Which should list the files on the website (index.html, style.css, ...). 9 | 10 | aws() { 11 | docker run -v "/home/username/.aws_creds:/root/.aws" -v "$(pwd)/public:/website" --rm -it amazon/aws-cli "$@" 12 | } 13 | # The ".aws_creds" directory should contain two files: "config" and "credentials". 14 | # See e.g https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-files.html for reference on what they are 15 | 16 | export S3_BUCKET_NAME="bucket-name-here" 17 | export SRC_WEBSITE_DIR="/website" # Or 'public' if not using docker 18 | export CLOUDFRONT_DISTRIBUTION="DISTRIBUTION-ID-HERE" 19 | 20 | --------------------------------------------------------------------------------