diff --git a/packages/Babylonian-Compiler.package/BPCompiler.class/instance/compile.ifFail..st b/packages/Babylonian-Compiler.package/BPCompiler.class/instance/compile.ifFail..st index 8ca3c86e..37a986fc 100644 --- a/packages/Babylonian-Compiler.package/BPCompiler.class/instance/compile.ifFail..st +++ b/packages/Babylonian-Compiler.package/BPCompiler.class/instance/compile.ifFail..st @@ -1,20 +1,33 @@ public access -compile: aCueWithBPSource ifFail: failBlock +compile: aCueWithStyledSource ifFail: failBlock - "This method expects source code which has annotations embedded in comments, if any." - | originalMethodNode bpSource basicCue | - bpSource := aCueWithBPSource sourceStream contents asString. - basicCue := CompilationCue - source: bpSource readStream - context: aCueWithBPSource context - receiver: aCueWithBPSource receiver - class: aCueWithBPSource getClass - environment: aCueWithBPSource environment - requestor: aCueWithBPSource requestor. - originalMethodNode := super compile: basicCue ifFail: failBlock. + "This method expects source code which has annotations embedded in comments, + if any, meaning it's styled with text attributes. Since the BPBrowser breaks the premise + of the Parser that the source stream and the code panel's morph code is the same, auto + refactoring will quickly cause inconsistencies. For example, if one were to add a temporal + variable to existing ones, with the second vertical line being at position 18, the styled + version could have it at position 19. The parser would then re-add two lines, + causing for synctactic errors when compiling. Therefore, we remove the text styling + inside the morph to re-fullfill that premise again during compilation." + | originalMethodNode bpUnstyledSource unstyledCue | + bpUnstyledSource := aCueWithStyledSource sourceStream contents asString asBPSource. + aCueWithStyledSource requestor ifNotNil: [ + aCueWithStyledSource requestor useDefaultStyler. + aCueWithStyledSource requestor setText: bpUnstyledSource. + aCueWithStyledSource requestor styler: (BPStyler new view: aCueWithStyledSource requestor). + ]. - bpSource := originalMethodNode sourceText asString. - (self methodSourceRequiresBPLayers: bpSource) ifTrue: [ - (self compileInstrumentedVersionOf: aCueWithBPSource) ifFalse: failBlock]. - - ^ originalMethodNode \ No newline at end of file + unstyledCue := CompilationCue + source: bpUnstyledSource readStream + context: aCueWithStyledSource context + receiver: aCueWithStyledSource receiver + class: aCueWithStyledSource getClass + environment: aCueWithStyledSource environment + requestor: aCueWithStyledSource requestor. + originalMethodNode := super compile: unstyledCue ifFail: failBlock. + + bpUnstyledSource := originalMethodNode sourceText asString. + (self methodSourceRequiresBPLayers: bpUnstyledSource) ifTrue: [ + (self compileInstrumentedVersionOf: aCueWithStyledSource) ifFalse: failBlock]. + + ^ originalMethodNode \ No newline at end of file diff --git a/packages/Babylonian-Compiler.package/BPCompiler.class/methodProperties.json b/packages/Babylonian-Compiler.package/BPCompiler.class/methodProperties.json index b1c80971..0606920d 100644 --- a/packages/Babylonian-Compiler.package/BPCompiler.class/methodProperties.json +++ b/packages/Babylonian-Compiler.package/BPCompiler.class/methodProperties.json @@ -6,8 +6,8 @@ "instance" : { "annotationKeywords" : "pre 11/8/2019 20:29", "backgroundCompileInstrumentedVersionOf:basedOn:" : "pre 10/12/2020 15:36", - "compile:ifFail:" : "pre 5/3/2021 10:59", - "compileInstrumentedVersionOf:" : "pre 1/11/2021 15:51", + "compile:ifFail:" : "jb 10/17/2021 19:02", + "compileInstrumentedVersionOf:" : "jb 9/9/2021 17:31", "keywords" : "pre 7/26/2019 14:00", "methodSourceRequiresBPLayers:" : "pre 11/11/2019 15:49", "parse:" : "pre 1/11/2021 15:51", diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/README.md b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/class/compilerClass.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/class/compilerClass.st new file mode 100644 index 00000000..143008a9 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/class/compilerClass.st @@ -0,0 +1,4 @@ +compiling +compilerClass + + ^ BPCompiler \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertCanceled.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertCanceled.st new file mode 100644 index 00000000..c530d875 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertCanceled.st @@ -0,0 +1,6 @@ +assertions +assertCanceled + + self + assertText: originalText; + assertSelection: previousSelection. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertSelection..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertSelection..st new file mode 100644 index 00000000..5b2115b8 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertSelection..st @@ -0,0 +1,10 @@ +assertions +assertSelection: selectionMatch + + selectionMatch isBlock ifTrue: [ + ^ self assertSelection: selectionMatch value]. + ^ self + assert: selectionMatch + equals: (selectionMatch isInterval + ifTrue: [self selectionInterval] + ifFalse: [self selection]) \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertSucceeded..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertSucceeded..st new file mode 100644 index 00000000..0ae02888 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertSucceeded..st @@ -0,0 +1,6 @@ +assertions +assertSucceeded: textMatch + + self + assertText: textMatch; + assertSelection: originalSelection. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertSucceeded.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertSucceeded.st new file mode 100644 index 00000000..5658d573 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertSucceeded.st @@ -0,0 +1,4 @@ +assertions +assertSucceeded + + ^ self assertSucceeded: originalText \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertText..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertText..st new file mode 100644 index 00000000..65e05aaa --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/assertText..st @@ -0,0 +1,10 @@ +assertions +assertText: textMatch + + text isBlock ifTrue: [ + ^ self assertText: text value]. + ^ (textMatch respondsTo: #matches:) + ifTrue: [ + self assert: [textMatch matches: (self codePaneTextMorph textMorph contents) asString]] + ifFalse: [ + self assert: textMatch equals: (self codePaneTextMorph textMorph contents) asString] \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/codePaneTextMorph.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/codePaneTextMorph.st new file mode 100644 index 00000000..c8563d26 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/codePaneTextMorph.st @@ -0,0 +1,4 @@ +private +codePaneTextMorph + + ^ browser containingWindow submorphNamed: 'codePaneTextMorph'. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/compile..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/compile..st new file mode 100644 index 00000000..7158c579 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/compile..st @@ -0,0 +1,14 @@ +private +compile: sourceString + + | result | + originalText := text := sourceString. + previousSelection := originalSelection := 1 to: text size + 1. + selectionInterval := nil. + result := self class + compile: text + classified: 'generated' + notifying: self codePaneTextMorph. + result ifNil: [^ self]. + self codePaneTextMorph accept. + selectionInterval := originalSelection. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/compileMethodHeaderAndSetBrowserToIt.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/compileMethodHeaderAndSetBrowserToIt.st new file mode 100644 index 00000000..a48a0142 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/compileMethodHeaderAndSetBrowserToIt.st @@ -0,0 +1,6 @@ +private +compileMethodHeaderAndSetBrowserToIt + + text := 'someMethod\\ ' withCRs asText. + self compile: text. + browser setSelector: #someMethod. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/compiling.shouldRaise.andSelect.testing..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/compiling.shouldRaise.andSelect.testing..st new file mode 100644 index 00000000..78a5fd13 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/compiling.shouldRaise.andSelect.testing..st @@ -0,0 +1,20 @@ +private +compiling: sourceCode shouldRaise: exceptionClass andSelect: selectionMatch testing: tests + + "Test behavior of the compiler for the given sourceCode and expected an exception of kind exceptionClass. Other arguments: + * selectionMatch is used to check the selection of the source text that is active when an exception has occured. Can be a text, an interval, or a predicate block. See #assertSelection:. + * tests is an array of associations representing pairs of reactions (key) to the exception and the assertion (value) that should be run afterward. + * The key can be a boolean for answering yes/no dialogs, a string for selecting a named option from a dialog window, or a one-arg block to handle the occuring exception in a different way (see #handlerBlockFor:). + * The value can be either a string that will be compared to the final compiler source code or a custom assertion block that will be evaluated after the compilation has terminated (see #testBlockFor:)." + + | referenceTest | + referenceTest := [] -> []. + (tests copyWithFirst: referenceTest) associationsDo: [:test | + self + should: [self compile: sourceCode.] + raise: exceptionClass + thenDo: [:exception | + previousSelection := self selectionInterval. + (self handlerBlockFor: test key) cull: exception]. + self codePaneTextMorph accept. + (self testBlockFor: test value) value]. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/correctFrom.to.with..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/correctFrom.to.with..st new file mode 100644 index 00000000..34aae0f6 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/correctFrom.to.with..st @@ -0,0 +1,10 @@ +emulating +correctFrom: start to: stop with: aString + + | delta userSelection | + userSelection := self selectionInterval. + text := (text first: start - 1) , aString , (text allButFirst: stop). + delta := aString size - (stop - start + 1). + self + selectInvisiblyFrom: userSelection first + (userSelection first > start ifFalse: [ 0 ] ifTrue: [ delta ]) + to: userSelection last + (userSelection last > start ifFalse: [ 0 ] ifTrue: [ delta ]). \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/generateUnknownSelector.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/generateUnknownSelector.st new file mode 100644 index 00000000..3560bfa8 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/generateUnknownSelector.st @@ -0,0 +1,8 @@ +private +generateUnknownSelector + + | selector num | + selector := 'yourself'. + num := 0. + [(Symbol lookup: selector, num) notNil] whileTrue: [num := num + 1]. + ^ selector, num \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/handlerBlockFor..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/handlerBlockFor..st new file mode 100644 index 00000000..52a080f3 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/handlerBlockFor..st @@ -0,0 +1,6 @@ +private +handlerBlockFor: message + + ^ message isBlock + ifTrue: [message] + ifFalse: [[:ex | [ex pass] valueSupplyingAnswer: message]] \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/nextTokenFrom.direction..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/nextTokenFrom.direction..st new file mode 100644 index 00000000..5c5433b0 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/nextTokenFrom.direction..st @@ -0,0 +1,10 @@ +emulating +nextTokenFrom: start direction: dir + + "simple token-finder for compiler automated corrections" + | loc str | + loc := start + dir. + str := self text. + [(loc between: 1 and: str size) and: [(str at: loc) isSeparator]] + whileTrue: [loc := loc + dir]. + ^ loc \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/removeGeneratedMethods.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/removeGeneratedMethods.st new file mode 100644 index 00000000..0bf2e279 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/removeGeneratedMethods.st @@ -0,0 +1,4 @@ +private +removeGeneratedMethods + + self class removeCategory: 'generated' \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/runCase.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/runCase.st new file mode 100644 index 00000000..2adf71f8 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/runCase.st @@ -0,0 +1,7 @@ +running +runCase + + ^ Preferences + setPreference: #confirmFirstUseOfStyle + toValue: false + during: [super runCase] \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectFrom.to..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectFrom.to..st new file mode 100644 index 00000000..d14734c5 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectFrom.to..st @@ -0,0 +1,4 @@ +emulating +selectFrom: start to: end + + selectionInterval := start to: end. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectIntervalInvisibly..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectIntervalInvisibly..st new file mode 100644 index 00000000..27983632 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectIntervalInvisibly..st @@ -0,0 +1,4 @@ +emulating +selectIntervalInvisibly: anInterval + + selectionInterval := anInterval \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectInvisiblyFrom.to..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectInvisiblyFrom.to..st new file mode 100644 index 00000000..5af57a3e --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectInvisiblyFrom.to..st @@ -0,0 +1,5 @@ +emulating +selectInvisiblyFrom: start to: end + + ^ self + selectFrom: start to: end \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selection.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selection.st new file mode 100644 index 00000000..63f6c2df --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selection.st @@ -0,0 +1,4 @@ +private +selection + + ^ text copyFrom: self selectionInterval start to: self selectionInterval stop \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectionInterval.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectionInterval.st new file mode 100644 index 00000000..cca362a6 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/selectionInterval.st @@ -0,0 +1,4 @@ +emulating +selectionInterval + + ^ selectionInterval ifNil: [1 to: self text size] \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/setUp.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/setUp.st new file mode 100644 index 00000000..6f4aeb2b --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/setUp.st @@ -0,0 +1,5 @@ +running +setUp + + browser := BPBrowser fullOnClass: self class. + self compileMethodHeaderAndSetBrowserToIt. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/should.raise.thenDo..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/should.raise.thenDo..st new file mode 100644 index 00000000..9aa9991a --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/should.raise.thenDo..st @@ -0,0 +1,12 @@ +assertions +should: aBlock raise: anExceptionalEvent thenDo: aHandlerBlock + + | raised result | + raised := false. + result := aBlock + on: anExceptionalEvent + do: [:ex | + raised := true. + aHandlerBlock cull: ex]. + self assert: raised description: ('aBlock should have raised {1}' translated format: {anExceptionalEvent}). + ^ result \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/tearDown.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/tearDown.st new file mode 100644 index 00000000..661f11e3 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/tearDown.st @@ -0,0 +1,6 @@ +running +tearDown + + self codePaneTextMorph accept. + super tearDown. + browser containingWindow abandon. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testAmbiguousSelector.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testAmbiguousSelector.st new file mode 100644 index 00000000..6fc043d2 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testAmbiguousSelector.st @@ -0,0 +1,14 @@ +tests +testAmbiguousSelector + + | expectedString | + self codePaneTextMorph textMorph contents append: '\^1@-1' withCRs. + text append: '\^1@-1' withCRs. + expectedString := ('someMethod\', Character startOfHeader, '\ \^1@ -1') withCRs. + self + compiling: text + shouldRaise: AmbiguousSelector + andSelect: '@-' + testing: { + [:ex | ex resume] -> [self assertCanceled]. + [:ex | ex resume: '@ -'] -> expectedString }. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testBlockFor..st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testBlockFor..st new file mode 100644 index 00000000..6fc5e9fa --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testBlockFor..st @@ -0,0 +1,6 @@ +private +testBlockFor: test + + ^ test isBlock + ifTrue: [test] + ifFalse: [[self assertSucceeded: test]] \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesBlockLocalTemp.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesBlockLocalTemp.st new file mode 100644 index 00000000..c8423b89 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesBlockLocalTemp.st @@ -0,0 +1,14 @@ +tests +testPastesBlockLocalTemp + + | expectedString | + self codePaneTextMorph textMorph contents append: ('\^ [ ', self undeclaredVar ,' ] value') withCRs. + text append: ('\^ [ ', self undeclaredVar ,' ] value') withCRs. + expectedString := ('someMethod\', Character startOfHeader, '\ \^ [ | foo | ', self undeclaredVar, ' ] value') withCRs. + self + compiling: text + shouldRaise: UndeclaredVariable + andSelect: 'foo' + testing: { + false -> [self assertCanceled]. + 'declare block-local temp' -> expectedString}. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesFirstTempAtMethodLevel.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesFirstTempAtMethodLevel.st new file mode 100644 index 00000000..eada8e5f --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesFirstTempAtMethodLevel.st @@ -0,0 +1,14 @@ +tests +testPastesFirstTempAtMethodLevel + + | expectedString | + self codePaneTextMorph textMorph contents append: self undeclaredVar. + text append: self undeclaredVar. + expectedString := ('someMethod\', Character startOfHeader, '\ \| foo |', self undeclaredVar) withCRs. + self + compiling: text + shouldRaise: UndeclaredVariable + andSelect: 'foo' + testing: { + false -> [self assertCanceled]. + 'declare method temp' -> expectedString}. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesSecondTempAtMethodLevel.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesSecondTempAtMethodLevel.st new file mode 100644 index 00000000..24aa0844 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesSecondTempAtMethodLevel.st @@ -0,0 +1,14 @@ +tests +testPastesSecondTempAtMethodLevel + + | expectedString | + self codePaneTextMorph textMorph contents append: ('| a | \ a := 3.', self undeclaredVar) withCRs. + text append: ('| a | \ a := 3.', self undeclaredVar) withCRs. + expectedString := ('someMethod\', Character startOfHeader, '\ | a foo | \ a := 3.', self undeclaredVar) withCRs. + self + compiling: text + shouldRaise: UndeclaredVariable + andSelect: 'foo' + testing: { + false -> [self assertCanceled]. + 'declare method temp' -> expectedString}. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesTempForBlockValue.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesTempForBlockValue.st new file mode 100644 index 00000000..af874b5c --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testPastesTempForBlockValue.st @@ -0,0 +1,14 @@ +tests +testPastesTempForBlockValue + + | expectedString | + self codePaneTextMorph textMorph contents append: ('\^ [ ', self undeclaredVar ,' ] value') withCRs. + text append: ('\^ [ ', self undeclaredVar ,' ] value') withCRs. + expectedString := ('someMethod\', Character startOfHeader, '\ \| foo |\^ [ ', self undeclaredVar, ' ] value') withCRs. + self + compiling: text + shouldRaise: UndeclaredVariable + andSelect: 'foo' + testing: { + false -> [self assertCanceled]. + 'declare method temp' -> expectedString}. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUndefinedVariable.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUndefinedVariable.st new file mode 100644 index 00000000..28620b72 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUndefinedVariable.st @@ -0,0 +1,13 @@ +tests +testUndefinedVariable + + + self codePaneTextMorph textMorph contents append: '| foo | ^ foo'. + text append: '| foo | ^ foo'. + self + compiling: text + shouldRaise: UndefinedVariable + andSelect: [(self text allRangesOfRegexMatches: '(?<=\^ )foo') first] + testing: { + true -> [self assertSucceeded]. + false -> [self assertCanceled] }. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUndefinedVariableBlockValue.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUndefinedVariableBlockValue.st new file mode 100644 index 00000000..0bbb34bc --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUndefinedVariableBlockValue.st @@ -0,0 +1,12 @@ +tests +testUndefinedVariableBlockValue + + self codePaneTextMorph textMorph contents append: '[ | foo | ^ foo ] value'. + text append: '[ | foo | ^ foo ] value'. + self + compiling: text + shouldRaise: UndefinedVariable + andSelect: [(self text allRangesOfRegexMatches: '(?<=\^ )foo') first] + testing: { + true -> [self assertSucceeded]. + false -> [self assertCanceled] }. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUnusedVariable.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUnusedVariable.st new file mode 100644 index 00000000..fe373090 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUnusedVariable.st @@ -0,0 +1,13 @@ +tests +testUnusedVariable + + self codePaneTextMorph textMorph contents append: '| foo | ^nil'. + text append: '| foo | ^nil'. + self + compiling: text + shouldRaise: UnusedVariable + andSelect: [text] + testing: { + [:ex | ex resume] -> [self assertCanceled]. + false -> [self assertSucceeded]. + true -> [self assertSucceeded: ('someMethod\' withCRs, Character startOfHeader, '\s*\^nil') asRegex] }. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUnusedVariableInBlock.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUnusedVariableInBlock.st new file mode 100644 index 00000000..72fad740 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/testUnusedVariableInBlock.st @@ -0,0 +1,13 @@ +tests +testUnusedVariableInBlock + + self codePaneTextMorph textMorph contents append: '^[ | foo | ]'. + text append: '^[ | foo | ]'. + self + compiling: text + shouldRaise: UnusedVariable + andSelect: [text] + testing: { + [:ex | ex resume] -> [self assertCanceled]. + false -> [self assertSucceeded]. + true -> [self assertSucceeded: ('someMethod\' withCRs, Character startOfHeader, '\s*\^\[\s*\]') asRegex] }. \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/text.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/text.st new file mode 100644 index 00000000..93215c56 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/text.st @@ -0,0 +1,4 @@ +emulating +text + + ^text \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/undeclaredVar.st b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/undeclaredVar.st new file mode 100644 index 00000000..6cafcf71 --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/instance/undeclaredVar.st @@ -0,0 +1,4 @@ +private +undeclaredVar + + ^ '\foo := 42.' withCRs \ No newline at end of file diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/methodProperties.json b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/methodProperties.json new file mode 100644 index 00000000..5f9a3b7b --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/methodProperties.json @@ -0,0 +1,39 @@ +{ + "class" : { + "compilerClass" : "jb 10/24/2021 01:58" }, + "instance" : { + "assertCanceled" : "jb 11/11/2021 00:21", + "assertSelection:" : "jb 11/11/2021 00:20", + "assertSucceeded" : "jb 11/11/2021 00:21", + "assertSucceeded:" : "jb 11/11/2021 00:21", + "assertText:" : "jb 10/24/2021 02:51", + "codePaneTextMorph" : "jb 10/20/2021 18:18", + "compile:" : "jb 10/24/2021 03:09", + "compileMethodHeaderAndSetBrowserToIt" : "jb 10/24/2021 01:52", + "compiling:shouldRaise:andSelect:testing:" : "jb 11/11/2021 00:23", + "correctFrom:to:with:" : "jb 11/11/2021 00:21", + "generateUnknownSelector" : "jb 11/11/2021 00:32", + "handlerBlockFor:" : "jb 11/11/2021 00:23", + "nextTokenFrom:direction:" : "jb 11/11/2021 00:21", + "removeGeneratedMethods" : "jb 11/11/2021 00:32", + "runCase" : "jb 10/28/2021 18:04", + "selectFrom:to:" : "jb 11/11/2021 00:21", + "selectIntervalInvisibly:" : "jb 11/11/2021 00:22", + "selectInvisiblyFrom:to:" : "jb 11/11/2021 00:22", + "selection" : "jb 11/11/2021 00:23", + "selectionInterval" : "jb 11/11/2021 00:22", + "setUp" : "jb 10/28/2021 18:05", + "should:raise:thenDo:" : "jb 11/11/2021 00:20", + "tearDown" : "jb 10/28/2021 18:05", + "testAmbiguousSelector" : "jb 10/24/2021 22:41", + "testBlockFor:" : "jb 11/11/2021 00:23", + "testPastesBlockLocalTemp" : "jb 10/24/2021 22:41", + "testPastesFirstTempAtMethodLevel" : "jb 10/24/2021 22:41", + "testPastesSecondTempAtMethodLevel" : "jb 10/24/2021 22:41", + "testPastesTempForBlockValue" : "jb 10/24/2021 22:41", + "testUndefinedVariable" : "jb 10/24/2021 02:34", + "testUndefinedVariableBlockValue" : "jb 10/24/2021 02:37", + "testUnusedVariable" : "jb 11/16/2021 14:22", + "testUnusedVariableInBlock" : "jb 11/16/2021 14:22", + "text" : "jb 11/11/2021 00:31", + "undeclaredVar" : "jb 10/23/2021 16:49" } } diff --git a/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/properties.json b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/properties.json new file mode 100644 index 00000000..c7de397e --- /dev/null +++ b/packages/Babylonian-Tests.package/BPCompilerExceptionTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "Babylonian-Tests", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "browser" ], + "name" : "BPCompilerExceptionTest", + "pools" : [ + ], + "super" : "CompilerExceptionsTest", + "type" : "normal" } diff --git a/packages/Babylonian-UI.package/BPAnnotationMorph.class/class/smallFontHeight.st b/packages/Babylonian-UI.package/BPAnnotationMorph.class/class/smallFontHeight.st index d1d3f7a6..c6bd17e4 100644 --- a/packages/Babylonian-UI.package/BPAnnotationMorph.class/class/smallFontHeight.st +++ b/packages/Babylonian-UI.package/BPAnnotationMorph.class/class/smallFontHeight.st @@ -1,4 +1,4 @@ ui constants smallFontHeight - ^ self fontHeight * 0.75 \ No newline at end of file + ^ self fontHeight * 0.75 \ No newline at end of file diff --git a/packages/Babylonian-UI.package/BPAnnotationMorph.class/methodProperties.json b/packages/Babylonian-UI.package/BPAnnotationMorph.class/methodProperties.json index b8018182..f5376c84 100644 --- a/packages/Babylonian-UI.package/BPAnnotationMorph.class/methodProperties.json +++ b/packages/Babylonian-UI.package/BPAnnotationMorph.class/methodProperties.json @@ -3,7 +3,7 @@ "fontHeight" : "pre 11/18/2019 10:40", "fontWidth" : "pre 11/18/2019 10:44", "newContainerMorph" : "pre 10/12/2020 17:47", - "smallFontHeight" : "pre 10/6/2020 11:54", + "smallFontHeight" : "jb 9/9/2021 18:39", "smallFontWidth" : "pre 1/7/2021 11:49" }, "instance" : { "annotation" : "pre 7/2/2019 16:39", diff --git a/packages/Babylonian-UI.package/BPStyler.class/instance/unstyledTextFrom..st b/packages/Babylonian-UI.package/BPStyler.class/instance/unstyledTextFrom..st index a2182722..deb182dc 100644 --- a/packages/Babylonian-UI.package/BPStyler.class/instance/unstyledTextFrom..st +++ b/packages/Babylonian-UI.package/BPStyler.class/instance/unstyledTextFrom..st @@ -1,4 +1,11 @@ converting unstyledTextFrom: aText - - ^ Text fromString: aText asBPSource \ No newline at end of file + + "Re-implemented so that TextActions are not removed from aText" + | answer | + answer := Text fromString: aText asBPSource. + aText runs withStartStopAndValueDo: [:start :stop :attribs | + (attribs anySatisfy: [:each | each shoutShouldPreserve]) + ifTrue: [ + attribs do: [:eachAttrib | answer addAttribute: eachAttrib from: start to: stop]]]. + ^answer \ No newline at end of file diff --git a/packages/Babylonian-UI.package/BPStyler.class/methodProperties.json b/packages/Babylonian-UI.package/BPStyler.class/methodProperties.json index 6ad0efd9..529b2fee 100644 --- a/packages/Babylonian-UI.package/BPStyler.class/methodProperties.json +++ b/packages/Babylonian-UI.package/BPStyler.class/methodProperties.json @@ -24,4 +24,4 @@ "removePotentialEmptyLinesInText:around:" : "pre 8/25/2020 09:47", "selectedMethod:" : "ct 8/20/2021 06:24", "textForAnnotation:from:at:" : "jb 11/10/2021 23:27", - "unstyledTextFrom:" : "lu 6/1/2021 21:39" } } + "unstyledTextFrom:" : "jb 10/28/2021 18:08" } } diff --git a/packages/Babylonian-UI.package/BPTextReadWriter.class/instance/writeStartTagFor..st b/packages/Babylonian-UI.package/BPTextReadWriter.class/instance/writeStartTagFor..st index 0842dc99..cea0b2e2 100644 --- a/packages/Babylonian-UI.package/BPTextReadWriter.class/instance/writeStartTagFor..st +++ b/packages/Babylonian-UI.package/BPTextReadWriter.class/instance/writeStartTagFor..st @@ -1,5 +1,5 @@ writing writeStartTagFor: aTextAttribute - + [self nextPutAll: aTextAttribute anchoredMorph startTag] on: MessageNotUnderstood do: []. \ No newline at end of file diff --git a/packages/Babylonian-UI.package/BPTextReadWriter.class/methodProperties.json b/packages/Babylonian-UI.package/BPTextReadWriter.class/methodProperties.json index 6917bd39..6d13a9d9 100644 --- a/packages/Babylonian-UI.package/BPTextReadWriter.class/methodProperties.json +++ b/packages/Babylonian-UI.package/BPTextReadWriter.class/methodProperties.json @@ -13,4 +13,4 @@ "respectExamples" : "pre 1/11/2021 14:54", "writeContent:" : "jb 12/7/2020 19:03", "writeEndTagFor:" : "jb 12/7/2020 19:03", - "writeStartTagFor:" : "jb 12/7/2020 19:03" } } + "writeStartTagFor:" : "jb 8/31/2021 00:29" } } diff --git a/packages/Babylonian-UI.package/CodeHolder.extension/instance/addAnnotation.in..st b/packages/Babylonian-UI.package/CodeHolder.extension/instance/addAnnotation.in..st index 46a0d7b5..cf039e82 100644 --- a/packages/Babylonian-UI.package/CodeHolder.extension/instance/addAnnotation.in..st +++ b/packages/Babylonian-UI.package/CodeHolder.extension/instance/addAnnotation.in..st @@ -4,7 +4,6 @@ addAnnotation: anAnnotation in: interval | newContent text actualInterval newMorph | actualInterval := self determineIntervalToAnnotateFor: interval forNodes: anAnnotation canBeAnnotatedTo. actualInterval ifNil: [self codeTextMorph textMorph flash. ^ self]. - anAnnotation methodReference: self methodReference. text := self codeTextMorph text. newMorph := anAnnotation asMorph. @@ -19,10 +18,10 @@ addAnnotation: anAnnotation in: interval copyReplaceFrom: actualInterval start to: actualInterval stop with: newContent. - (self codeTextMorph) addMorph: newMorph; setText: newContent; hasUnacceptedEdits: true; - accept. - \ No newline at end of file + updateStyleNow; + flag: #workaround ;"BPStyler is currently not thread-safe, make sure to terminate any background styling operations before triggering the styler again in the line." + accept. \ No newline at end of file diff --git a/packages/Babylonian-UI.package/CodeHolder.extension/methodProperties.json b/packages/Babylonian-UI.package/CodeHolder.extension/methodProperties.json index efe25c4f..1c6bbc61 100644 --- a/packages/Babylonian-UI.package/CodeHolder.extension/methodProperties.json +++ b/packages/Babylonian-UI.package/CodeHolder.extension/methodProperties.json @@ -2,7 +2,7 @@ "class" : { }, "instance" : { - "addAnnotation:in:" : "pre 10/6/2020 11:07", + "addAnnotation:in:" : "jb 10/23/2021 14:38", "addAnnotationAtSelection:" : "pre 6/7/2021 14:59", "addAssertionToSelection" : "pre 11/13/2019 17:37", "addProbeToSelection" : "pre 8/6/2019 16:11",