use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class StatsViewLabelProvider method getColumnImage.
@Override
public Image getColumnImage(final Object element, final int columnIndex) {
Image img = null;
final ICoverageObject statsEl = (ICoverageObject) element;
switch(columnIndex) {
case 0:
final ObjectType type = statsEl.getType();
switch(type) {
case FUNCTION:
img = Activator.getImageDescriptor(Images.FUNCTION).createImage();
break;
case MODULE:
IErlModule m;
try {
m = ErlangEngine.getInstance().getModel().findModule(statsEl.getLabel());
} catch (final ErlModelException e) {
ErlLogger.error(e);
return null;
}
img = ErlangElementImageProvider.getErlImageDescriptor(m, ErlangElementImageProvider.SMALL_ICONS).createImage();
break;
case FOLDER:
img = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER).createImage();
break;
case PROJECT:
img = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT).createImage();
break;
default:
break;
}
break;
case 3:
img = drawPercentage(statsEl.getPercentage());
break;
default:
}
return img;
}
use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class DocumentationFormatter method getDocumentationString.
public static String getDocumentationString(final Collection<IErlComment> comments, final IErlTypespec typespec) {
final StringBuilder stringBuilder = new StringBuilder();
if (!comments.isEmpty()) {
stringBuilder.append("<pre class='edoc'>");
for (final IErlComment member : comments) {
try {
String source = "\n" + DocumentationFormatter.convertToHTML(member.getSource());
source = source.replaceAll("\n%%%", "\n").replaceAll("\n%%", "\n").replaceAll("\n%", "\n").substring(1);
source = source.replaceAll("\n( *([-=] *)+\n)+", "\n<hr/>\n").replaceAll("^ *([-=] *)+\n", "\n").replaceAll("\n *([-=] *)+$", "\n");
stringBuilder.append(source);
if (!source.endsWith("\n")) {
stringBuilder.append('\n');
}
stringBuilder.append('\n');
} catch (final ErlModelException e) {
ErlLogger.warn(e);
}
}
stringBuilder.append("</pre>");
}
if (typespec != null) {
try {
stringBuilder.append("<hr/><pre class='typespec'>").append(DocumentationFormatter.convertToHTML(typespec.getSource())).append("</pre>");
} catch (final ErlModelException e) {
ErlLogger.warn(e);
}
}
return stringBuilder.toString().replace("\n", "<br/>");
}
use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class ErlStructureCreator method createStructureComparator.
@Override
protected IStructureComparator createStructureComparator(final Object element, final IDocument document0, final ISharedDocumentAdapter sharedDocumentAdapter, final IProgressMonitor monitor) throws CoreException {
IErlModule module = null;
final IErlModel model = ErlangEngine.getInstance().getModel();
String s = "";
IDocument document = document0;
if (element instanceof ResourceNode) {
final ResourceNode rn = (ResourceNode) element;
final IResource r = rn.getResource();
if (r instanceof IFile) {
final IFile f = (IFile) r;
final IErlElement e = model.findElement(r);
if (e instanceof IErlModule) {
module = (IErlModule) e;
}
if (document == null) {
try {
s = ErlStructureCreator.readString(f.getContents());
document = new Document(s);
} catch (final CoreException e1) {
}
}
}
} else if (document == null && element instanceof IStreamContentAccessor) {
try {
try (final InputStream contents = ((IStreamContentAccessor) element).getContents()) {
s = ErlStructureCreator.readString(contents);
} catch (final IOException e) {
}
document = new Document(s);
} catch (final CoreException ex) {
}
} else if (document != null) {
s = document.get();
}
if (module == null) {
String name = "comptemp";
if (element instanceof ITypedElement) {
final ITypedElement typedElement = (ITypedElement) element;
name = typedElement.getName();
}
module = model.getModuleFromText(model, name, s, null);
}
ErlNode root = null;
if (element != null && document != null) {
try {
module.open(null);
root = new RootErlNode(document, element);
recursiveMakeErlNodes(module, root, document);
} catch (final ErlModelException e) {
ErlLogger.warn(e);
}
}
return root;
}
use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class DefaultErlangFoldingStructureProvider method projectionEnabled.
/*
* @seeorg.eclipse.jface.text.source.projection.IProjectionListener#
* projectionEnabled()
*/
@Override
public void projectionEnabled() {
// http://home.ott.oti.com/teams/wswb/anon/out/vms/index.html
// projectionEnabled messages are not always paired with
// projectionDisabled
// i.e. multiple enabled messages may be sent out.
// we have to make sure that we disable first when getting an enable
// message.
projectionDisabled();
initialize();
if (fEditor instanceof ErlangEditor && fModule != null) {
boolean structureKnown = false;
try {
structureKnown = fModule.isStructureKnown();
} catch (final ErlModelException e1) {
}
if (structureKnown) {
final IErlElementDelta d = ErlangEngine.getInstance().getModel().createElementDelta(IErlElementDelta.CHANGED, IErlElementDelta.F_CONTENT, fModule);
processDelta(d);
} else {
try {
fModule.open(null);
} catch (final ErlModelException e) {
ErlLogger.error(e);
}
}
}
}
use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class ErlangExternalsContentProvider method hasChildren.
@Override
public boolean hasChildren(final Object element0) {
Object element = element0;
if (element instanceof IProject) {
final IProject project = (IProject) element;
if (project.isOpen()) {
element = ErlangEngine.getInstance().getModel().findProject(project);
}
}
if (element instanceof IErlModule) {
return erlangFileContentProvider.hasChildren(element);
}
if (element instanceof IParent) {
if (element instanceof IErlExternalRoot || element instanceof IErlProject || element instanceof IErlModel) {
// we know these have children
return true;
}
final Stopwatch clock = Stopwatch.createStarted();
if (element instanceof IOpenable) {
final IOpenable openable = (IOpenable) element;
try {
openable.open(null);
} catch (final ErlModelException e) {
}
}
final IParent parent = (IParent) element;
final boolean result = parent.hasChildrenOfKind(ErlElementKind.EXTERNAL_ROOT, ErlElementKind.EXTERNAL_APP, ErlElementKind.EXTERNAL_FOLDER, ErlElementKind.MODULE);
if (clock.elapsed(TimeUnit.MILLISECONDS) > 100) {
ErlLogger.debug("TIME open " + element.getClass() + " " + element + " " + clock.elapsed(TimeUnit.MILLISECONDS) + " ms");
}
return result;
}
return false;
}
Aggregations