1
0
Просмотр исходного кода

Merge pull request #1169 from mkroehnert/rename-package

add Environment>>renamePackage:to:
Herbert Vojčík 9 лет назад
Родитель
Сommit
8a889ab67f
3 измененных файлов с 48 добавлено и 0 удалено
  1. 5 0
      API-CHANGES.txt
  2. 36 0
      src/Platform-Services.js
  3. 7 0
      src/Platform-Services.st

+ 5 - 0
API-CHANGES.txt

@@ -1,3 +1,8 @@
+0.14.14:
+
++ Environment
+  + renamePackage:to:
+
 0.14.12:
 
 + JSObjectProxy >>

+ 36 - 0
src/Platform-Services.js

@@ -1329,6 +1329,42 @@ messageSends: ["ifNotNil:", "at:", "globals", "error:", ",", "renameClass:to:",
 }),
 $globals.Environment);
 
+$core.addMethod(
+$core.method({
+selector: "renamePackage:to:",
+protocol: 'actions',
+fn: function (aPackageName,aNewPackageName){
+var self=this;
+function $Smalltalk(){return $globals.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2,$receiver;
+$1=$recv($recv($Smalltalk())._globals())._at_(aNewPackageName);
+if(($receiver = $1) == null || $receiver.isNil){
+$1;
+} else {
+$2=$recv("A package named ".__comma(aNewPackageName)).__comma(" already exists");
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx[","]=1;
+//>>excludeEnd("ctx");
+self._error_($2);
+};
+$recv($Smalltalk())._renamePackage_to_(aPackageName,aNewPackageName);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"renamePackage:to:",{aPackageName:aPackageName,aNewPackageName:aNewPackageName},$globals.Environment)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aPackageName", "aNewPackageName"],
+source: "renamePackage: aPackageName to: aNewPackageName\x0a        (Smalltalk globals at: aNewPackageName)\x0a                ifNotNil: [ self error: 'A package named ', aNewPackageName, ' already exists' ].\x0a\x0a        Smalltalk renamePackage: aPackageName to: aNewPackageName",
+referencedClasses: ["Smalltalk"],
+//>>excludeEnd("ide");
+messageSends: ["ifNotNil:", "at:", "globals", "error:", ",", "renamePackage:to:"]
+}),
+$globals.Environment);
+
 $core.addMethod(
 $core.method({
 selector: "renameProtocol:to:in:",

+ 7 - 0
src/Platform-Services.st

@@ -240,6 +240,13 @@ renameClass: aClass to: aClassName
 	ClassBuilder new renameClass: aClass to: aClassName
 !
 
+renamePackage: aPackageName to: aNewPackageName
+        (Smalltalk globals at: aNewPackageName)
+                ifNotNil: [ self error: 'A package named ', aNewPackageName, ' already exists' ].
+
+        Smalltalk renamePackage: aPackageName to: aNewPackageName
+!
+
 renameProtocol: aString to: anotherString in: aClass
 	(aClass methodsInProtocol: aString)
 		do: [ :each | each protocol: anotherString ]