Index: ui/org/eclipse/jdt/internal/ui/text/java/JavaMethodCompletionProposal.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaMethodCompletionProposal.java,v retrieving revision 1.11 diff -u -r1.11 JavaMethodCompletionProposal.java --- ui/org/eclipse/jdt/internal/ui/text/java/JavaMethodCompletionProposal.java 26 May 2005 12:32:41 -0000 1.11 +++ ui/org/eclipse/jdt/internal/ui/text/java/JavaMethodCompletionProposal.java 16 Sep 2005 21:21:13 -0000 @@ -40,7 +40,7 @@ public class JavaMethodCompletionProposal extends LazyJavaCompletionProposal { /** Triggers for method proposals without parameters. Do not modify. */ - protected final static char[] METHOD_TRIGGERS= new char[] { ';', ',', '.', '\t', '[', ' ' }; + protected final static char[] METHOD_TRIGGERS= new char[] { ';', ',', '.', '\t', '[', ' ', '(', '+', '-', '/', '*', '<', '>', '&', '|', '^', '?', ':', '^', '%', ']' }; /** Triggers for method proposals. Do not modify. */ protected final static char[] METHOD_WITH_ARGUMENTS_TRIGGERS= new char[] { '(', '-', ' ' }; @@ -99,6 +99,18 @@ } public void apply(IDocument document, char trigger, int offset) { + + String replacement= getReplacementString(); + if (replacement != null && replacement.endsWith("()") && trigger == '(') { //$NON-NLS-1$ + setCursorPosition(replacement.length() - 1); + + // Strip off the closing brackets if the user doesn't want them auto-closed. + IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore(); + if (!preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACKETS)) { + setReplacementString(replacement.substring(0, replacement.length() - 1)); + } + } + super.apply(document, trigger, offset); try { setUpLinkedMode(document, getReplacementString()); Index: ui/org/eclipse/jdt/internal/ui/text/java/LazyJavaTypeCompletionProposal.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/LazyJavaTypeCompletionProposal.java,v retrieving revision 1.2 diff -u -r1.2 LazyJavaTypeCompletionProposal.java --- ui/org/eclipse/jdt/internal/ui/text/java/LazyJavaTypeCompletionProposal.java 3 May 2005 12:57:50 -0000 1.2 +++ ui/org/eclipse/jdt/internal/ui/text/java/LazyJavaTypeCompletionProposal.java 16 Sep 2005 21:21:13 -0000 @@ -39,7 +39,7 @@ */ public class LazyJavaTypeCompletionProposal extends LazyJavaCompletionProposal { /** Triggers for types. Do not modify. */ - protected final static char[] TYPE_TRIGGERS= new char[] { '.', '\t', '[', '(', ' ' }; + protected final static char[] TYPE_TRIGGERS= new char[] { '.', '\t', '[', '(', ' ', ')' }; protected final ICompilationUnit fCompilationUnit; Index: ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java,v retrieving revision 1.13 diff -u -r1.13 CompletionProposalCollector.java --- ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java 2 May 2005 12:54:28 -0000 1.13 +++ ui/org/eclipse/jdt/ui/text/java/CompletionProposalCollector.java 16 Sep 2005 21:21:16 -0000 @@ -89,13 +89,15 @@ private static final boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.jdt.ui/debug/ResultCollector")); //$NON-NLS-1$//$NON-NLS-2$ /** Triggers for method proposals without parameters. Do not modify. */ - protected final static char[] METHOD_TRIGGERS= new char[] { ';', ',', '.', '\t', '[', ' ' }; + protected final static char[] METHOD_TRIGGERS= new char[] { ';', ',', '.', '\t', '[', ' ', '(', '+', '-', '/', '*', '<', '>', '&', '|', '^', '?', ':', '^', '%', ']' }; /** Triggers for method proposals. Do not modify. */ protected final static char[] METHOD_WITH_ARGUMENTS_TRIGGERS= new char[] { '(', '-', ' ' }; /** Triggers for types. Do not modify. */ - protected final static char[] TYPE_TRIGGERS= new char[] { '.', '\t', '[', '(', ' ' }; + protected final static char[] TYPE_TRIGGERS= new char[] { '.', '\t', '[', '(', ' ', ')' }; /** Triggers for variables. Do not modify. */ - protected final static char[] VAR_TRIGGER= new char[] { '\t', ' ', '=', ';', '.' }; + protected final static char[] VAR_TRIGGERS= new char[] { '\t', ' ', '=', ';', '.', '+', '-', '/', '*', '<', '>', '&', '|', '^', '~', '?', ':', '%', ')', '}', ']', ',' }; + /** Triggers for keywords. */ + protected final static char[] KEYWORD_TRIGGERS= new char[] { '\t', ' ', '=', ';', '.', '&', '|', '?', ':', '(', ')', '{', '}', ']', ',', '^' }; private final CompletionProposalLabelProvider fLabelProvider= new CompletionProposalLabelProvider(); private final ImageDescriptorRegistry fRegistry= JavaPlugin.getImageDescriptorRegistry(); @@ -588,7 +590,7 @@ if (fJavaProject != null) javaProposal.setProposalInfo(new FieldProposalInfo(fJavaProject, proposal)); - javaProposal.setTriggerCharacters(VAR_TRIGGER); + javaProposal.setTriggerCharacters(VAR_TRIGGERS); return javaProposal; } @@ -599,7 +601,9 @@ int length= getLength(proposal); String label= fLabelProvider.createSimpleLabel(proposal); int relevance= computeRelevance(proposal); - return new JavaCompletionProposal(completion, start, length, null, label, relevance); + JavaCompletionProposal javaProposal= new JavaCompletionProposal(completion, start, length, null, label, relevance); + javaProposal.setTriggerCharacters(KEYWORD_TRIGGERS); + return javaProposal; } private IJavaCompletionProposal createLabelProposal(CompletionProposal proposal) { @@ -621,7 +625,7 @@ int relevance= computeRelevance(proposal); final JavaCompletionProposal javaProposal= new JavaCompletionProposal(completion, start, length, image, label, relevance); - javaProposal.setTriggerCharacters(VAR_TRIGGER); + javaProposal.setTriggerCharacters(VAR_TRIGGERS); return javaProposal; }