private ArrayList<Entry<IPath, IResource>> getSourceArchivesToCleanUp(IProgressMonitor monitor) throws CoreException { Set<IPath> projectSourcePaths = null; for (IProject project : CeylonBuilder.getProjects()) { for (JDTModule module : CeylonBuilder.getProjectExternalModules(project)) { String sourceArchivePathString = module.getSourceArchivePath(); if (sourceArchivePathString != null) { if (projectSourcePaths == null) { projectSourcePaths = new HashSet<>(); } projectSourcePaths.add(Path.fromOSString(sourceArchivePathString)); } } } if (projectSourcePaths == null) return null; Map<IPath, IResource> knownSourceArchives = getSourceArchives(); ArrayList<Entry<IPath, IResource>> result = null; synchronized (knownSourceArchives) { Iterator<Entry<IPath, IResource>> iterator = knownSourceArchives.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<IPath, IResource> entry = iterator.next(); IPath path = entry.getKey(); if (!projectSourcePaths.contains(path)) { if (entry.getValue() != null) { if (result == null) result = new ArrayList<>(); result.add(entry); } } } } return result; }
@Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { RootFolderType rootFolderType = null; IResource resource = null; if (receiver instanceof IResource) { resource = (IResource) receiver; } if (receiver instanceof IJavaElement) { resource = ((IJavaElement) receiver).getResource(); } if (resource instanceof IFolder) { rootFolderType = CeylonBuilder.getRootFolderType((IFolder) resource); } if (resource instanceof IFile) { rootFolderType = CeylonBuilder.getRootFolderType((IFile) resource); } if (rootFolderType != null) { if (IS_IN_CEYLON_SOURCE_FOLDER_PROPERTY.equals(property)) { return rootFolderType.equals(RootFolderType.SOURCE); } if (IS_IN_CEYLON_RESOURCE_FOLDER_PROPERTY.equals(property)) { return rootFolderType.equals(RootFolderType.RESOURCE); } } return false; }
static void addCreateParameterProposal( Collection<ICompletionProposal> proposals, String def, String desc, Image image, Declaration dec, PhasedUnit unit, Tree.Declaration decNode, Tree.ParameterList paramList, ProducedType t) { IFile file = CeylonBuilder.getFile(unit); TextFileChange change = new TextFileChange("Add Parameter", file); change.setEdit(new MultiTextEdit()); int offset = paramList.getStopIndex(); int il = importType(change, t, unit.getCompilationUnit()); change.addEdit(new InsertEdit(offset, def)); proposals.add( new CreateProposal( def, "Add " + desc + " to '" + dec.getName() + "'", image, 0, offset + il, file, change)); }
static void addCreateProposal( Collection<ICompletionProposal> proposals, String def, boolean local, String desc, Image image, PhasedUnit unit, Tree.Statement statement, ProducedType t) { IFile file = CeylonBuilder.getFile(unit); TextFileChange change = new TextFileChange(local ? "Create Local" : "Create Toplevel", file); change.setEdit(new MultiTextEdit()); IDocument doc = CreateProposal.getDocument(change); String indent = CeylonQuickFixAssistant.getIndent(statement, doc); int offset = statement.getStartIndex(); def = def.replace("$indent", indent); int il = importType(change, t, unit.getCompilationUnit()); change.addEdit(new InsertEdit(offset, def + "\n" + indent)); proposals.add( new CreateProposal( def, (local ? "Create local " : "Create toplevel ") + desc, image, 0, offset + il, file, change)); }
public void refreshReferences(IProject source, IProgressMonitor monitor) { IProject externalProject = getExternalSourceArchivesProject(); if (source.equals(externalProject)) return; if (!CeylonNature.isEnabled(source)) return; Set<IPath> externalSourceArchives = getExternalSourceArchives(CeylonBuilder.getProjectExternalModules(source)); if (externalSourceArchives == null) return; runRefreshJob(externalSourceArchives); return; }
static void addCreateParameterAndAttributeProposal( Collection<ICompletionProposal> proposals, String pdef, String adef, String desc, Image image, Declaration dec, PhasedUnit unit, Tree.Declaration decNode, Tree.ParameterList paramList, Tree.Body body, ProducedType t) { IFile file = CeylonBuilder.getFile(unit); TextFileChange change = new TextFileChange("Add Attribute", file); change.setEdit(new MultiTextEdit()); int offset = paramList.getStopIndex(); IDocument doc = CreateProposal.getDocument(change); String indent; String indentAfter; int offset2; List<Tree.Statement> statements = body.getStatements(); if (statements.isEmpty()) { indentAfter = "\n" + CeylonQuickFixAssistant.getIndent(decNode, doc); indent = indentAfter + getDefaultIndent(); offset2 = body.getStartIndex() + 1; } else { Tree.Statement statement = statements.get(statements.size() - 1); indent = "\n" + CeylonQuickFixAssistant.getIndent(statement, doc); offset2 = statement.getStopIndex() + 1; indentAfter = ""; } int il = importType(change, t, unit.getCompilationUnit()); change.addEdit(new InsertEdit(offset, pdef)); change.addEdit(new InsertEdit(offset2, indent + adef + indentAfter)); proposals.add( new CreateProposal( pdef, "Add " + desc + " to '" + dec.getName() + "'", image, 0, offset + il, file, change)); }
/* * Refreshes the external folders referenced on the classpath of the given source project */ public void refreshReferences(final IProject[] sourceProjects, IProgressMonitor monitor) { IProject externalProject = getExternalSourceArchivesProject(); Set<IPath> externalSourceArchives = null; for (IProject project : sourceProjects) { if (project.equals(externalProject)) continue; if (!CeylonNature.isEnabled(project)) continue; Set<IPath> sourceArchivesInProject = getExternalSourceArchives(CeylonBuilder.getProjectExternalModules(project)); if (sourceArchivesInProject == null || sourceArchivesInProject.size() == 0) continue; if (externalSourceArchives == null) externalSourceArchives = new HashSet<>(); externalSourceArchives.addAll(sourceArchivesInProject); } if (externalSourceArchives == null) return; runRefreshJob(externalSourceArchives); }
static void addCreateEnumProposal( Collection<ICompletionProposal> proposals, String def, String desc, Image image, PhasedUnit unit, Tree.Statement statement) { IFile file = CeylonBuilder.getFile(unit); TextFileChange change = new TextFileChange("Create Enumerated", file); IDocument doc = CreateProposal.getDocument(change); String indent = CeylonQuickFixAssistant.getIndent(statement, doc); String s = indent + def + "\n"; int offset = statement.getStopIndex() + 2; if (offset > doc.getLength()) { offset = doc.getLength(); s = "\n" + s; } // def = def.replace("$indent", indent); change.setEdit(new InsertEdit(offset, s)); proposals.add( new CreateProposal(def, "Create enumerated " + desc, image, 0, offset, file, change)); }