Skip to content

Commit

Permalink
dc: add draft for ast diffing, ported from gumtree
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95 committed Sep 26, 2023
1 parent 3dc00d8 commit e40934e
Show file tree
Hide file tree
Showing 34 changed files with 1,449 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .squot
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ OrderedDictionary {
'packages/Sandblocks-Kotlin' : #SquotTonelSerializer,
'packages/Sandblocks-Cpp' : #SquotTonelSerializer,
'packages/Sandblocks-Wing' : #SquotTonelSerializer,
'packages/DomainCode-Parser' : #SquotTonelSerializer
'packages/DomainCode-Parser' : #SquotTonelSerializer,
'packages/DomainCode-Core' : #SquotTonelSerializer,
'packages/DomainCode-Diff' : #SquotTonelSerializer
}
6 changes: 6 additions & 0 deletions packages/DomainCode-Core/.squot-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SquotTrackedObjectMetadata {
#objectClassName : #PackageInfo,
#id : UUID [ 'b0f8b91f48b140dab0d584ce30237423' ],
#objectsReplacedByNames : true,
#serializer : #SquotTonelSerializer
}
34 changes: 34 additions & 0 deletions packages/DomainCode-Core/DCFileEditor.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Class {
#name : #DCFileEditor,
#superclass : #SBBlock,
#instVars : [
'file'
],
#category : #'DomainCode-Core'
}

