Source Code Cross Referenced for DependencyExtentOperation.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » search » dependencies » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » Eclipse plug in development » org.eclipse.pde.internal.ui.search.dependencies 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.pde.internal.ui.search.dependencies;
011:
012:        import org.eclipse.core.resources.IProject;
013:        import org.eclipse.core.runtime.CoreException;
014:        import org.eclipse.core.runtime.IProgressMonitor;
015:        import org.eclipse.core.runtime.SubProgressMonitor;
016:        import org.eclipse.jdt.core.IClassFile;
017:        import org.eclipse.jdt.core.ICompilationUnit;
018:        import org.eclipse.jdt.core.IJavaElement;
019:        import org.eclipse.jdt.core.IJavaProject;
020:        import org.eclipse.jdt.core.IPackageFragment;
021:        import org.eclipse.jdt.core.IType;
022:        import org.eclipse.jdt.core.JavaCore;
023:        import org.eclipse.jdt.core.search.IJavaSearchConstants;
024:        import org.eclipse.jdt.core.search.IJavaSearchScope;
025:        import org.eclipse.jdt.core.search.SearchEngine;
026:        import org.eclipse.jdt.core.search.SearchMatch;
027:        import org.eclipse.jdt.core.search.SearchParticipant;
028:        import org.eclipse.jdt.core.search.SearchPattern;
029:        import org.eclipse.jdt.core.search.SearchRequestor;
030:        import org.eclipse.pde.core.ISourceObject;
031:        import org.eclipse.pde.core.plugin.IPluginExtension;
032:        import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
033:        import org.eclipse.pde.core.plugin.IPluginModelBase;
034:        import org.eclipse.pde.core.plugin.PluginRegistry;
035:        import org.eclipse.pde.internal.core.search.PluginJavaSearchUtil;
036:        import org.eclipse.pde.internal.ui.PDEUIMessages;
037:        import org.eclipse.search.ui.ISearchResult;
038:        import org.eclipse.search.ui.text.Match;
039:
040:        public class DependencyExtentOperation {
041:
042:            class TypeReferenceSearchRequestor extends SearchRequestor {
043:                boolean fUsed = false;
044:
045:                /* (non-Javadoc)
046:                 * @see org.eclipse.jdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.jdt.core.search.SearchMatch)
047:                 */
048:                public void acceptSearchMatch(SearchMatch match)
049:                        throws CoreException {
050:                    if (match.getAccuracy() == SearchMatch.A_ACCURATE
051:                            && !match.isInsideDocComment()) {
052:                        fUsed = true;
053:                    }
054:                }
055:
056:                public boolean containMatches() {
057:                    return fUsed;
058:                }
059:            }
060:
061:            class TypeDeclarationSearchRequestor extends SearchRequestor {
062:
063:                private Match fMatch;
064:
065:                /* (non-Javadoc)
066:                 * @see org.eclipse.jdt.core.search.SearchRequestor#acceptSearchMatch(org.eclipse.jdt.core.search.SearchMatch)
067:                 */
068:                public void acceptSearchMatch(SearchMatch match)
069:                        throws CoreException {
070:                    if (!match.isInsideDocComment())
071:                        fMatch = new Match(match.getElement(),
072:                                Match.UNIT_CHARACTER, match.getOffset(), match
073:                                        .getLength());
074:                }
075:
076:                public Match getMatch() {
077:                    return fMatch;
078:                }
079:            }
080:
081:            private DependencyExtentSearchResult fSearchResult;
082:            private String fImportID;
083:            private IPluginModelBase fModel;
084:            private IProject fProject;
085:
086:            public DependencyExtentOperation(IProject project, String importID,
087:                    ISearchResult searchResult) {
088:                fSearchResult = (DependencyExtentSearchResult) searchResult;
089:                fProject = project;
090:                fImportID = importID;
091:                fModel = PluginRegistry.findModel(project);
092:            }
093:
094:            public void execute(IProgressMonitor monitor) {
095:                IPluginModelBase[] plugins = PluginJavaSearchUtil
096:                        .getPluginImports(fImportID);
097:                monitor.beginTask(
098:                        PDEUIMessages.DependencyExtentOperation_searching
099:                                + " " + fImportID + "...", 10); //$NON-NLS-1$//$NON-NLS-2$ 
100:                checkForJavaDependencies(plugins, new SubProgressMonitor(
101:                        monitor, 9));
102:                for (int i = 0; i < plugins.length; i++) {
103:                    checkForExtensionPointsUsed(plugins[i]);
104:                }
105:                monitor.done();
106:            }
107:
108:            private void checkForExtensionPointsUsed(IPluginModelBase model) {
109:                IPluginExtensionPoint[] extPoints = model.getPluginBase()
110:                        .getExtensionPoints();
111:                for (int i = 0; i < extPoints.length; i++) {
112:                    findMatches(extPoints[i]);
113:                }
114:            }
115:
116:            private void findMatches(IPluginExtensionPoint point) {
117:                String fullID = point.getFullId();
118:                if (fullID == null)
119:                    return;
120:
121:                IPluginExtension[] extensions = fModel.getPluginBase()
122:                        .getExtensions();
123:                for (int i = 0; i < extensions.length; i++) {
124:                    if (fullID.equals(extensions[i].getPoint())) {
125:                        int line = ((ISourceObject) extensions[i])
126:                                .getStartLine() - 1;
127:                        if (line >= 0) {
128:                            fSearchResult.addMatch(new Match(point,
129:                                    Match.UNIT_LINE, line, 1));
130:                            break;
131:                        }
132:                    }
133:                }
134:            }
135:
136:            private void checkForJavaDependencies(IPluginModelBase[] models,
137:                    IProgressMonitor monitor) {
138:                try {
139:                    if (!fProject.hasNature(JavaCore.NATURE_ID))
140:                        return;
141:
142:                    IJavaProject jProject = JavaCore.create(fProject);
143:                    IPackageFragment[] packageFragments = PluginJavaSearchUtil
144:                            .collectPackageFragments(models, jProject, true);
145:                    monitor.beginTask("", packageFragments.length); //$NON-NLS-1$
146:                    SearchEngine engine = new SearchEngine();
147:                    for (int i = 0; i < packageFragments.length; i++) {
148:                        if (monitor.isCanceled())
149:                            break;
150:                        IPackageFragment pkgFragment = packageFragments[i];
151:                        monitor
152:                                .subTask(PDEUIMessages.DependencyExtentOperation_inspecting
153:                                        + " " + pkgFragment.getElementName()); //$NON-NLS-1$ 
154:                        if (pkgFragment.hasChildren()) {
155:                            IJavaElement[] children = pkgFragment.getChildren();
156:                            for (int j = 0; j < children.length; j++) {
157:                                if (monitor.isCanceled())
158:                                    break;
159:                                IJavaElement child = children[j];
160:                                IType[] types = new IType[0];
161:                                if (child instanceof  IClassFile) {
162:                                    types = new IType[] { ((IClassFile) child)
163:                                            .getType() };
164:                                } else if (child instanceof  ICompilationUnit) {
165:                                    types = ((ICompilationUnit) child)
166:                                            .getTypes();
167:                                }
168:                                if (types.length > 0)
169:                                    searchForTypesUsed(engine, child, types,
170:                                            PluginJavaSearchUtil
171:                                                    .createSeachScope(jProject));
172:                            }
173:                        }
174:                        monitor.worked(1);
175:                    }
176:                } catch (CoreException e) {
177:                } finally {
178:                    monitor.done();
179:                }
180:            }
181:
182:            private void searchForTypesUsed(SearchEngine engine,
183:                    IJavaElement parent, IType[] types, IJavaSearchScope scope)
184:                    throws CoreException {
185:                for (int i = 0; i < types.length; i++) {
186:                    if (types[i].isAnonymous())
187:                        continue;
188:                    TypeReferenceSearchRequestor requestor = new TypeReferenceSearchRequestor();
189:                    engine.search(SearchPattern.createPattern(types[i],
190:                            IJavaSearchConstants.REFERENCES),
191:                            new SearchParticipant[] { SearchEngine
192:                                    .getDefaultSearchParticipant() }, scope,
193:                            requestor, null);
194:                    if (requestor.containMatches()) {
195:                        TypeDeclarationSearchRequestor decRequestor = new TypeDeclarationSearchRequestor();
196:                        engine
197:                                .search(
198:                                        SearchPattern
199:                                                .createPattern(
200:                                                        types[i],
201:                                                        IJavaSearchConstants.DECLARATIONS),
202:                                        new SearchParticipant[] { SearchEngine
203:                                                .getDefaultSearchParticipant() },
204:                                        SearchEngine
205:                                                .createJavaSearchScope(new IJavaElement[] { parent }),
206:                                        decRequestor, null);
207:                        Match match = decRequestor.getMatch();
208:                        if (match != null)
209:                            fSearchResult.addMatch(match);
210:                    }
211:                }
212:
213:            }
214:
215:        }
w_w___w.__j__a_v__a2_s__.__com___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.