NewChangesBrowser.st
changeset 17586 da595acccff1
parent 17034 96c54689f887
child 17921 e003f86bb9ec
equal deleted inserted replaced
17585:f5cf1f8f16f1 17586:da595acccff1
  2557     name := aChange className.
  2557     name := aChange className.
  2558     name notNil ifTrue:[^ name].
  2558     name notNil ifTrue:[^ name].
  2559 
  2559 
  2560     prevMethodDefNr := changes indexOf: aChange.
  2560     prevMethodDefNr := changes indexOf: aChange.
  2561     [(changes at:prevMethodDefNr) followUp] whileTrue:[
  2561     [(changes at:prevMethodDefNr) followUp] whileTrue:[
  2562 	prevMethodDefNr := prevMethodDefNr - 1.
  2562         prevMethodDefNr := prevMethodDefNr - 1.
  2563     ].
  2563     ].
  2564 
  2564 
  2565     "
  2565     "
  2566      get the chunk
  2566      get the chunk
  2567     "
  2567     "
  2568     chunk := (changes at:prevMethodDefNr) chunk.
  2568     chunk := (changes at:prevMethodDefNr) chunk.
  2569     chunk isNil ifTrue:[^ nil].       "mhmh - empty"
  2569     chunk isNil ifTrue:[^ nil].       "mhmh - empty"
  2570 
  2570 
  2571     (chunk startsWith:'''---') ifTrue:[
  2571     (chunk startsWith:'''---') ifTrue:[
  2572 	words := chunk asCollectionOfWords.
  2572         words := chunk asCollectionOfWords.
  2573 	words size > 2 ifTrue:[
  2573         words size > 2 ifTrue:[
  2574 	    (words at:2) = 'checkin' ifTrue:[
  2574             (words at:2) = 'checkin' ifTrue:[
  2575 		name := words at:3.
  2575                 name := words at:3.
  2576 		aChange className: name.
  2576                 aChange className: name.
  2577 		^ name
  2577                 ^ name
  2578 	    ]
  2578             ]
  2579 	].
  2579         ].
  2580     ].
  2580     ].
  2581 
  2581 
  2582     "/ fix it - otherwise, it cannot be parsed
  2582     "/ fix it - otherwise, it cannot be parsed
  2583     (chunk endsWith:'primitiveDefinitions:') ifTrue:[
  2583     (chunk endsWith:'primitiveDefinitions:') ifTrue:[
  2584 	chunk := chunk , ''''''
  2584         chunk := chunk , ''''''
  2585     ].
  2585     ].
  2586     (chunk endsWith:'primitiveFunctions:') ifTrue:[
  2586     (chunk endsWith:'primitiveFunctions:') ifTrue:[
  2587 	chunk := chunk , ''''''
  2587         chunk := chunk , ''''''
  2588     ].
  2588     ].
  2589     (chunk endsWith:'primitiveVariables:') ifTrue:[
  2589     (chunk endsWith:'primitiveVariables:') ifTrue:[
  2590 	chunk := chunk , ''''''
  2590         chunk := chunk , ''''''
  2591     ].
  2591     ].
  2592 
  2592 
  2593     "
  2593     "
  2594      use parser to construct a parseTree
  2594      use parser to construct a parseTree
  2595     "
  2595     "
  2596     oldDollarSetting := Parser allowDollarInIdentifier.
  2596     oldDollarSetting := Parser allowDollarInIdentifier.
  2597     [
  2597     [
  2598 	Parser allowDollarInIdentifier:true.
  2598         Parser allowDollarInIdentifier:true.
  2599 	aParseTree := Parser parseExpression:chunk.
  2599         aParseTree := Parser parseExpression:chunk.
  2600     ] valueNowOrOnUnwindDo:[
  2600     ] ensure:[
  2601 	Parser allowDollarInIdentifier:oldDollarSetting
  2601         Parser allowDollarInIdentifier:oldDollarSetting
  2602     ].
  2602     ].
  2603 
  2603 
  2604     (aParseTree isNil or:[aParseTree == #Error]) ifTrue:[
  2604     (aParseTree isNil or:[aParseTree == #Error]) ifTrue:[
  2605 	^ nil        "seems strange... (could be a comment)"
  2605         ^ nil        "seems strange... (could be a comment)"
  2606     ].
  2606     ].
  2607     aParseTree isMessage ifFalse:[
  2607     aParseTree isMessage ifFalse:[
  2608 	^ nil        "very strange... (whats that ?)"
  2608         ^ nil        "very strange... (whats that ?)"
  2609     ].
  2609     ].
  2610 
  2610 
  2611     "
  2611     "
  2612      ask parser for selector
  2612      ask parser for selector
  2613     "
  2613     "
  2627        #'primitiveFunctions:'
  2627        #'primitiveFunctions:'
  2628        #'primitiveVariables:'
  2628        #'primitiveVariables:'
  2629        #'renameCategory:to:'
  2629        #'renameCategory:to:'
  2630        #'instanceVariableNames:'
  2630        #'instanceVariableNames:'
  2631     ) includes:sel) ifTrue:[
  2631     ) includes:sel) ifTrue:[
  2632 	"
  2632         "
  2633 	 yes, the className is the receiver
  2633          yes, the className is the receiver
  2634 	"
  2634         "
  2635 	(recTree notNil and:[recTree ~~ #Error]) ifTrue:[
  2635         (recTree notNil and:[recTree ~~ #Error]) ifTrue:[
  2636 	    isMeta := false.
  2636             isMeta := false.
  2637 	    recTree isUnaryMessage ifTrue:[
  2637             recTree isUnaryMessage ifTrue:[
  2638 		(recTree selector ~~ #class) ifTrue:[^ nil].
  2638                 (recTree selector ~~ #class) ifTrue:[^ nil].
  2639 		"id class methodsFor:..."
  2639                 "id class methodsFor:..."
  2640 		recTree := recTree receiver.
  2640                 recTree := recTree receiver.
  2641 		isMeta := true.
  2641                 isMeta := true.
  2642 	    ].
  2642             ].
  2643 	    recTree isPrimary ifTrue:[
  2643             recTree isPrimary ifTrue:[
  2644 		name := recTree name.
  2644                 name := recTree name.
  2645 		isMeta ifTrue:[
  2645                 isMeta ifTrue:[
  2646 		    name := name , ' class'.
  2646                     name := name , ' class'.
  2647 		].
  2647                 ].
  2648 		aChange className: name.
  2648                 aChange className: name.
  2649 		^ name
  2649                 ^ name
  2650 	    ]
  2650             ]
  2651 	].
  2651         ].
  2652 	"more strange things"
  2652         "more strange things"
  2653 	^ nil
  2653         ^ nil
  2654     ].
  2654     ].
  2655 
  2655 
  2656     "
  2656     "
  2657      is it a change in a class-description ?
  2657      is it a change in a class-description ?
  2658     "
  2658     "
  2659     (('subclass:*' match:sel)
  2659     (('subclass:*' match:sel)
  2660     or:[('variable*subclass:*' match:sel)]) ifTrue:[
  2660     or:[('variable*subclass:*' match:sel)]) ifTrue:[
  2661 	"/ must parse the full changes text, to get
  2661         "/ must parse the full changes text, to get
  2662 	"/ privacy information.
  2662         "/ privacy information.
  2663 
  2663 
  2664 	changeStream := self streamForChange:aChange.
  2664         changeStream := self streamForChange:aChange.
  2665 	changeStream notNil ifTrue:[
  2665         changeStream notNil ifTrue:[
  2666 	    chunk := changeStream nextChunk.
  2666             chunk := changeStream nextChunk.
  2667 	    changeStream close.
  2667             changeStream close.
  2668 	    fullParseTree := Parser parseExpression:chunk.
  2668             fullParseTree := Parser parseExpression:chunk.
  2669 	    (fullParseTree isNil or:[fullParseTree == #Error]) ifTrue:[
  2669             (fullParseTree isNil or:[fullParseTree == #Error]) ifTrue:[
  2670 		fullParseTree := nil
  2670                 fullParseTree := nil
  2671 	    ].
  2671             ].
  2672 	    fullParseTree isMessage ifFalse:[
  2672             fullParseTree isMessage ifFalse:[
  2673 		fullParseTree := nil
  2673                 fullParseTree := nil
  2674 	    ].
  2674             ].
  2675 	    "/ actually, the nil case cannot happen
  2675             "/ actually, the nil case cannot happen
  2676 	    fullParseTree notNil ifTrue:[
  2676             fullParseTree notNil ifTrue:[
  2677 		aParseTree := fullParseTree.
  2677                 aParseTree := fullParseTree.
  2678 		sel := aParseTree selector.
  2678                 sel := aParseTree selector.
  2679 	    ].
  2679             ].
  2680 	].
  2680         ].
  2681 
  2681 
  2682 	arg1Tree := aParseTree arg1.
  2682         arg1Tree := aParseTree arg1.
  2683 	(arg1Tree notNil and:[arg1Tree isConstant]) ifTrue:[
  2683         (arg1Tree notNil and:[arg1Tree isConstant]) ifTrue:[
  2684 	    name := arg1Tree value asString.
  2684             name := arg1Tree value asString.
  2685 
  2685 
  2686 	    "/ is it a private-class ?
  2686             "/ is it a private-class ?
  2687 	    ('*privateIn:' match:sel) ifTrue:[
  2687             ('*privateIn:' match:sel) ifTrue:[
  2688 		ownerTree := aParseTree args last.
  2688                 ownerTree := aParseTree args last.
  2689 		ownerName := ownerTree name asString.
  2689                 ownerName := ownerTree name asString.
  2690 		name := ownerName , '::' , name
  2690                 name := ownerName , '::' , name
  2691 	    ].
  2691             ].
  2692 	    aChange className: name.
  2692             aChange className: name.
  2693 	    ^ name
  2693             ^ name
  2694 	].
  2694         ].
  2695 	"very strange"
  2695         "very strange"
  2696 	^ nil
  2696         ^ nil
  2697     ].
  2697     ].
  2698 
  2698 
  2699     "
  2699     "
  2700      is it a class remove ?
  2700      is it a class remove ?
  2701     "
  2701     "
  2702     (sel == #removeClass:) ifTrue:[
  2702     (sel == #removeClass:) ifTrue:[
  2703 	(recTree notNil
  2703         (recTree notNil
  2704 	and:[recTree ~~ #Error
  2704         and:[recTree ~~ #Error
  2705 	and:[recTree isPrimary
  2705         and:[recTree isPrimary
  2706 	and:[recTree name = 'Smalltalk']]]) ifTrue:[
  2706         and:[recTree name = 'Smalltalk']]]) ifTrue:[
  2707 	    arg1Tree := aParseTree arg1.
  2707             arg1Tree := aParseTree arg1.
  2708 	    (arg1Tree notNil and:[arg1Tree isPrimary]) ifTrue:[
  2708             (arg1Tree notNil and:[arg1Tree isPrimary]) ifTrue:[
  2709 		name := arg1Tree name.
  2709                 name := arg1Tree name.
  2710 		aChange className: name.
  2710                 aChange className: name.
  2711 		^ name
  2711                 ^ name
  2712 	    ].
  2712             ].
  2713 	]
  2713         ]
  2714     ].
  2714     ].
  2715 
  2715 
  2716     "
  2716     "
  2717      is it a method category change ?
  2717      is it a method category change ?
  2718     "
  2718     "
  2719     ((sel == #category:)
  2719     ((sel == #category:)
  2720     or:[sel == #privacy:]) ifTrue:[
  2720     or:[sel == #privacy:]) ifTrue:[
  2721 	(recTree notNil
  2721         (recTree notNil
  2722 	and:[recTree ~~ #Error
  2722         and:[recTree ~~ #Error
  2723 	and:[recTree isMessage
  2723         and:[recTree isMessage
  2724 	and:[recTree selector == #compiledMethodAt:]]]) ifTrue:[
  2724         and:[recTree selector == #compiledMethodAt:]]]) ifTrue:[
  2725 	    isMeta := false.
  2725             isMeta := false.
  2726 	    recTree := recTree receiver.
  2726             recTree := recTree receiver.
  2727 	    recTree isUnaryMessage ifTrue:[
  2727             recTree isUnaryMessage ifTrue:[
  2728 		(recTree selector ~~ #class) ifTrue:[^ nil].
  2728                 (recTree selector ~~ #class) ifTrue:[^ nil].
  2729 		"id class "
  2729                 "id class "
  2730 		recTree := recTree receiver
  2730                 recTree := recTree receiver
  2731 	    ].
  2731             ].
  2732 	    recTree isPrimary ifTrue:[
  2732             recTree isPrimary ifTrue:[
  2733 		isMeta ifTrue:[
  2733                 isMeta ifTrue:[
  2734 		    name := name , ' class'.
  2734                     name := name , ' class'.
  2735 		].
  2735                 ].
  2736 		name := recTree name.
  2736                 name := recTree name.
  2737 		aChange className: name.
  2737                 aChange className: name.
  2738 		^ name
  2738                 ^ name
  2739 	    ]
  2739             ]
  2740 	]
  2740         ]
  2741     ].
  2741     ].
  2742     ^ nil
  2742     ^ nil
       
  2743 
       
  2744     "Modified: / 17-07-2017 / 10:43:26 / cg"
  2743 !
  2745 !
  2744 
  2746 
  2745 newLabel:how
  2747 newLabel:how
  2746     "sets the label"
  2748     "sets the label"
  2747 
  2749 
  3090                 ].
  3092                 ].
  3091                 change lastPosition: aStream position.
  3093                 change lastPosition: aStream position.
  3092             ].
  3094             ].
  3093             modified := false.
  3095             modified := false.
  3094 
  3096 
  3095         ] valueNowOrOnUnwindDo:[
  3097         ] ensure:[
  3096             aStream close.
  3098             aStream close.
  3097             inBackground ifTrue:[myProcess priority:myPriority].
  3099             inBackground ifTrue:[myProcess priority:myPriority].
  3098         ].
  3100         ].
  3099     ].
  3101     ].
  3100     changes removeLast.
  3102     changes removeLast.
  3104     self filterLabel label: 'Filter:'.
  3106     self filterLabel label: 'Filter:'.
  3105 
  3107 
  3106     self checkIfFileHasChanged.
  3108     self checkIfFileHasChanged.
  3107 
  3109 
  3108     "Modified: / 16-11-2010 / 15:52:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  3110     "Modified: / 16-11-2010 / 15:52:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  3109     "Modified: / 18-08-2011 / 09:45:23 / cg"
  3111     "Modified: / 17-07-2017 / 10:43:38 / cg"
  3110 !
  3112 !
  3111 
  3113 
  3112 selectorOfMethodChange:aChange
  3114 selectorOfMethodChange:aChange
  3113     "returns the selector of the method change, or nil if it is not a method change"
  3115     "returns the selector of the method change, or nil if it is not a method change"
  3114 
  3116