{ #category : #'as yet unclassified' }
DCFileEditor >> file: aFile [

file := aFile.

self
changeTableLayout;
hResizing: #spaceFill;
vResizing: #spaceFill;
addMorphBack: (ScrollPane new
hResizing: #spaceFill;
vResizing: #spaceFill;
hScrollBarPolicy: #never;
in: [:scroll |
scroll scroller
changeTableLayout;
hResizing: #spaceFill;
addMorphBack: ((SBTSFile languageForPathAskInstall: aFile basename)
ifNotNil: [:language |
(DCBlock parseBlock: file contents language: language)
hResizing: #spaceFill;
vResizing: #shrinkWrap]
ifNil: [self shouldBeImplemented])];
yourself)
]
54 changes: 54 additions & 0 deletions packages/DomainCode-Core/DCProject.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Class {
#name : #DCProject,
#superclass : #SBBlock,
#instVars : [
'directory',
'name'
],
#category : #'DomainCode-Core'
}

{ #category : #'as yet unclassified' }
DCProject >> directory [

^ directory
]

{ #category : #'as yet unclassified' }
DCProject >> directory: aDirectory [

directory := aDirectory asFSReference.

self
removeAllMorphs;
changeTableLayout;
hResizing: #shrinkWrap;
vResizing: #shrinkWrap;
listDirection: #leftToRight;
addMorphBack: (name := SBTextBubble new contents: directory basename);
addMorphBack: (SBButton new icon: SBIcon iconFolderOpen do: [self addProp: #open])
]

{ #category : #'as yet unclassified' }
DCProject >> domainParent [

^ self owner owner
]

{ #category : #'as yet unclassified' }
DCProject >> domainReferencesDo: aClosure [

aClosure value: self directory
]

{ #category : #'as yet unclassified' }
DCProject >> name [

^ name contents
]

{ #category : #'as yet unclassified' }
DCProject >> name: aString [

name contents: aString
]
45 changes: 45 additions & 0 deletions packages/DomainCode-Core/DCProjectView.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Class {
#name : #DCProjectView,
#superclass : #SBBlock,
#instVars : [
'files'
],
#category : #'DomainCode-Core'
}

{ #category : #'as yet unclassified' }
DCProjectView class >> queryOpenProject: aRoot [
<domainQuery>

aRoot
queryFirst: [:obj | obj class = DCProject and: [obj hasProp: #open]]
ifFound: [:match | aRoot sandblockEditor openMorphInView: (self new project: match)]
ifNone: []
]

{ #category : #'as yet unclassified' }
DCProjectView >> openFile: aFile [

self submorphCount > 1 ifTrue: [self lastSubmorph delete].
self addMorphBack: (DCFileEditor new file: aFile)
]

{ #category : #'as yet unclassified' }
DCProjectView >> project: aProject [

self
changeTableLayout;
hResizing: #rigid;
vResizing: #shrinkWrap;
listDirection: #leftToRight;
layoutInset: 8;
width: 600;
attachDecorator: SBForceMoveDecorator newConfigured;
attachDecorator: SBResizableDecorator new;
addMorphBack: (files := SBColumn new).

aProject
queryFirst: [:obj | obj class = FSReference and: [obj = aProject directory]]
ifFound: [:rootFile | files addMorphBack: ((SBFileTree new on: rootFile) when: #open send: #openFile: to: self)]
ifNone: []
]
54 changes: 54 additions & 0 deletions packages/DomainCode-Core/DCQuery.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Class {
#name : #DCQuery,
#superclass : #Object,
#classVars : [
'Properties'
],
#category : #'DomainCode-Core'
}

{ #category : #'as yet unclassified' }
DCQuery class >> addProperty: anObject to: aDomainObject [

(self properties at: aDomainObject ifAbsentPut: [OrderedCollection new]) add: anObject.
self checkQueriesFor: aDomainObject domainRoot
]

{ #category : #'as yet unclassified' }
DCQuery class >> checkQueriesFor: aRoot [

Object allSubclassesDo: [:cls |
Pragma
withPragmasIn: cls
do: [:pragma | pragma keyword = #domainQuery ifTrue: [cls theNonMetaClass perform: pragma selector with: aRoot]]]
]

{ #category : #'as yet unclassified' }
DCQuery class >> does: aDomainObject haveProperty: anObject [

^ self properties
at: aDomainObject
ifPresent: [:properties | properties includes: anObject]
ifAbsent: [false]
]

{ #category : #'as yet unclassified' }
DCQuery class >> match: aClosure with: anObject do: anotherClosure [

(aClosure value: anObject) ifTrue: [anotherClosure value: anObject].
anObject domainReferencesDo: [:ref | self match: aClosure with: ref do: anotherClosure]
]

{ #category : #'as yet unclassified' }
DCQuery class >> properties [

^ Properties ifNil: [Properties := WeakKeyDictionary new]
]

{ #category : #'as yet unclassified' }
DCQuery class >> removeProperty: anObject from: aDomainObject [

self properties
at: aDomainObject
ifPresent: [:properties | properties remove: aDomainObject]
]
46 changes: 46 additions & 0 deletions packages/DomainCode-Core/DCWorkspace.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Class {
#name : #DCWorkspace,
#superclass : #SBBlock,
#instVars : [
'projects'
],
#category : #'DomainCode-Core'
}

{ #category : #'as yet unclassified' }
DCWorkspace >> domainParent [

^ nil
]

{ #category : #'as yet unclassified' }
DCWorkspace >> domainReferencesDo: aClosure [

projects submorphsDo: aClosure
]

{ #category : #'as yet unclassified' }
DCWorkspace >> initialize [

super initialize.

self
hResizing: #shrinkWrap;
vResizing: #shrinkWrap;
changeTableLayout;
addMorphBack: (SBButton new label: 'Open Project' do: [self openProject]);
addMorphBack: (projects := SBColumn new)
]

{ #category : #'as yet unclassified' }
DCWorkspace >> openProject [
<action>

UIManager default chooseDirectory ifNotNil: [:directory | projects addMorphFront: (DCProject new directory: directory)]
]

{ #category : #'as yet unclassified' }
DCWorkspace >> projects [

^ projects submorphs
]
7 changes: 7 additions & 0 deletions packages/DomainCode-Core/FSReference.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #FSReference }

{ #category : #'*DomainCode-Core' }
FSReference >> domainReferencesDo: aClosure [

self isDirectory ifTrue: [self children do: aClosure]
]
44 changes: 44 additions & 0 deletions packages/DomainCode-Core/Object.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Extension { #name : #Object }

{ #category : #'*DomainCode-Core' }
Object >> addProp: anObject [

DCQuery addProperty: anObject to: self
]

{ #category : #'*DomainCode-Core' }
Object >> domainParent [

^ self subclassResponsibility
]

{ #category : #'*DomainCode-Core' }
Object >> domainReferencesDo: aClosure [


]

{ #category : #'*DomainCode-Core' }
Object >> domainRoot [

^ self domainParent ifNil: [self] ifNotNil: [:p | p domainRoot]
]

{ #category : #'*DomainCode-Core' }
Object >> hasProp: anObject [

^ DCQuery does: self haveProperty: anObject
]

{ #category : #'*DomainCode-Core' }
Object >> query: aClosure do: anotherClosure [

^ DCQuery match: aClosure with: self do: anotherClosure
]

{ #category : #'*DomainCode-Core' }
Object >> queryFirst: aClosure ifFound: anotherClosure ifNone: aThirdClosure [

DCQuery match: aClosure with: self do: [:match | ^ anotherClosure value: match].
^ aThirdClosure value
]
1 change: 1 addition & 0 deletions packages/DomainCode-Core/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'DomainCode-Core' }
6 changes: 6 additions & 0 deletions packages/DomainCode-Diff/.squot-contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SquotTrackedObjectMetadata {
#objectClassName : #PackageInfo,
#id : UUID [ 'c4feeb7baa0d4f32a5bba86de4f6057a' ],
#objectsReplacedByNames : true,
#serializer : #SquotTonelSerializer
}
Loading

0 comments on commit e40934e

Please sign in to comment.