1324 globalNameCompletion:aPartialGlobalName inEnvironment:anEnvironment |
1324 globalNameCompletion:aPartialGlobalName inEnvironment:anEnvironment |
1325 "given a partial globalName, return an array consisting of |
1325 "given a partial globalName, return an array consisting of |
1326 2 entries: 1st: the best (longest) match |
1326 2 entries: 1st: the best (longest) match |
1327 2nd: collection consisting of matching names" |
1327 2nd: collection consisting of matching names" |
1328 |
1328 |
|
1329 ^ self globalNameCompletion:aPartialGlobalName inEnvironment:anEnvironment match:true |
|
1330 |
|
1331 " |
|
1332 Smalltalk globalnameCompletion:'Arr' |
|
1333 Smalltalk globalnameCompletion:'Arra' |
|
1334 Smalltalk globalnameCompletion:'arra' |
|
1335 Smalltalk globalnameCompletion:'*rray' |
|
1336 " |
|
1337 |
|
1338 "Created: / 10-08-2006 / 13:06:23 / cg" |
|
1339 ! |
|
1340 |
|
1341 globalNameCompletion:aPartialGlobalName inEnvironment:anEnvironment match:doMatch |
|
1342 "given a partial globalName, return an array consisting of |
|
1343 2 entries: 1st: the best (longest) match |
|
1344 2nd: collection consisting of matching names" |
|
1345 |
1329 |searchName matches ignCaseMatches best isMatchString| |
1346 |searchName matches ignCaseMatches best isMatchString| |
1330 |
1347 |
1331 searchName := aPartialGlobalName. |
1348 searchName := aPartialGlobalName. |
1332 searchName isEmpty ifTrue:[ |
1349 searchName isEmpty ifTrue:[ |
1333 ^ Array with:searchName with:#() |
1350 ^ Array with:searchName with:#() |
1335 |
1352 |
1336 (searchName at:1) isLowercase ifTrue:[ |
1353 (searchName at:1) isLowercase ifTrue:[ |
1337 searchName := searchName copy asUppercaseFirst |
1354 searchName := searchName copy asUppercaseFirst |
1338 ]. |
1355 ]. |
1339 |
1356 |
1340 isMatchString := searchName includesMatchCharacters. |
1357 isMatchString := doMatch and:[ searchName includesMatchCharacters ]. |
1341 matches := OrderedCollection new. |
1358 matches := OrderedCollection new. |
1342 ignCaseMatches := OrderedCollection new. |
1359 ignCaseMatches := OrderedCollection new. |
1343 anEnvironment keysDo:[:aGlobalName | |
1360 anEnvironment keysDo:[:aGlobalName | |
1344 | addIt| |
1361 | addIt| |
1345 |
1362 |
1518 selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment |
1535 selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment |
1519 "given a partial selector, return an array consisting of |
1536 "given a partial selector, return an array consisting of |
1520 2 entries: 1st: the longest match |
1537 2 entries: 1st: the longest match |
1521 2nd: collection consisting of matching implemented selectors" |
1538 2nd: collection consisting of matching implemented selectors" |
1522 |
1539 |
1523 |matches best lcSym| |
1540 ^ self selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment match:false |
|
1541 ! |
|
1542 |
|
1543 selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment match:doMatch |
|
1544 "given a partial selector, return an array consisting of |
|
1545 2 entries: 1st: the longest match |
|
1546 2nd: collection consisting of matching implemented selectors" |
|
1547 |
|
1548 |matches best lcSym isMatch| |
1524 |
1549 |
1525 matches := IdentitySet new. |
1550 matches := IdentitySet new. |
1526 |
1551 |
1527 "/ search for exact match |
1552 isMatch := doMatch and:[aPartialSymbolName includesMatchCharacters]. |
|
1553 |
1528 anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
1554 anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
1529 (eachSelector startsWith:aPartialSymbolName) ifTrue:[ |
1555 (isMatch |
|
1556 ifTrue:[ (aPartialSymbolName match:eachSelector) ] |
|
1557 ifFalse:[ (eachSelector startsWith:aPartialSymbolName) ]) |
|
1558 ifTrue:[ |
1530 matches add:eachSelector |
1559 matches add:eachSelector |
1531 ]. |
1560 ]. |
1532 ]. |
1561 ]. |
1533 matches isEmpty ifTrue:[ |
1562 matches isEmpty ifTrue:[ |
1534 "/ search for case-ignoring match |
1563 "/ search for case-ignoring match |
1535 lcSym := aPartialSymbolName asLowercase. |
|
1536 anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
1564 anEnvironment allMethodsWithSelectorDo:[:eachMethod :eachSelector | |
1537 (eachSelector asLowercase startsWith:lcSym) ifTrue:[ |
1565 (isMatch |
|
1566 ifTrue:[ (lcSym match:eachSelector ignoreCase:true) ] |
|
1567 ifFalse:[ (eachSelector asLowercase startsWith:lcSym) ]) |
|
1568 ifTrue:[ |
1538 matches add:eachSelector |
1569 matches add:eachSelector |
1539 ]. |
1570 ]. |
1540 ]. |
1571 ]. |
1541 ]. |
1572 ]. |
1542 |
1573 |