Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 217226 Details for
Bug 167472
[quick fix] Suggest to add missing type for for-each variable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
quick fix v0.1
eclipse.jdt.ui.patch (text/plain), 4.87 KB, created by
Markus Keller
on 2012-06-12 13:54:05 EDT
(
hide
)
Description:
quick fix v0.1
Filename:
MIME Type:
Creator:
Markus Keller
Created:
2012-06-12 13:54:05 EDT
Size:
4.87 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >diff --git ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java >index ee40f55..2562482 100644 >--- ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java >+++ ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.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 >@@ -874,6 +874,8 @@ > int superParent= parent.getParent().getNodeType(); > if (superParent == ASTNode.CATCH_CLAUSE) { > kind= SimilarElementsRequestor.CLASSES; >+ } else if (superParent == ASTNode.ENHANCED_FOR_STATEMENT) { >+ kind= SimilarElementsRequestor.REF_TYPES; > } > break; > case ASTNode.TAG_ELEMENT: >diff --git ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java >index afa202e..c04ffa7 100644 >--- ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java >+++ ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java >@@ -80,6 +80,7 @@ > import org.eclipse.jdt.core.dom.ClassInstanceCreation; > import org.eclipse.jdt.core.dom.CompilationUnit; > import org.eclipse.jdt.core.dom.ConstructorInvocation; >+import org.eclipse.jdt.core.dom.EnhancedForStatement; > import org.eclipse.jdt.core.dom.Expression; > import org.eclipse.jdt.core.dom.FieldAccess; > import org.eclipse.jdt.core.dom.IBinding; >@@ -98,6 +99,7 @@ > import org.eclipse.jdt.core.dom.SimpleName; > import org.eclipse.jdt.core.dom.SimpleType; > import org.eclipse.jdt.core.dom.SingleMemberAnnotation; >+import org.eclipse.jdt.core.dom.SingleVariableDeclaration; > import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor; > import org.eclipse.jdt.core.dom.SuperConstructorInvocation; > import org.eclipse.jdt.core.dom.SuperFieldAccess; >@@ -590,6 +592,10 @@ > } > > int kind= evauateTypeKind(selectedNode, cu.getJavaProject()); >+ >+ if (kind == SimilarElementsRequestor.REF_TYPES) { >+ addEnhancedForWithoutTypeProposals(cu, selectedNode, proposals); >+ } > > while (selectedNode.getLocationInParent() == QualifiedName.NAME_PROPERTY) { > selectedNode= selectedNode.getParent(); >@@ -632,6 +638,46 @@ > ReorgCorrectionsSubProcessor.addProjectSetupFixProposal(context, problem, node.getFullyQualifiedName(), proposals); > } > >+ private static void addEnhancedForWithoutTypeProposals(ICompilationUnit cu, ASTNode selectedNode, Collection<ICommandAccess> proposals) { >+ if (selectedNode instanceof SimpleName && selectedNode.getLocationInParent() == SimpleType.NAME_PROPERTY) { >+ ASTNode type= selectedNode.getParent(); >+ if (type.getLocationInParent() == SingleVariableDeclaration.TYPE_PROPERTY) { >+ SingleVariableDeclaration svd= (SingleVariableDeclaration) type.getParent(); >+ if (svd.getLocationInParent() == EnhancedForStatement.PARAMETER_PROPERTY) { >+ EnhancedForStatement enhancedForStatement= (EnhancedForStatement) svd.getParent(); >+ if (svd.getName().getLength() == 0) { >+ ITypeBinding typeBinding= enhancedForStatement.getExpression().resolveTypeBinding(); >+ if (typeBinding != null) { >+ ITypeBinding elementBinding= null; >+ if (typeBinding.isArray()) { >+ elementBinding= typeBinding.getElementType(); >+ } else if (typeBinding.isParameterizedType()) { >+ ITypeBinding iterable= Bindings.findTypeInHierarchy(typeBinding, "java.lang.Iterable"); //$NON-NLS-1$ >+ if (iterable != null) { >+ ITypeBinding[] typeArguments= iterable.getTypeArguments(); >+ if (typeArguments.length == 1) { >+ elementBinding= typeArguments[0]; >+ } >+ } >+ } >+ >+ if (elementBinding != null) { >+ SimpleName simpleName= (SimpleName) selectedNode; >+ String name= simpleName.getIdentifier(); >+ int relevance= StubUtility.hasLocalVariableName(cu.getJavaProject(), name) ? 10 : 7; >+ String label= Messages.format("Create loop variable ''{0}''", BasicElementLabels.getJavaElementName(name)); >+ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL); >+ >+ //TODO: doesn't work yet: >+ proposals.add(new NewVariableCorrectionProposal(label, cu, NewVariableCorrectionProposal.LOCAL, simpleName, elementBinding, relevance, image)); >+ } >+ } >+ } >+ } >+ } >+ } >+ } >+ > private static void addNullityAnnotationTypesProposals(ICompilationUnit cu, Name node, Collection<ICommandAccess> proposals) throws CoreException { > if (!(node.getParent() instanceof Annotation)) > return;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 167472
: 217226