diff options
| author | Markus Keller | 2012-04-11 14:44:13 +0000 |
|---|---|---|
| committer | Markus Keller | 2012-04-11 14:44:13 +0000 |
| commit | 5cebfb1d709a8016d876757ac33ff278dfcbd43a (patch) | |
| tree | a0974ecab82fa4a856b06aa2f4bf5fcaf1961301 | |
| parent | ccad5c0389ff05c7e0ff5b98b2f9ba7115404f1c (diff) | |
| download | eclipse.jdt.ui-5cebfb1d709a8016d876757ac33ff278dfcbd43a.tar.gz eclipse.jdt.ui-5cebfb1d709a8016d876757ac33ff278dfcbd43a.tar.xz eclipse.jdt.ui-5cebfb1d709a8016d876757ac33ff278dfcbd43a.zip | |
Bug 200847: [templates] Variable resolver resolves to array of specified
type
| -rw-r--r-- | org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitCompletion.java | 17 | ||||
| -rw-r--r-- | org.eclipse.jdt.ui/plugin.properties | 4 |
2 files changed, 18 insertions, 3 deletions
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitCompletion.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitCompletion.java index 451a5325c4..aed181254d 100644 --- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitCompletion.java +++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/template/java/CompilationUnitCompletion.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -138,6 +138,21 @@ final class CompilationUnitCompletion extends CompletionRequestor { String implementorName= SignatureUtil.stripSignatureToFQN(signature); if (implementorName.length() == 0) return false; + + int implementorDims= Signature.getArrayCount(signature); + int superDimsIndex= supertype.indexOf("[]"); //$NON-NLS-1$ + int superDims; + if (superDimsIndex != -1) { + superDims= (supertype.length() - superDimsIndex) / 2; + supertype= supertype.substring(0, superDimsIndex); + } else { + superDims= 0; + } + if (implementorDims > superDims) { + return "java.lang.Object".equals(supertype); //$NON-NLS-1$ + } else if (superDims != implementorDims) { + return false; + } boolean qualified= supertype.indexOf('.') != -1; diff --git a/org.eclipse.jdt.ui/plugin.properties b/org.eclipse.jdt.ui/plugin.properties index 4142cfb593..784220d8cc 100644 --- a/org.eclipse.jdt.ui/plugin.properties +++ b/org.eclipse.jdt.ui/plugin.properties @@ -1068,9 +1068,9 @@ templates.java.resolvers.Link.description= <b>${<i>id</i>:link([proposal[,propos templates.java.resolvers.Imports.name= Import templates.java.resolvers.Imports.description= <b>${:import([type[,type]*])}</b><br>Adds an import statement for each type that is not already imported. Does nothing if a conflicting import exists. Evaluates to nothing.<br><br><b>Example:</b><br><code>${:import(java.util.List, java.util.Collection)}</code> templates.java.resolvers.ImportStatic.name= Import Static -templates.java.resolvers.ImportStatic.description= <b>${:importStatic([qualifiedName[,qualifiedName]*])}</b><br>Adds a static import statement for each qualified name that is not already imported. The <code>qualifiedName</code> is the fully qualified name of a static field or method or it is the qualified name of a type plus a '.*' suffix. Does nothing if a conflicting import exists. Evaluates to nothing.<br><br><b>Example:</b><br><code>${:importStatic(java.util.Collections.EMPTY_SET, 'java.lang.System.*')}</code> +templates.java.resolvers.ImportStatic.description= <b>${:importStatic([qualifiedName[,qualifiedName]*])}</b><br>Adds a static import statement for each qualified name that is not already imported. The <code>qualifiedName</code> is the fully qualified name of a static field or method, or it is the qualified name of a type plus a '.*' suffix, enclosed in single quotes ''. Does nothing if a conflicting import exists. Evaluates to nothing.<br><br><b>Example:</b><br><code>${:importStatic(java.util.Collections.EMPTY_SET, 'java.lang.System.*')}</code> templates.java.resolvers.Var.name= Variable -templates.java.resolvers.Var.description= <b>${<i>id</i>:var(type[,type]*)}</b><br>Evaluates to a field, local variable or parameter visible in the current scope that is a subtype of any of the given types. If no type is specified, any non-primitive variable matches.<br><br><b>Example:</b><br><code>${array:var(java.lang.Object[])}</code> +templates.java.resolvers.Var.description= <b>${<i>id</i>:var(type[,type]*)}</b><br>Evaluates to a field, local variable or parameter visible in the current scope that is a subtype of any of the given types. If no type is specified, any non-primitive variable matches.<br><br><b>Example:</b><br><code>${array:var('java.lang.Object[]')}</code> templates.java.resolvers.LocalVar.name= Local Variable templates.java.resolvers.LocalVar.description= <b>${<i>id</i>:localVar(type[,type]*)}</b><br>Evaluates to a local variable or parameter visible in the current scope that is a subtype of any of the given types. If no type is specified, any non-primitive local variable matches.<br><br><b>Example:</b><br><code>${iterable:localVar(java.lang.Iterable)}</code> templates.java.resolvers.Name.name= New Name |
