MCPcopy Create free account
hub / github.com/beanshell/beanshell / completeName

Method completeName

src/bsh/util/NameCompletionTable.java:109–133  ·  view source on GitHub ↗
( String part )

Source from the content-addressed store, hash-verified

107 }
108
109 public String [] completeName( String part )
110 {
111 List found = new ArrayList();
112 getMatchingNames( part, found );
113
114 if ( found.size() == 0 )
115 return new String [0];
116
117 // Find the max common prefix
118 String maxCommon = (String)found.get(0);
119 for(int i=1; i<found.size() && maxCommon.length() > 0; i++) {
120 maxCommon = StringUtil.maxCommonPrefix(
121 maxCommon, (String)found.get(i) );
122
123 // if maxCommon gets as small as part, stop trying
124 if ( maxCommon.equals( part ) )
125 break;
126 }
127
128 // Return max common or all ambiguous
129 if ( maxCommon.length() > part.length() )
130 return new String [] { maxCommon };
131 else
132 return (String[])(found.toArray(new String[0]));
133 }
134
135 /**
136 class SourceCache implements NameSource.Listener

Callers

nothing calls this directly

Calls 5

getMatchingNamesMethod · 0.95
maxCommonPrefixMethod · 0.95
getMethod · 0.65
sizeMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected