package org.eclipse.jdt.internal.codeassist; import org.eclipse.core.runtime.*; import org.eclipse.jdt.core.compiler.*; import javax.swing.*; import java.io.*; public class InputMatcher { InputMatcherPlugin[] matcherPlugins; static InputMatcher plugin = new InputMatcher(); public InputMatcher() { init(); } private void init() { plugin = this; try { matcherPlugins = instantiateMatchers(); } catch (CoreException ex) { } } protected InputMatcherPlugin[] instantiateMatchers() throws CoreException { IExtensionPoint plugin = Platform.getPluginRegistry(). getExtensionPoint(org.eclipse.jdt.core.JavaCore.PLUGIN_ID, "inputMatcher"); IExtension[] extensions = plugin.getExtensions(); if (extensions == null || extensions.length == 0) return null; InputMatcherPlugin[] ret = new InputMatcherPlugin[extensions.length]; for (int i = 0; i < extensions.length; i++) { String className = extensions[i].getConfigurationElements()[0].getAttribute("class"); InputMatcherPlugin matcher = null; matcher = (InputMatcherPlugin) extensions[i].getConfigurationElements()[0].createExecutableExtension("class"); ret[i] = matcher; } return ret; } public boolean inputMatches( char[] input, char[] name, boolean isCaseSensitive) { if (matcherPlugins == null || matcherPlugins.length == 0) return CharOperation.prefixEquals(input, name, isCaseSensitive); for (int i = 0; i < matcherPlugins.length; i++) { if (matcherPlugins[i].inputMatched(input, name, isCaseSensitive)) { return true; } } return false; } public synchronized static boolean prefixEquals( char[] input, char[] name, boolean isCaseSensitive) { return plugin.inputMatches(input, name, isCaseSensitive); } }