You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ds...@apache.org on 2010/08/02 19:08:20 UTC
svn commit: r981604 [11/22] - in /felix/trunk/sigil:
common/core.tests/src/org/apache/felix/sigil/common/core/
common/core.tests/src/org/apache/felix/sigil/common/core/internal/model/osgi/
common/core/src/org/apache/felix/sigil/common/bnd/ common/core/...
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.model.util;
-
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.CharBuffer;
@@ -35,12 +34,11 @@ import java.util.regex.Pattern;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
-
public class Grep
{
// Pattern used to parse lines
- private static Pattern linePattern = Pattern.compile( ".*\r?\n" );
+ private static Pattern linePattern = Pattern.compile(".*\r?\n");
// The input pattern that we're looking for
private Pattern pattern;
@@ -49,77 +47,72 @@ public class Grep
private FileChannel fc;
-
- private Grep( IFile f, Pattern pattern ) throws IOException, CoreException
+ private Grep(IFile f, Pattern pattern) throws IOException, CoreException
{
this.pattern = pattern;
- cb = openBuffer( f );
+ cb = openBuffer(f);
}
-
- private CharBuffer openBuffer( IFile f ) throws IOException, CoreException
+ private CharBuffer openBuffer(IFile f) throws IOException, CoreException
{
- Charset charset = Charset.forName( f.getCharset() );
+ Charset charset = Charset.forName(f.getCharset());
CharsetDecoder decoder = charset.newDecoder();
// Open the file and then get a channel from the stream
- FileInputStream fis = new FileInputStream( f.getLocation().toFile() );
+ FileInputStream fis = new FileInputStream(f.getLocation().toFile());
fc = fis.getChannel();
// Get the file's size and then map it into memory
- int sz = ( int ) fc.size();
- MappedByteBuffer bb = fc.map( FileChannel.MapMode.READ_ONLY, 0, sz );
+ int sz = (int) fc.size();
+ MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);
// Decode the file into a char buffer
- return decoder.decode( bb );
+ return decoder.decode(bb);
}
-
- public static String[] grep( Pattern pattern, IFile... files ) throws CoreException
+ public static String[] grep(Pattern pattern, IFile... files) throws CoreException
{
LinkedList<String> matches = new LinkedList<String>();
- for ( IFile f : files )
+ for (IFile f : files)
{
try
{
- Grep g = new Grep( f, pattern );
- g.grep( matches );
+ Grep g = new Grep(f, pattern);
+ g.grep(matches);
g.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
- return matches.toArray( new String[matches.size()] );
+ return matches.toArray(new String[matches.size()]);
}
-
private void close() throws IOException
{
fc.close();
}
-
// Use the linePattern to break the given CharBuffer into lines, applying
// the input pattern to each line to see if we have a match
//
- private void grep( List<String> matches )
+ private void grep(List<String> matches)
{
- Matcher lm = linePattern.matcher( cb ); // Line matcher
+ Matcher lm = linePattern.matcher(cb); // Line matcher
Matcher pm = null; // Pattern matcher
int lines = 0;
- while ( lm.find() )
+ while (lm.find())
{
lines++;
CharSequence cs = lm.group(); // The current line
- if ( pm == null )
- pm = pattern.matcher( cs );
+ if (pm == null)
+ pm = pattern.matcher(cs);
else
- pm.reset( cs );
- if ( pm.find() )
- matches.add( pm.group() );
- if ( lm.end() == cb.limit() )
+ pm.reset(cs);
+ if (pm.find())
+ matches.add(pm.group());
+ if (lm.end() == cb.limit())
break;
}
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.model.util;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -94,7 +93,6 @@ import org.eclipse.jdt.core.JavaModelExc
import org.eclipse.jdt.core.Signature;
import org.osgi.framework.Version;
-
/**
* @author dave
*
@@ -102,31 +100,30 @@ import org.osgi.framework.Version;
public class JavaHelper
{
- public static final IAccessRule DENY_RULE = JavaCore.newAccessRule( new Path( "**" ), IAccessRule.K_NON_ACCESSIBLE
- | IAccessRule.IGNORE_IF_BETTER );
+ public static final IAccessRule DENY_RULE = JavaCore.newAccessRule(new Path("**"),
+ IAccessRule.K_NON_ACCESSIBLE | IAccessRule.IGNORE_IF_BETTER);
- public static final IAccessRule ALLOW_ALL_RULE = JavaCore
- .newAccessRule( new Path( "**" ), IAccessRule.K_ACCESSIBLE );
+ public static final IAccessRule ALLOW_ALL_RULE = JavaCore.newAccessRule(
+ new Path("**"), IAccessRule.K_ACCESSIBLE);
private static Map<String, Collection<IClasspathEntry>> entryCache = new HashMap<String, Collection<IClasspathEntry>>();
-
- public static Collection<IClasspathEntry> findClasspathEntries( ISigilBundle bundle )
+ public static Collection<IClasspathEntry> findClasspathEntries(ISigilBundle bundle)
{
LinkedList<IClasspathEntry> cp = new LinkedList<IClasspathEntry>();
- ISigilProjectModel sp = bundle.getAncestor( ISigilProjectModel.class );
+ ISigilProjectModel sp = bundle.getAncestor(ISigilProjectModel.class);
- if ( sp != null )
+ if (sp != null)
{
IJavaProject p = sp.getJavaModel();
- for ( String enc : bundle.getClasspathEntrys() )
+ for (String enc : bundle.getClasspathEntrys())
{
- IClasspathEntry e = p.decodeClasspathEntry( enc );
- if ( e != null )
+ IClasspathEntry e = p.decodeClasspathEntry(enc);
+ if (e != null)
{
- cp.add( e );
+ cp.add(e);
}
}
}
@@ -134,25 +131,24 @@ public class JavaHelper
return cp;
}
-
- public static Collection<ICompilationUnit> findCompilationUnits( ISigilProjectModel project )
- throws JavaModelException
+ public static Collection<ICompilationUnit> findCompilationUnits(
+ ISigilProjectModel project) throws JavaModelException
{
LinkedList<ICompilationUnit> ret = new LinkedList<ICompilationUnit>();
IJavaProject java = project.getJavaModel();
- for ( IClasspathEntry cp : findClasspathEntries( project.getBundle() ) )
+ for (IClasspathEntry cp : findClasspathEntries(project.getBundle()))
{
- IPackageFragmentRoot[] roots = java.findPackageFragmentRoots( cp );
- for ( IPackageFragmentRoot rt : roots )
+ IPackageFragmentRoot[] roots = java.findPackageFragmentRoots(cp);
+ for (IPackageFragmentRoot rt : roots)
{
- for ( IJavaElement j : rt.getChildren() )
+ for (IJavaElement j : rt.getChildren())
{
- IPackageFragment p = ( IPackageFragment ) j;
+ IPackageFragment p = (IPackageFragment) j;
ICompilationUnit[] units = p.getCompilationUnits();
- for ( ICompilationUnit u : units )
+ for (ICompilationUnit u : units)
{
- ret.add( u );
+ ret.add(u);
}
}
}
@@ -161,126 +157,126 @@ public class JavaHelper
return ret;
}
-
/**
* @param project
* @param packageName
* @return
*/
- public static Collection<IPackageExport> findExportsForPackage( ISigilProjectModel project, final String packageName )
+ public static Collection<IPackageExport> findExportsForPackage(
+ ISigilProjectModel project, final String packageName)
{
final LinkedList<IPackageExport> results = new LinkedList<IPackageExport>();
- SigilCore.getRepositoryManager( project ).visit( new IModelWalker()
+ SigilCore.getRepositoryManager(project).visit(new IModelWalker()
{
- public boolean visit( IModelElement element )
+ public boolean visit(IModelElement element)
{
- if ( element instanceof IPackageExport )
+ if (element instanceof IPackageExport)
{
- IPackageExport e = ( IPackageExport ) element;
- if ( e.getPackageName().equals( packageName ) )
+ IPackageExport e = (IPackageExport) element;
+ if (e.getPackageName().equals(packageName))
{
- results.add( e );
+ results.add(e);
}
}
return true;
}
- } );
+ });
return results;
}
-
- public static String[] findUses( String packageName, ISigilProjectModel projectModel ) throws CoreException
+ public static String[] findUses(String packageName, ISigilProjectModel projectModel)
+ throws CoreException
{
ArrayList<String> uses = new ArrayList<String>();
- for ( final String dependency : findPackageDependencies( packageName, projectModel ) )
+ for (final String dependency : findPackageDependencies(packageName, projectModel))
{
- if ( !dependency.equals( packageName ) )
+ if (!dependency.equals(packageName))
{
final boolean[] found = new boolean[1];
- projectModel.visit( new IModelWalker()
+ projectModel.visit(new IModelWalker()
{
- public boolean visit( IModelElement element )
+ public boolean visit(IModelElement element)
{
- if ( element instanceof IPackageImport )
+ if (element instanceof IPackageImport)
{
- IPackageImport pi = ( IPackageImport ) element;
- if ( pi.getPackageName().equals( dependency ) )
+ IPackageImport pi = (IPackageImport) element;
+ if (pi.getPackageName().equals(dependency))
{
found[0] = true;
}
}
return !found[0];
}
- } );
+ });
- if ( found[0] )
+ if (found[0])
{
- uses.add( dependency );
+ uses.add(dependency);
}
}
}
- return uses.toArray( new String[uses.size()] );
+ return uses.toArray(new String[uses.size()]);
}
-
- private static String[] findPackageDependencies( String packageName, ISigilProjectModel projectModel )
- throws CoreException
+ private static String[] findPackageDependencies(String packageName,
+ ISigilProjectModel projectModel) throws CoreException
{
HashSet<String> imports = new HashSet<String>();
- IPackageFragment p = ( IPackageFragment ) projectModel.getJavaModel().findElement(
- new Path( packageName.replace( '.', '/' ) ) );
+ IPackageFragment p = (IPackageFragment) projectModel.getJavaModel().findElement(
+ new Path(packageName.replace('.', '/')));
- if ( p == null )
+ if (p == null)
{
- throw SigilCore.newCoreException( "Unknown package " + packageName, null );
+ throw SigilCore.newCoreException("Unknown package " + packageName, null);
}
- for ( ICompilationUnit cu : p.getCompilationUnits() )
+ for (ICompilationUnit cu : p.getCompilationUnits())
{
- scanImports( cu, imports );
+ scanImports(cu, imports);
}
- for ( IClassFile cf : p.getClassFiles() )
+ for (IClassFile cf : p.getClassFiles())
{
- scanImports( cf, imports );
+ scanImports(cf, imports);
}
- return imports.toArray( new String[imports.size()] );
+ return imports.toArray(new String[imports.size()]);
}
-
/**
* @param project
* @param monitor
* @return
*/
- public static List<IPackageImport> findRequiredImports( ISigilProjectModel project, IProgressMonitor monitor )
+ public static List<IPackageImport> findRequiredImports(ISigilProjectModel project,
+ IProgressMonitor monitor)
{
LinkedList<IPackageImport> imports = new LinkedList<IPackageImport>();
- for ( String packageName : findJavaImports( project, monitor ) )
+ for (String packageName : findJavaImports(project, monitor))
{
- if ( !ProfileManager.isBootDelegate( project, packageName ) )
+ if (!ProfileManager.isBootDelegate(project, packageName))
{ // these must come from boot classloader
try
{
- if ( !project.isInClasspath( packageName, monitor ) )
+ if (!project.isInClasspath(packageName, monitor))
{
- Collection<IPackageExport> exports = findExportsForPackage( project, packageName );
- if ( !exports.isEmpty() )
+ Collection<IPackageExport> exports = findExportsForPackage(
+ project, packageName);
+ if (!exports.isEmpty())
{
- imports.add( select( exports ) );
+ imports.add(select(exports));
}
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to check classpath", e );
+ SigilCore.error("Failed to check classpath", e);
}
}
}
@@ -288,171 +284,175 @@ public class JavaHelper
return imports;
}
-
/**
* @param project
* @param monitor
* @return
*/
- public static Collection<IModelElement> findUnusedReferences( final ISigilProjectModel project,
- final IProgressMonitor monitor )
+ public static Collection<IModelElement> findUnusedReferences(
+ final ISigilProjectModel project, final IProgressMonitor monitor)
{
final LinkedList<IModelElement> unused = new LinkedList<IModelElement>();
- final Set<String> packages = findJavaImports( project, monitor );
+ final Set<String> packages = findJavaImports(project, monitor);
- project.visit( new IModelWalker()
+ project.visit(new IModelWalker()
{
- public boolean visit( IModelElement element )
+ public boolean visit(IModelElement element)
{
- if ( element instanceof IPackageImport )
+ if (element instanceof IPackageImport)
{
- IPackageImport pi = ( IPackageImport ) element;
- if ( !packages.contains( pi.getPackageName() ) )
+ IPackageImport pi = (IPackageImport) element;
+ if (!packages.contains(pi.getPackageName()))
{
- unused.add( pi );
+ unused.add(pi);
}
}
- else if ( element instanceof IRequiredBundle )
+ else if (element instanceof IRequiredBundle)
{
- IRequiredBundle rb = ( IRequiredBundle ) element;
- IRepositoryManager manager = SigilCore.getRepositoryManager( project );
- ResolutionConfig config = new ResolutionConfig( ResolutionConfig.INCLUDE_OPTIONAL
- | ResolutionConfig.IGNORE_ERRORS );
+ IRequiredBundle rb = (IRequiredBundle) element;
+ IRepositoryManager manager = SigilCore.getRepositoryManager(project);
+ ResolutionConfig config = new ResolutionConfig(
+ ResolutionConfig.INCLUDE_OPTIONAL
+ | ResolutionConfig.IGNORE_ERRORS);
try
{
- IResolution r = manager.getBundleResolver().resolve( rb, config,
- new ResolutionMonitorAdapter( monitor ) );
- ISigilBundle bundle = r.getProvider( rb );
+ IResolution r = manager.getBundleResolver().resolve(rb, config,
+ new ResolutionMonitorAdapter(monitor));
+ ISigilBundle bundle = r.getProvider(rb);
boolean found = false;
- for ( IPackageExport pe : bundle.getBundleInfo().getExports() )
+ for (IPackageExport pe : bundle.getBundleInfo().getExports())
{
- if ( packages.contains( pe.getPackageName() ) )
+ if (packages.contains(pe.getPackageName()))
{
found = true;
break;
}
}
- if ( !found )
+ if (!found)
{
- unused.add( rb );
+ unused.add(rb);
}
}
- catch ( ResolutionException e )
+ catch (ResolutionException e)
{
- SigilCore.error( "Failed to resolve " + rb, e );
+ SigilCore.error("Failed to resolve " + rb, e);
}
}
return true;
}
- } );
+ });
return unused;
}
-
- public static Collection<IClasspathEntry> resolveClasspathEntrys( ISigilProjectModel sigil,
- IProgressMonitor monitor ) throws CoreException
+ public static Collection<IClasspathEntry> resolveClasspathEntrys(
+ ISigilProjectModel sigil, IProgressMonitor monitor) throws CoreException
{
- if ( monitor == null )
+ if (monitor == null)
{
monitor = Job.getJobManager().createProgressGroup();
- monitor.beginTask( "Resolving classpath for " + sigil.getSymbolicName(), 2 );
+ monitor.beginTask("Resolving classpath for " + sigil.getSymbolicName(), 2);
}
ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
- ResolutionConfig config = new ResolutionConfig( ResolutionConfig.INCLUDE_OPTIONAL
- | ResolutionConfig.IGNORE_ERRORS | ResolutionConfig.INDEXED_ONLY | ResolutionConfig.LOCAL_ONLY | ResolutionConfig.COMPILE_TIME );
+ ResolutionConfig config = new ResolutionConfig(ResolutionConfig.INCLUDE_OPTIONAL
+ | ResolutionConfig.IGNORE_ERRORS | ResolutionConfig.INDEXED_ONLY
+ | ResolutionConfig.LOCAL_ONLY | ResolutionConfig.COMPILE_TIME);
IResolution resolution;
try
{
- resolution = SigilCore.getRepositoryManager( sigil ).getBundleResolver().resolve( sigil, config,
- new ResolutionMonitorAdapter( monitor ) );
+ resolution = SigilCore.getRepositoryManager(sigil).getBundleResolver().resolve(
+ sigil, config, new ResolutionMonitorAdapter(monitor));
}
- catch ( ResolutionException e )
+ catch (ResolutionException e)
{
- throw SigilCore.newCoreException( "Failed to resolve dependencies", e );
+ throw SigilCore.newCoreException("Failed to resolve dependencies", e);
}
- monitor.worked( 1 );
+ monitor.worked(1);
Set<ISigilBundle> bundles = resolution.getBundles();
- for ( ISigilBundle bundle : bundles )
+ for (ISigilBundle bundle : bundles)
{
- if ( !sigil.getSymbolicName().equals(bundle.getBundleInfo().getSymbolicName()) )
+ if (!sigil.getSymbolicName().equals(bundle.getBundleInfo().getSymbolicName()))
{ // discard self reference...
- List<IModelElement> matched = resolution.getMatchedRequirements( bundle );
- for ( IClasspathEntry cpe : buildClassPathEntry( sigil, bundle, bundles, matched, monitor ) )
+ List<IModelElement> matched = resolution.getMatchedRequirements(bundle);
+ for (IClasspathEntry cpe : buildClassPathEntry(sigil, bundle, bundles,
+ matched, monitor))
{
- entries.add( cpe );
+ entries.add(cpe);
}
}
}
- Collections.sort( entries, new Comparator<IClasspathEntry>()
+ Collections.sort(entries, new Comparator<IClasspathEntry>()
{
- public int compare( IClasspathEntry o1, IClasspathEntry o2 )
+ public int compare(IClasspathEntry o1, IClasspathEntry o2)
{
- return o1.toString().compareTo( o2.toString() );
+ return o1.toString().compareTo(o2.toString());
}
- } );
+ });
- monitor.worked( 1 );
+ monitor.worked(1);
monitor.done();
return entries;
}
-
- private static Collection<IClasspathEntry> buildClassPathEntry( ISigilProjectModel project, ISigilBundle provider,
- Set<ISigilBundle> all, List<IModelElement> requirements, IProgressMonitor monitor ) throws CoreException
+ private static Collection<IClasspathEntry> buildClassPathEntry(
+ ISigilProjectModel project, ISigilBundle provider, Set<ISigilBundle> all,
+ List<IModelElement> requirements, IProgressMonitor monitor) throws CoreException
{
- IAccessRule[] rules = buildAccessRules( project, provider, all, requirements );
+ IAccessRule[] rules = buildAccessRules(project, provider, all, requirements);
IClasspathAttribute[] attrs = new IClasspathAttribute[0];
- ISigilProjectModel other = provider.getAncestor( ISigilProjectModel.class );
+ ISigilProjectModel other = provider.getAncestor(ISigilProjectModel.class);
try
{
- if ( other == null )
+ if (other == null)
{
- provider.synchronize( monitor );
- return newBundleEntry( provider, rules, attrs, false );
+ provider.synchronize(monitor);
+ return newBundleEntry(provider, rules, attrs, false);
}
else
{
- return newProjectEntry( other, rules, attrs, false );
+ return newProjectEntry(other, rules, attrs, false);
}
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw SigilCore.newCoreException( "Failed to synchronize " + provider, e );
+ throw SigilCore.newCoreException("Failed to synchronize " + provider, e);
}
}
-
- private static Collection<IClasspathEntry> newProjectEntry( ISigilProjectModel n, IAccessRule[] rules,
- IClasspathAttribute[] attributes, boolean export ) throws CoreException
+ private static Collection<IClasspathEntry> newProjectEntry(ISigilProjectModel n,
+ IAccessRule[] rules, IClasspathAttribute[] attributes, boolean export)
+ throws CoreException
{
ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
- entries.add( JavaCore.newProjectEntry( n.getProject().getFullPath(), rules, false, attributes, export ) );
- for ( IClasspathEntry e : n.getJavaModel().getRawClasspath() )
+ entries.add(JavaCore.newProjectEntry(n.getProject().getFullPath(), rules, false,
+ attributes, export));
+ for (IClasspathEntry e : n.getJavaModel().getRawClasspath())
{
- switch ( e.getEntryKind() )
+ switch (e.getEntryKind())
{
case IClasspathEntry.CPE_LIBRARY:
- entries.add( JavaCore.newLibraryEntry( e.getPath(), e.getSourceAttachmentPath(), e
- .getSourceAttachmentRootPath(), rules, attributes, export ) );
+ entries.add(JavaCore.newLibraryEntry(e.getPath(),
+ e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(),
+ rules, attributes, export));
break;
case IClasspathEntry.CPE_VARIABLE:
- IPath path = JavaCore.getResolvedVariablePath( e.getPath() );
- if ( path != null )
+ IPath path = JavaCore.getResolvedVariablePath(e.getPath());
+ if (path != null)
{
- entries.add( JavaCore.newLibraryEntry( path, e.getSourceAttachmentPath(), e
- .getSourceAttachmentRootPath(), rules, attributes, export ) );
+ entries.add(JavaCore.newLibraryEntry(path,
+ e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(),
+ rules, attributes, export));
}
break;
}
@@ -461,13 +461,13 @@ public class JavaHelper
return entries;
}
-
- private static Collection<IClasspathEntry> newBundleEntry( ISigilBundle bundle, IAccessRule[] rules,
- IClasspathAttribute[] attributes, boolean exported ) throws CoreException
+ private static Collection<IClasspathEntry> newBundleEntry(ISigilBundle bundle,
+ IAccessRule[] rules, IClasspathAttribute[] attributes, boolean exported)
+ throws CoreException
{
String name = bundle.getBundleInfo().getSymbolicName();
- if ( bundle.getBundleInfo().getVersion() != null )
+ if (bundle.getBundleInfo().getVersion() != null)
{
name += "_version_" + bundle.getBundleInfo().getVersion();
}
@@ -476,148 +476,150 @@ public class JavaHelper
Collection<IClasspathEntry> entries = null;
- synchronized ( entryCache )
+ synchronized (entryCache)
{
- entries = entryCache.get( cacheName );
+ entries = entryCache.get(cacheName);
- if ( entries == null )
+ if (entries == null)
{
IPath path = PathUtil.newPathIfExists(bundle.getLocation());
- if ( path == null )
+ if (path == null)
{
- SigilCore.error( "Found null path for " + bundle.getSymbolicName() );
+ SigilCore.error("Found null path for " + bundle.getSymbolicName());
entries = Collections.emptyList();
}
else
{
- entries = buildEntries( path, name, bundle, rules, attributes, exported );
+ entries = buildEntries(path, name, bundle, rules, attributes,
+ exported);
}
- entryCache.put( cacheName, entries );
+ entryCache.put(cacheName, entries);
}
}
return entries;
}
- private static IPath bundleCache = SigilCore.getDefault().getStateLocation().append( "bundle-cache" );
-
+ private static IPath bundleCache = SigilCore.getDefault().getStateLocation().append(
+ "bundle-cache");
- public static boolean isCachedBundle( String bp )
+ public static boolean isCachedBundle(String bp)
{
- return bp.startsWith( bundleCache.toOSString() );
+ return bp.startsWith(bundleCache.toOSString());
}
-
- private static Collection<IClasspathEntry> buildEntries( IPath path, String name, ISigilBundle bundle,
- IAccessRule[] rules, IClasspathAttribute[] attributes, boolean exported ) throws CoreException
+ private static Collection<IClasspathEntry> buildEntries(IPath path, String name,
+ ISigilBundle bundle, IAccessRule[] rules, IClasspathAttribute[] attributes,
+ boolean exported) throws CoreException
{
- if ( path.toFile().isDirectory() )
+ if (path.toFile().isDirectory())
{
- throw SigilCore.newCoreException( "Bundle location cannot be a directory", null );
+ throw SigilCore.newCoreException("Bundle location cannot be a directory",
+ null);
}
else
{
// ok it's a jar could contain libs etc
try
{
- IPath cache = bundleCache.append( name );
+ IPath cache = bundleCache.append(name);
Collection<String> classpath = bundle.getBundleInfo().getClasspaths();
- ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>( classpath.size() );
+ ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(
+ classpath.size());
IPath source = PathUtil.newPathIfExists(bundle.getSourcePathLocation());
IPath rootPath = PathUtil.newPathIfNotNull(bundle.getSourceRootPath());
- if ( source != null && !source.toFile().exists() )
+ if (source != null && !source.toFile().exists())
{
source = null;
}
- if ( !classpath.isEmpty() )
+ if (!classpath.isEmpty())
{
- unpack( cache, bundle, classpath );
- for ( String cp : classpath )
+ unpack(cache, bundle, classpath);
+ for (String cp : classpath)
{
- IPath p = ".".equals( cp ) ? path : cache.append( cp );
- if ( p.toFile().exists() )
+ IPath p = ".".equals(cp) ? path : cache.append(cp);
+ if (p.toFile().exists())
{
- IClasspathEntry e = JavaCore.newLibraryEntry( p, source, rootPath, rules,
- attributes, exported );
- entries.add( e );
+ IClasspathEntry e = JavaCore.newLibraryEntry(p, source,
+ rootPath, rules, attributes, exported);
+ entries.add(e);
}
}
}
else
{ // default classpath is .
- IClasspathEntry e = JavaCore.newLibraryEntry( path, source, rootPath, rules,
- attributes, exported );
- entries.add( e );
+ IClasspathEntry e = JavaCore.newLibraryEntry(path, source, rootPath,
+ rules, attributes, exported);
+ entries.add(e);
}
return entries;
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw SigilCore.newCoreException( "Failed to unpack bundle", e );
+ throw SigilCore.newCoreException("Failed to unpack bundle", e);
}
}
}
private static HashMap<IPath, Collection<String>> unpacked = new HashMap<IPath, Collection<String>>();
-
- private static synchronized void unpack( IPath cache, ISigilBundle bundle, Collection<String> classpath )
- throws IOException
+ private static synchronized void unpack(IPath cache, ISigilBundle bundle,
+ Collection<String> classpath) throws IOException
{
- Collection<String> check = unpacked.get( cache );
+ Collection<String> check = unpacked.get(cache);
- if ( check == null || !check.equals( classpath ) )
+ if (check == null || !check.equals(classpath))
{
- if ( classpath.size() == 1 && classpath.contains( "." ) )
+ if (classpath.size() == 1 && classpath.contains("."))
{
- unpacked.put( cache, classpath );
+ unpacked.put(cache, classpath);
}
else
{
// trim . from path to avoid check later in inClasspath
- check = new HashSet<String>( classpath );
- check.remove( "." );
+ check = new HashSet<String>(classpath);
+ check.remove(".");
- File dir = createEmptyDir( cache );
+ File dir = createEmptyDir(cache);
FileInputStream fin = null;
try
{
- fin = new FileInputStream( bundle.getLocation() );
- JarInputStream in = new JarInputStream( fin );
+ fin = new FileInputStream(bundle.getLocation());
+ JarInputStream in = new JarInputStream(fin);
JarEntry entry;
- while ( ( entry = in.getNextJarEntry() ) != null )
+ while ((entry = in.getNextJarEntry()) != null)
{
- if ( inClasspath( check, entry ) )
+ if (inClasspath(check, entry))
{
- File f = new File( dir, entry.getName() );
- if ( entry.isDirectory() )
+ File f = new File(dir, entry.getName());
+ if (entry.isDirectory())
{
- createDir( f );
+ createDir(f);
}
else
{
try
{
File p = f.getParentFile();
- createDir( p );
- streamTo( in, f );
+ createDir(p);
+ streamTo(in, f);
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
- SigilCore.error( "Failed to unpack " + entry, e );
+ SigilCore.error("Failed to unpack " + entry, e);
}
}
}
}
- unpacked.put( cache, classpath );
+ unpacked.put(cache, classpath);
}
finally
{
- if ( fin != null )
+ if (fin != null)
{
fin.close();
}
@@ -626,17 +628,16 @@ public class JavaHelper
}
}
-
/**
* @param classpath
* @param entry
* @return
*/
- private static boolean inClasspath( Collection<String> classpath, JarEntry entry )
+ private static boolean inClasspath(Collection<String> classpath, JarEntry entry)
{
- for ( String s : classpath )
+ for (String s : classpath)
{
- if ( entry.getName().startsWith( s ) )
+ if (entry.getName().startsWith(s))
{
return true;
}
@@ -644,31 +645,29 @@ public class JavaHelper
return false;
}
-
- private static void createDir( File p ) throws IOException
+ private static void createDir(File p) throws IOException
{
- if ( !p.exists() )
+ if (!p.exists())
{
- if ( !p.mkdirs() )
- throw new IOException( "Failed to create directory " + p );
+ if (!p.mkdirs())
+ throw new IOException("Failed to create directory " + p);
}
}
-
- private static void streamTo( InputStream in, File f ) throws IOException
+ private static void streamTo(InputStream in, File f) throws IOException
{
- FileOutputStream fos = new FileOutputStream( f );
+ FileOutputStream fos = new FileOutputStream(f);
try
{
byte[] buf = new byte[1024];
- for ( ;; )
+ for (;;)
{
- int r = in.read( buf );
+ int r = in.read(buf);
- if ( r == -1 )
+ if (r == -1)
break;
- fos.write( buf, 0, r );
+ fos.write(buf, 0, r);
}
fos.flush();
@@ -679,101 +678,98 @@ public class JavaHelper
{
fos.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
- SigilCore.error( "Failed to close stream", e );
+ SigilCore.error("Failed to close stream", e);
}
}
}
-
- private static File createEmptyDir( IPath cache )
+ private static File createEmptyDir(IPath cache)
{
File dir = cache.toFile();
- if ( dir.exists() )
+ if (dir.exists())
{
- deleteAll( dir );
+ deleteAll(dir);
}
dir.mkdirs();
return dir;
}
-
- private static void deleteAll( File file )
+ private static void deleteAll(File file)
{
File[] sub = file.listFiles();
- if ( sub != null )
+ if (sub != null)
{
- for ( File f : sub )
+ for (File f : sub)
{
- deleteAll( f );
+ deleteAll(f);
}
}
file.delete();
}
-
- private static IAccessRule[] buildAccessRules( ISigilProjectModel project, ISigilBundle bundle,
- Set<ISigilBundle> all, List<IModelElement> requirements ) throws JavaModelException
+ private static IAccessRule[] buildAccessRules(ISigilProjectModel project,
+ ISigilBundle bundle, Set<ISigilBundle> all, List<IModelElement> requirements)
+ throws JavaModelException
{
ArrayList<IAccessRule> rules = new ArrayList<IAccessRule>();
- for ( IModelElement e : requirements )
+ for (IModelElement e : requirements)
{
- if ( e instanceof IRequiredBundle )
+ if (e instanceof IRequiredBundle)
{
IRequiredBundle host = project.getBundle().getBundleInfo().getFragmentHost();
- if ( host != null )
+ if (host != null)
{
- if ( host.equals( e ) )
+ if (host.equals(e))
{
- return new IAccessRule[]
- { ALLOW_ALL_RULE };
+ return new IAccessRule[] { ALLOW_ALL_RULE };
}
else
{
- return buildExportRules( bundle, all, requirements );
+ return buildExportRules(bundle, all, requirements);
}
}
else
{
- return buildExportRules( bundle, all, requirements );
+ return buildExportRules(bundle, all, requirements);
}
}
- else if ( e instanceof IPackageImport )
+ else if (e instanceof IPackageImport)
{
- IPackageImport pi = ( IPackageImport ) e;
+ IPackageImport pi = (IPackageImport) e;
String pckg = pi.getPackageName();
HashSet<String> pckgs = new HashSet<String>();
- pckgs.add( pckg );
+ pckgs.add(pckg);
//findIndirectReferences(pckgs, pckg, project.getJavaModel(), project.getJavaModel());
- for ( String p : pckgs )
+ for (String p : pckgs)
{
- rules.add( newPackageAccess( p ) );
+ rules.add(newPackageAccess(p));
}
}
}
- rules.add( DENY_RULE );
+ rules.add(DENY_RULE);
- return rules.toArray( new IAccessRule[rules.size()] );
+ return rules.toArray(new IAccessRule[rules.size()]);
}
-
- private static IAccessRule[] buildExportRules( ISigilBundle bundle, Set<ISigilBundle> all,
- List<IModelElement> requirements )
+
+ private static IAccessRule[] buildExportRules(ISigilBundle bundle,
+ Set<ISigilBundle> all, List<IModelElement> requirements)
{
- Set<IPackageExport> ex = mergeExports( bundle, all, requirements );
+ Set<IPackageExport> ex = mergeExports(bundle, all, requirements);
IAccessRule[] rules = new IAccessRule[ex.size() + 1];
Iterator<IPackageExport> iter = ex.iterator();
- for ( int i = 0; i < rules.length - 1; i++ )
+ for (int i = 0; i < rules.length - 1; i++)
{
IPackageExport p = iter.next();
- rules[i] = JavaCore.newAccessRule( new Path( p.getPackageName().replace( '.', '/' ) ).append( "*" ),
- IAccessRule.K_ACCESSIBLE );
+ rules[i] = JavaCore.newAccessRule(new Path(p.getPackageName().replace('.',
+ '/')).append("*"), IAccessRule.K_ACCESSIBLE);
}
rules[rules.length - 1] = DENY_RULE;
@@ -781,224 +777,218 @@ public class JavaHelper
return rules;
}
-
- private static Set<IPackageExport> mergeExports( ISigilBundle bundle, Set<ISigilBundle> all,
- List<IModelElement> requirements )
+ private static Set<IPackageExport> mergeExports(ISigilBundle bundle,
+ Set<ISigilBundle> all, List<IModelElement> requirements)
{
IBundleModelElement headers = bundle.getBundleInfo();
// FIXME treeset as PackageExport does not implement equals/hashCode
- TreeSet<IPackageExport> exports = new TreeSet<IPackageExport>( headers.getExports() );
+ TreeSet<IPackageExport> exports = new TreeSet<IPackageExport>(
+ headers.getExports());
IRequiredBundle host = headers.getFragmentHost();
- if ( host != null )
+ if (host != null)
{
- for ( ISigilBundle b : all )
+ for (ISigilBundle b : all)
{
- if ( host.accepts( b.getBundleCapability() ) )
+ if (host.accepts(b.getBundleCapability()))
{
- exports.addAll( b.getBundleInfo().getExports() );
+ exports.addAll(b.getBundleInfo().getExports());
break;
}
}
}
return exports;
- }
-
+ }
/*
* Searches for C (and D, E, etc) in case:
* A extends B extends C where A, B and C are in different packages and A is in this bundle
* and B and C are in one or more external bundles
*/
- private static void findIndirectReferences( Set<String> indirect, String pckg, IParent parent, IJavaProject p )
- throws JavaModelException
+ private static void findIndirectReferences(Set<String> indirect, String pckg,
+ IParent parent, IJavaProject p) throws JavaModelException
{
- for ( IJavaElement e : parent.getChildren() )
+ for (IJavaElement e : parent.getChildren())
{
boolean skip = false;
- switch ( e.getElementType() )
+ switch (e.getElementType())
{
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
- IPackageFragmentRoot rt = ( IPackageFragmentRoot ) e;
+ IPackageFragmentRoot rt = (IPackageFragmentRoot) e;
IClasspathEntry ce = rt.getRawClasspathEntry();
IPath path = ce.getPath();
- skip = "org.eclipse.jdt.launching.JRE_CONTAINER".equals( path.toString() );
+ skip = "org.eclipse.jdt.launching.JRE_CONTAINER".equals(path.toString());
break;
case IJavaElement.CLASS_FILE:
- IClassFile cf = ( IClassFile ) e;
- if ( cf.getElementName().startsWith( pckg ) )
+ IClassFile cf = (IClassFile) e;
+ if (cf.getElementName().startsWith(pckg))
{
- findIndirectReferences( indirect, findPackage( cf.getType().getSuperclassName() ), p, p );
+ findIndirectReferences(indirect,
+ findPackage(cf.getType().getSuperclassName()), p, p);
}
break;
case IJavaElement.COMPILATION_UNIT:
- ICompilationUnit cu = ( ICompilationUnit ) e;
+ ICompilationUnit cu = (ICompilationUnit) e;
break;
}
- if ( !skip && e instanceof IParent )
+ if (!skip && e instanceof IParent)
{
- IParent newParent = ( IParent ) e;
- findIndirectReferences( indirect, pckg, newParent, p );
+ IParent newParent = (IParent) e;
+ findIndirectReferences(indirect, pckg, newParent, p);
}
}
}
-
- private static IAccessRule newPackageAccess( String packageName )
+ private static IAccessRule newPackageAccess(String packageName)
{
- return JavaCore.newAccessRule( new Path( packageName.replace( '.', '/' ) ).append( "*" ),
- IAccessRule.K_ACCESSIBLE );
+ return JavaCore.newAccessRule(
+ new Path(packageName.replace('.', '/')).append("*"), IAccessRule.K_ACCESSIBLE);
}
-
- private static Set<String> findJavaImports( ISigilProjectModel project, IProgressMonitor monitor )
+ private static Set<String> findJavaImports(ISigilProjectModel project,
+ IProgressMonitor monitor)
{
Set<String> imports = new HashSet<String>();
- findJavaModelImports( project, imports, monitor );
- findTextImports( project, imports, monitor );
+ findJavaModelImports(project, imports, monitor);
+ findTextImports(project, imports, monitor);
return imports;
}
-
- private static void findTextImports( ISigilProjectModel project, Set<String> imports, IProgressMonitor monitor )
+ private static void findTextImports(ISigilProjectModel project, Set<String> imports,
+ IProgressMonitor monitor)
{
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
- IContentType txt = contentTypeManager.getContentType( "org.eclipse.core.runtime.text" );
- for ( Resource p : project.getBundle().getSourcePaths() )
+ IContentType txt = contentTypeManager.getContentType("org.eclipse.core.runtime.text");
+ for (Resource p : project.getBundle().getSourcePaths())
{
- IFile f = project.getProject().getFile( p.getLocalFile() );
- if ( f.exists() )
+ IFile f = project.getProject().getFile(p.getLocalFile());
+ if (f.exists())
{
try
{
IContentDescription desc = f.getContentDescription();
- if ( desc != null )
+ if (desc != null)
{
IContentType type = desc.getContentType();
- if ( type != null )
+ if (type != null)
{
- if ( type.isKindOf( txt ) )
+ if (type.isKindOf(txt))
{
- parseText( f, imports );
+ parseText(f, imports);
}
}
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to parse text file " + f, e );
+ SigilCore.error("Failed to parse text file " + f, e);
}
}
}
}
-
- private static void findJavaModelImports( ISigilProjectModel project, Set<String> imports, IProgressMonitor monitor )
+ private static void findJavaModelImports(ISigilProjectModel project,
+ Set<String> imports, IProgressMonitor monitor)
{
try
{
- for ( IPackageFragment root : project.getJavaModel().getPackageFragments() )
+ for (IPackageFragment root : project.getJavaModel().getPackageFragments())
{
- IPackageFragmentRoot rt = ( IPackageFragmentRoot ) root
- .getAncestor( IJavaElement.PACKAGE_FRAGMENT_ROOT );
+ IPackageFragmentRoot rt = (IPackageFragmentRoot) root.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
- if ( isInClassPath( project, rt ) )
+ if (isInClassPath(project, rt))
{
- for ( ICompilationUnit cu : root.getCompilationUnits() )
+ for (ICompilationUnit cu : root.getCompilationUnits())
{
- scanImports( cu, imports );
+ scanImports(cu, imports);
}
- for ( IClassFile cf : root.getClassFiles() )
+ for (IClassFile cf : root.getClassFiles())
{
- scanImports( cf, imports );
+ scanImports(cf, imports);
}
}
}
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
- SigilCore.error( "Failed to parse java model", e );
+ SigilCore.error("Failed to parse java model", e);
}
}
// matches word.word.word.word.Word
- private static final Pattern JAVA_CLASS_PATTERN = Pattern.compile( "((\\w*\\.\\w*)+?)\\.[A-Z]\\w*" );
-
+ private static final Pattern JAVA_CLASS_PATTERN = Pattern.compile("((\\w*\\.\\w*)+?)\\.[A-Z]\\w*");
- private static void parseText( IFile f, Set<String> imports ) throws CoreException
+ private static void parseText(IFile f, Set<String> imports) throws CoreException
{
- for ( String result : Grep.grep( JAVA_CLASS_PATTERN, f ) )
+ for (String result : Grep.grep(JAVA_CLASS_PATTERN, f))
{
- findImport( result, imports );
+ findImport(result, imports);
}
}
-
- private static boolean isInClassPath( ISigilProjectModel project, IPackageFragmentRoot rt )
- throws JavaModelException
+ private static boolean isInClassPath(ISigilProjectModel project,
+ IPackageFragmentRoot rt) throws JavaModelException
{
- String path = encode( project, rt.getRawClasspathEntry() );
- return project.getBundle().getClasspathEntrys().contains( path );
+ String path = encode(project, rt.getRawClasspathEntry());
+ return project.getBundle().getClasspathEntrys().contains(path);
}
-
- private static String encode( ISigilProjectModel project, IClasspathEntry cp )
+ private static String encode(ISigilProjectModel project, IClasspathEntry cp)
{
- return project.getJavaModel().encodeClasspathEntry( cp ).trim();
+ return project.getJavaModel().encodeClasspathEntry(cp).trim();
}
-
- private static void scanImports( IParent parent, Set<String> imports ) throws JavaModelException
+ private static void scanImports(IParent parent, Set<String> imports)
+ throws JavaModelException
{
- for ( IJavaElement e : parent.getChildren() )
+ for (IJavaElement e : parent.getChildren())
{
- switch ( e.getElementType() )
+ switch (e.getElementType())
{
case IJavaElement.TYPE:
- handleType( ( IType ) e, imports );
+ handleType((IType) e, imports);
break;
case IJavaElement.IMPORT_DECLARATION:
- handleImport( ( IImportDeclaration ) e, imports );
+ handleImport((IImportDeclaration) e, imports);
break;
case IJavaElement.FIELD:
- handleField( ( IField ) e, imports );
+ handleField((IField) e, imports);
break;
case IJavaElement.LOCAL_VARIABLE:
- handleLocalVariable( ( ILocalVariable ) e, imports );
+ handleLocalVariable((ILocalVariable) e, imports);
break;
case IJavaElement.ANNOTATION:
- handleAnnotation( ( IAnnotation ) e, imports );
+ handleAnnotation((IAnnotation) e, imports);
break;
case IJavaElement.METHOD:
- handleMethod( ( IMethod ) e, imports );
+ handleMethod((IMethod) e, imports);
break;
default:
// no action
break;
}
- if ( e instanceof IParent )
+ if (e instanceof IParent)
{
- scanImports( ( IParent ) e, imports );
+ scanImports((IParent) e, imports);
}
}
}
-
- private static void handleType( IType e, Set<String> imports ) throws JavaModelException
+ private static void handleType(IType e, Set<String> imports)
+ throws JavaModelException
{
- findImportFromType( e.getSuperclassTypeSignature(), imports );
- for ( String sig : e.getSuperInterfaceTypeSignatures() )
+ findImportFromType(e.getSuperclassTypeSignature(), imports);
+ for (String sig : e.getSuperInterfaceTypeSignatures())
{
- findImportFromType( sig, imports );
+ findImportFromType(sig, imports);
}
//findImportsForSuperTypes(e, imports);
}
-
/*private static void findImportsForSuperTypes(IType e, Set<String> imports) throws JavaModelException {
IJavaProject project = (IJavaProject) e.getAncestor(IJavaModel.JAVA_PROJECT);
LinkedList<String> types = new LinkedList<String>();
@@ -1026,125 +1016,114 @@ public class JavaHelper
}
} */
- private static void handleMethod( IMethod e, Set<String> imports ) throws JavaModelException
+ private static void handleMethod(IMethod e, Set<String> imports)
+ throws JavaModelException
{
- findImportFromType( e.getReturnType(), imports );
+ findImportFromType(e.getReturnType(), imports);
- for ( String param : e.getParameterTypes() )
+ for (String param : e.getParameterTypes())
{
- findImportFromType( param, imports );
+ findImportFromType(param, imports);
}
- for ( String ex : e.getExceptionTypes() )
+ for (String ex : e.getExceptionTypes())
{
- findImportFromType( ex, imports );
+ findImportFromType(ex, imports);
}
}
-
- private static void handleAnnotation( IAnnotation e, Set<String> imports )
+ private static void handleAnnotation(IAnnotation e, Set<String> imports)
{
- findImport( e.getElementName(), imports );
+ findImport(e.getElementName(), imports);
}
-
- private static void handleLocalVariable( ILocalVariable e, Set<String> imports )
+ private static void handleLocalVariable(ILocalVariable e, Set<String> imports)
{
- findImportFromType( e.getTypeSignature(), imports );
+ findImportFromType(e.getTypeSignature(), imports);
}
-
- private static void handleField( IField e, Set<String> imports ) throws IllegalArgumentException,
- JavaModelException
+ private static void handleField(IField e, Set<String> imports)
+ throws IllegalArgumentException, JavaModelException
{
- findImportFromType( Signature.getElementType( e.getTypeSignature() ), imports );
+ findImportFromType(Signature.getElementType(e.getTypeSignature()), imports);
}
-
- private static void handleImport( IImportDeclaration id, Set<String> imports )
+ private static void handleImport(IImportDeclaration id, Set<String> imports)
{
- findImport( id.getElementName(), imports );
+ findImport(id.getElementName(), imports);
}
-
- private static void findImportFromType( String type, Set<String> imports )
+ private static void findImportFromType(String type, Set<String> imports)
{
- String element = decodeSignature( type );
- findImport( element, imports );
+ String element = decodeSignature(type);
+ findImport(element, imports);
}
-
- private static String decodeSignature( String type )
+ private static String decodeSignature(String type)
{
- return decodeSignature( type, false );
+ return decodeSignature(type, false);
}
-
- private static String decodeSignature( String type, boolean resolve )
+ private static String decodeSignature(String type, boolean resolve)
{
- if ( type == null )
+ if (type == null)
{
return null;
}
- if ( type.length() > 0 )
+ if (type.length() > 0)
{
- switch ( type.charAt( 0 ) )
+ switch (type.charAt(0))
{
case Signature.C_ARRAY:
- return decodeSignature( type.substring( 1 ) );
+ return decodeSignature(type.substring(1));
case Signature.C_UNRESOLVED:
- return resolve ? resolve( type.substring( 1, type.length() - 1 ) ) : null;
+ return resolve ? resolve(type.substring(1, type.length() - 1)) : null;
case Signature.C_RESOLVED:
- return type.substring( 1 );
+ return type.substring(1);
}
}
return type;
}
-
- private static String resolve( String substring )
+ private static String resolve(String substring)
{
// TODO Auto-generated method stub
return null;
}
-
- private static void findImport( String clazz, Set<String> imports )
+ private static void findImport(String clazz, Set<String> imports)
{
- String packageName = findPackage( clazz );
- if ( packageName != null )
+ String packageName = findPackage(clazz);
+ if (packageName != null)
{
- imports.add( packageName );
+ imports.add(packageName);
}
}
-
- private static String findPackage( String clazz )
+ private static String findPackage(String clazz)
{
- if ( clazz == null )
+ if (clazz == null)
return null;
- int pos = clazz.lastIndexOf( '.' );
- return pos == -1 ? null : clazz.substring( 0, pos );
+ int pos = clazz.lastIndexOf('.');
+ return pos == -1 ? null : clazz.substring(0, pos);
}
-
- private static String findClass( String clazz )
+ private static String findClass(String clazz)
{
- if ( clazz == null )
+ if (clazz == null)
return null;
- int pos = clazz.lastIndexOf( '.' );
- return pos == -1 ? null : clazz.substring( pos + 1 );
+ int pos = clazz.lastIndexOf('.');
+ return pos == -1 ? null : clazz.substring(pos + 1);
}
-
- private static IPackageImport select( Collection<IPackageExport> proposals )
+ private static IPackageImport select(Collection<IPackageExport> proposals)
{
IPackageExport pe = null;
- for ( IPackageExport check : proposals )
+ for (IPackageExport check : proposals)
{
- if ( pe == null || check.getVersion().compareTo( pe.getVersion() ) > 0 )
+ if (pe == null || check.getVersion().compareTo(pe.getVersion()) > 0)
{
pe = check;
}
@@ -1155,56 +1134,55 @@ public class JavaHelper
Version version = pe.getVersion();
VersionRange versions = ModelHelper.getDefaultRange(version);
- IPackageImport pi = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
- pi.setPackageName( packageName );
- pi.setVersions( versions );
+ IPackageImport pi = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
+ pi.setPackageName(packageName);
+ pi.setVersions(versions);
return pi;
}
-
- public static Iterable<IJavaElement> findTypes( IParent parent, int... type ) throws JavaModelException
+ public static Iterable<IJavaElement> findTypes(IParent parent, int... type)
+ throws JavaModelException
{
LinkedList<IJavaElement> found = new LinkedList<IJavaElement>();
- scanForElement( parent, type, found, false );
+ scanForElement(parent, type, found, false);
return found;
}
-
- public static IJavaElement findType( IParent parent, int... type ) throws JavaModelException
+ public static IJavaElement findType(IParent parent, int... type)
+ throws JavaModelException
{
LinkedList<IJavaElement> found = new LinkedList<IJavaElement>();
- scanForElement( parent, type, found, true );
+ scanForElement(parent, type, found, true);
return found.isEmpty() ? null : found.getFirst();
}
-
- private static void scanForElement( IParent parent, int[] type, List<IJavaElement> roots, boolean thereCanBeOnlyOne )
- throws JavaModelException
+ private static void scanForElement(IParent parent, int[] type,
+ List<IJavaElement> roots, boolean thereCanBeOnlyOne) throws JavaModelException
{
- for ( IJavaElement e : parent.getChildren() )
+ for (IJavaElement e : parent.getChildren())
{
- if ( isType( type, e ) )
+ if (isType(type, e))
{
- roots.add( e );
- if ( thereCanBeOnlyOne )
+ roots.add(e);
+ if (thereCanBeOnlyOne)
{
break;
}
}
- else if ( e instanceof IParent )
+ else if (e instanceof IParent)
{
- scanForElement( ( IParent ) e, type, roots, thereCanBeOnlyOne );
+ scanForElement((IParent) e, type, roots, thereCanBeOnlyOne);
}
}
}
-
- private static boolean isType( int[] type, IJavaElement e )
+ private static boolean isType(int[] type, IJavaElement e)
{
- for ( int i : type )
+ for (int i : type)
{
- if ( i == e.getElementType() )
+ if (i == e.getElementType())
{
return true;
}
@@ -1212,26 +1190,26 @@ public class JavaHelper
return false;
}
-
- public static boolean isAssignableTo( String ifaceOrParentClass, IType type ) throws JavaModelException
+ public static boolean isAssignableTo(String ifaceOrParentClass, IType type)
+ throws JavaModelException
{
- if ( ifaceOrParentClass == null )
+ if (ifaceOrParentClass == null)
return true;
- ITypeHierarchy h = type.newSupertypeHierarchy( null );
+ ITypeHierarchy h = type.newSupertypeHierarchy(null);
- for ( IType superType : h.getAllClasses() )
+ for (IType superType : h.getAllClasses())
{
String name = superType.getFullyQualifiedName();
- if ( name.equals( ifaceOrParentClass ) )
+ if (name.equals(ifaceOrParentClass))
{
return true;
}
}
- for ( IType ifaceType : h.getAllInterfaces() )
+ for (IType ifaceType : h.getAllInterfaces())
{
String name = ifaceType.getFullyQualifiedName();
- if ( name.equals( ifaceOrParentClass ) )
+ if (name.equals(ifaceOrParentClass))
{
return true;
}
@@ -1240,61 +1218,62 @@ public class JavaHelper
return false;
}
-
- private static IType findType( ITypeRoot root ) throws JavaModelException
+ private static IType findType(ITypeRoot root) throws JavaModelException
{
// TODO Auto-generated method stub
- for ( IJavaElement child : root.getChildren() )
+ for (IJavaElement child : root.getChildren())
{
- if ( child.getElementType() == IJavaElement.TYPE )
+ if (child.getElementType() == IJavaElement.TYPE)
{
- return ( IType ) child;
+ return (IType) child;
}
}
- throw new JavaModelException( new IllegalStateException( "Missing type for " + root ), IStatus.ERROR );
+ throw new JavaModelException(
+ new IllegalStateException("Missing type for " + root), IStatus.ERROR);
}
-
- public static Set<String> findLocalPackageDependencies(
- ISigilProjectModel project, String packageName, IProgressMonitor monitor) throws JavaModelException
+ public static Set<String> findLocalPackageDependencies(ISigilProjectModel project,
+ String packageName, IProgressMonitor monitor) throws JavaModelException
{
- Set<String> imports = findJavaImports( project, monitor );
+ Set<String> imports = findJavaImports(project, monitor);
imports.remove(packageName);
return imports;
}
-
- public static Set<String> findLocalPackageUsers(
- ISigilProjectModel project, String packageName, IProgressMonitor monitor) throws JavaModelException
+ public static Set<String> findLocalPackageUsers(ISigilProjectModel project,
+ String packageName, IProgressMonitor monitor) throws JavaModelException
{
Set<String> imports = new HashSet<String>();
Set<String> check = new HashSet<String>();
- for ( IPackageFragment root : project.getJavaModel().getPackageFragments() )
+ for (IPackageFragment root : project.getJavaModel().getPackageFragments())
{
- IPackageFragmentRoot rt = ( IPackageFragmentRoot ) root
- .getAncestor( IJavaElement.PACKAGE_FRAGMENT_ROOT );
+ IPackageFragmentRoot rt = (IPackageFragmentRoot) root.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
- if ( isInClassPath( project, rt ) )
+ if (isInClassPath(project, rt))
{
- for ( ICompilationUnit cu : root.getCompilationUnits() )
+ for (ICompilationUnit cu : root.getCompilationUnits())
{
IPackageFragment pack = (IPackageFragment) cu.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
- if ( !pack.getElementName().equals(packageName)) {
- scanImports( cu, check );
- if (check.contains(packageName)) {
+ if (!pack.getElementName().equals(packageName))
+ {
+ scanImports(cu, check);
+ if (check.contains(packageName))
+ {
imports.add(pack.getElementName());
}
}
check.clear();
}
- for ( IClassFile cf : root.getClassFiles() )
+ for (IClassFile cf : root.getClassFiles())
{
IPackageFragment pack = (IPackageFragment) cf.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
- if ( !pack.getElementName().equals(packageName)) {
- scanImports( cf, check );
- if (check.contains(packageName)) {
+ if (!pack.getElementName().equals(packageName))
+ {
+ scanImports(cf, check);
+ if (check.contains(packageName))
+ {
imports.add(pack.getElementName());
}
}
@@ -1302,7 +1281,7 @@ public class JavaHelper
}
}
}
-
+
return imports;
}
}
\ No newline at end of file
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.model.util;
-
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -39,75 +38,77 @@ import org.apache.felix.sigil.eclipse.mo
import org.eclipse.jface.preference.IPreferenceStore;
import org.osgi.framework.Version;
-
public class ModelHelper
{
- public static List<IModelElement> findUsers( IModelElement e )
+ public static List<IModelElement> findUsers(IModelElement e)
{
LinkedList<IModelElement> users = new LinkedList<IModelElement>();
- findUsers( e, users );
+ findUsers(e, users);
return users;
}
-
- private static void findUsers( IModelElement e, final LinkedList<IModelElement> users )
+ private static void findUsers(IModelElement e, final LinkedList<IModelElement> users)
{
- if ( e instanceof ICapabilityModelElement )
+ if (e instanceof ICapabilityModelElement)
{
- final ICapabilityModelElement cap = ( ICapabilityModelElement ) e;
- SigilCore.getGlobalRepositoryManager().visit( new IModelWalker()
+ final ICapabilityModelElement cap = (ICapabilityModelElement) e;
+ SigilCore.getGlobalRepositoryManager().visit(new IModelWalker()
{
- public boolean visit( IModelElement element )
+ public boolean visit(IModelElement element)
{
- if ( element instanceof IRequirementModelElement )
+ if (element instanceof IRequirementModelElement)
{
- IRequirementModelElement req = ( IRequirementModelElement ) element;
- if ( req.accepts( cap ) )
+ IRequirementModelElement req = (IRequirementModelElement) element;
+ if (req.accepts(cap))
{
- users.add( req );
+ users.add(req);
}
return false;
}
return true;
}
- } );
+ });
}
-
- if ( e instanceof ICompoundModelElement )
+
+ if (e instanceof ICompoundModelElement)
{
- ICompoundModelElement c = ( ICompoundModelElement ) e;
+ ICompoundModelElement c = (ICompoundModelElement) e;
IModelElement[] ch = c.children();
- for ( IModelElement ee : ch )
+ for (IModelElement ee : ch)
{
- findUsers( ee, users );
+ findUsers(ee, users);
}
}
}
-
- public static VersionRange getDefaultRange(Version version) {
+
+ public static VersionRange getDefaultRange(Version version)
+ {
IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
-
- VersionRangeBoundingRule lowerBoundRule = VersionRangeBoundingRule.valueOf( store
- .getString( SigilCore.DEFAULT_VERSION_LOWER_BOUND ) );
- VersionRangeBoundingRule upperBoundRule = VersionRangeBoundingRule.valueOf( store
- .getString( SigilCore.DEFAULT_VERSION_UPPER_BOUND ) );
- VersionRange selectedVersions = VersionRange.newInstance( version, lowerBoundRule, upperBoundRule );
+ VersionRangeBoundingRule lowerBoundRule = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_LOWER_BOUND));
+ VersionRangeBoundingRule upperBoundRule = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_UPPER_BOUND));
+
+ VersionRange selectedVersions = VersionRange.newInstance(version, lowerBoundRule,
+ upperBoundRule);
return selectedVersions;
}
-
- public static IPackageExport findExport(ISigilProjectModel sigil, final String packageName) {
+
+ public static IPackageExport findExport(ISigilProjectModel sigil,
+ final String packageName)
+ {
final ArrayList<IPackageExport> found = new ArrayList<IPackageExport>(1);
sigil.visit(new IModelWalker()
- {
+ {
public boolean visit(IModelElement element)
{
- if (element instanceof IPackageExport) {
+ if (element instanceof IPackageExport)
+ {
IPackageExport pe = (IPackageExport) element;
- if (pe.getPackageName().equals(packageName)) {
+ if (pe.getPackageName().equals(packageName))
+ {
found.add(pe);
}
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.model.util;
-
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -35,27 +34,25 @@ import org.apache.felix.sigil.utils.Glob
import org.eclipse.core.runtime.Platform;
import org.osgi.framework.Bundle;
-
public class ProfileManager
{
- private static final Pattern[] BOOT_DELEGATION_PATTERNS = new Pattern[]
- { GlobCompiler.compile( "org.ietf.jgss" ), GlobCompiler.compile( "org.omg.*" ),
- GlobCompiler.compile( "org.w3c.*" ), GlobCompiler.compile( "org.xml.*" ), GlobCompiler.compile( "sun.*" ),
- GlobCompiler.compile( "com.sun.*" ), };
+ private static final Pattern[] BOOT_DELEGATION_PATTERNS = new Pattern[] {
+ GlobCompiler.compile("org.ietf.jgss"), GlobCompiler.compile("org.omg.*"),
+ GlobCompiler.compile("org.w3c.*"), GlobCompiler.compile("org.xml.*"),
+ GlobCompiler.compile("sun.*"), GlobCompiler.compile("com.sun.*"), };
private static HashMap<String, Properties> profiles;
-
- public static boolean isBootDelegate( ISigilProjectModel project, String packageName )
+ public static boolean isBootDelegate(ISigilProjectModel project, String packageName)
{
- if ( packageName.startsWith( "java." ) )
+ if (packageName.startsWith("java."))
{
return true;
}
- for ( Pattern p : BOOT_DELEGATION_PATTERNS )
+ for (Pattern p : BOOT_DELEGATION_PATTERNS)
{
- if ( p.matcher( packageName ).matches() )
+ if (p.matcher(packageName).matches())
{
return true;
}
@@ -63,60 +60,59 @@ public class ProfileManager
return false;
}
-
- public static Properties findProfileForVersion( String javaVersion )
+ public static Properties findProfileForVersion(String javaVersion)
{
Map<String, Properties> profiles = loadProfiles();
- if ( "1.5.0".equals( javaVersion ) )
+ if ("1.5.0".equals(javaVersion))
{
- return profiles.get( "J2SE-1.5" );
+ return profiles.get("J2SE-1.5");
}
- else if ( "1.6.0".equals( javaVersion ) )
+ else if ("1.6.0".equals(javaVersion))
{
- return profiles.get( "J2SE-1.6" );
+ return profiles.get("J2SE-1.6");
}
return null;
}
-
private synchronized static Map<String, Properties> loadProfiles()
{
- if ( profiles == null )
+ if (profiles == null)
{
profiles = new HashMap<String, Properties>();
- Bundle b = Platform.getBundle( "org.eclipse.osgi" );
+ Bundle b = Platform.getBundle("org.eclipse.osgi");
- for ( String profile : loadProfiles( b ) )
+ for (String profile : loadProfiles(b))
{
- if ( profile.trim().length() > 0 )
+ if (profile.trim().length() > 0)
{
- URL url = findURL( profile, b );
- if ( url != null )
+ URL url = findURL(profile, b);
+ if (url != null)
{
try
{
- Properties p = loadProperties( url );
- String name = p.getProperty( "osgi.java.profile.name" );
- if ( name != null )
+ Properties p = loadProperties(url);
+ String name = p.getProperty("osgi.java.profile.name");
+ if (name != null)
{
- profiles.put( name, p );
+ profiles.put(name, p);
}
else
{
- SigilCore.error( "Invalid profile definition, no name specified: " + url );
+ SigilCore.error("Invalid profile definition, no name specified: "
+ + url);
}
}
- catch ( IOException e )
+ catch (IOException e)
{
- SigilCore.error( "Failed to load java profile", e );
+ SigilCore.error("Failed to load java profile", e);
}
}
else
{
- SigilCore.error( "Unknown profile **" + profile + "**" );
+ SigilCore.error("Unknown profile **" + profile + "**");
}
}
// else ignore empty values
@@ -125,45 +121,40 @@ public class ProfileManager
return profiles;
}
-
- private static String[] loadProfiles( Bundle b )
+ private static String[] loadProfiles(Bundle b)
{
- URL url = findURL( "profile.list", b );
+ URL url = findURL("profile.list", b);
- if ( url != null )
+ if (url != null)
{
try
{
- Properties p = loadProperties( url );
- String s = p.getProperty( "java.profiles" );
- return s == null ? new String[]
- {} : s.split( "," );
+ Properties p = loadProperties(url);
+ String s = p.getProperty("java.profiles");
+ return s == null ? new String[] {} : s.split(",");
}
- catch ( IOException e )
+ catch (IOException e)
{
- SigilCore.error( "Failed to load java profile list", e );
+ SigilCore.error("Failed to load java profile list", e);
}
}
else
{
- SigilCore.error( "Failed to find java profile list" );
+ SigilCore.error("Failed to find java profile list");
}
// fine no properties found
- return new String[]
- {};
+ return new String[] {};
}
-
@SuppressWarnings("unchecked")
- private static URL findURL( String file, Bundle b )
+ private static URL findURL(String file, Bundle b)
{
- Enumeration e = b.findEntries( "/", file, false );
- return e == null ? null : ( URL ) ( e.hasMoreElements() ? e.nextElement() : null );
+ Enumeration e = b.findEntries("/", file, false);
+ return e == null ? null : (URL) (e.hasMoreElements() ? e.nextElement() : null);
}
-
- private static Properties loadProperties( URL url ) throws IOException
+ private static Properties loadProperties(URL url) throws IOException
{
Properties p = new Properties();
@@ -172,17 +163,17 @@ public class ProfileManager
try
{
in = url.openStream();
- p.load( in );
+ p.load(in);
}
finally
{
- if ( in != null )
+ if (in != null)
{
try
{
in.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java Mon Aug 2 17:08:03 2010
@@ -19,37 +19,31 @@
package org.apache.felix.sigil.eclipse.nature;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
-
public class SigilProjectNature implements IProjectNature
{
private IProject project;
-
public void configure() throws CoreException
{
// TODO configure project builder
}
-
public void deconfigure() throws CoreException
{
}
-
public IProject getProject()
{
return project;
}
-
- public void setProject( IProject project )
+ public void setProject(IProject project)
{
this.project = project;
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.preferences;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -27,7 +26,6 @@ import java.util.List;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.text.StrTokenizer;
-
public class PrefsUtils
{
@@ -35,28 +33,26 @@ public class PrefsUtils
{
}
-
- public static final String arrayToString( String[] array )
+ public static final String arrayToString(String[] array)
{
StringBuilder builder = new StringBuilder();
- for ( int i = 0; i < array.length; i++ )
+ for (int i = 0; i < array.length; i++)
{
- if ( i > 0 )
- builder.append( ',' );
- builder.append( StringEscapeUtils.escapeCsv( array[i] ) );
+ if (i > 0)
+ builder.append(',');
+ builder.append(StringEscapeUtils.escapeCsv(array[i]));
}
return builder.toString();
}
-
- public static final String[] stringToArray( String string )
+ public static final String[] stringToArray(String string)
{
- StrTokenizer tokenizer = new StrTokenizer( string, ',', '"' );
+ StrTokenizer tokenizer = new StrTokenizer(string, ',', '"');
String[] array = new String[tokenizer.size()];
- for ( int i = 0; i < array.length; i++ )
+ for (int i = 0; i < array.length; i++)
{
array[i] = tokenizer.nextToken();
}
@@ -64,15 +60,13 @@ public class PrefsUtils
return array;
}
-
- public static String listToString( List<String> names )
+ public static String listToString(List<String> names)
{
- return arrayToString( names.toArray( new String[names.size()] ) );
+ return arrayToString(names.toArray(new String[names.size()]));
}
-
- public static List<String> stringToList( String string )
+ public static List<String> stringToList(String string)
{
- return new ArrayList<String>( Arrays.asList( stringToArray( string ) ) );
+ return new ArrayList<String>(Arrays.asList(stringToArray(string)));
}
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.preferences;
-
public enum PromptablePreference
{
Always, Prompt, Never