Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Created UI-related functionality. Implemented .hp elements sorting.

  • Loading branch information...
commit 5c688d98cd4e3e887b8548910359b7d1c66ad836 1 parent d7924ec
@serras serras authored
View
5 net.sf.eclipsefp.haskell.profiler/META-INF/MANIFEST.MF
@@ -6,7 +6,10 @@ Bundle-Version: 0.0.1
Bundle-Activator: net.sf.eclipsefp.haskell.profiler.ProfilerPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.eclipse.team.core
+ org.eclipse.team.core,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %bundleVendor
+Bundle-Localization: plugin
View
1  net.sf.eclipsefp.haskell.profiler/build.properties
@@ -2,4 +2,5 @@ source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
+ plugin.properties,\
plugin.xml
View
4 net.sf.eclipsefp.haskell.profiler/plugin.properties
@@ -2,5 +2,5 @@
bundleVendor = The EclipseFP Project
bundleName = Haskell Plug-in Profiler support
-contenttype_profiler_name = GHC Profiling Output
-profilerViewer_name = Profiling Output Viewer
+contenttypeProfilerName = GHC Profiling Output
+profilerViewerName = Profiling Output Viewer
View
4 net.sf.eclipsefp.haskell.profiler/plugin.xml
@@ -14,7 +14,7 @@
base-type="org.eclipse.core.runtime.text"
file-extensions="hp"
id="net.sf.eclipsefp.haskell.contenttypes.profiler"
- name="%contenttype_profiler_name"
+ name="%contenttypeProfilerName"
priority="normal">
</content-type>
</extension>
@@ -25,7 +25,7 @@
contributorClass="net.sf.eclipsefp.haskell.profiler.actions.ProfilerViewerActionContributor"
extensions="hp"
id="net.sf.eclipsefp.haskell.profiler.internal.editors.ProfilerViewer"
- name="%profilerViewer_name">
+ name="%profilerViewerName">
<contentTypeBinding
contentTypeId="net.sf.eclipsefp.haskell.contenttypes.profiler">
</contentTypeBinding>
View
58 ...skell.profiler/src/net/sf/eclipsefp/haskell/profiler/internal/editors/ProfilerViewer.java
@@ -1,58 +1,76 @@
package net.sf.eclipsefp.haskell.profiler.internal.editors;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.util.Map;
+
+import net.sf.eclipsefp.haskell.profiler.model.Job;
+
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;
public class ProfilerViewer extends EditorPart {
+ Job job = null;
+
public ProfilerViewer() {
- // TODO Auto-generated constructor stub
+ super();
}
-
+
@Override
- public void doSave(IProgressMonitor monitor) {
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ try {
+ IFileEditorInput fInput = (IFileEditorInput)input;
+ InputStream contents = fInput.getFile().getContents();
+ job = Job.parse(contents);
+ contents.close();
+ for(Map.Entry<String, BigInteger> entry : job.sortEntriesByTotal()) {
+ System.out.print(entry.getKey());
+ System.out.print(": ");
+ System.out.println(entry.getValue().toString());
+ }
+ } catch (Exception e) {
+ throw new PartInitException(Status.CANCEL_STATUS);
+ }
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
// TODO Auto-generated method stub
}
@Override
- public void doSaveAs() {
- // TODO Auto-generated method stub
-
+ public void setFocus() {
+ // Do nothing
}
@Override
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- // TODO Auto-generated method stub
+ public void doSave(IProgressMonitor monitor) {
+ // Do nothing: the .hp files cannot be changed
+ }
+ @Override
+ public void doSaveAs() {
+ // Do nothing: the .hp files cannot be changed
}
@Override
public boolean isDirty() {
- // TODO Auto-generated method stub
return false;
}
@Override
public boolean isSaveAsAllowed() {
- // TODO Auto-generated method stub
return false;
}
- @Override
- public void createPartControl(Composite parent) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void setFocus() {
- // TODO Auto-generated method stub
-
- }
}
View
2  ...l.profiler/src/net/sf/eclipsefp/haskell/profiler/internal/parser/ProfilingOutputParser.jj
@@ -20,7 +20,7 @@ TOKEN :
{
< #DIGIT : [ "0"-"9" ] >
| < FLOAT : (< DIGIT >)+ "." (< DIGIT >)+ >
-| < INTEGER : (< DIGIT >)+ > | < IDENTIFIER : (~[" ", "\n", "\r", "\""])+ >
+| < INTEGER : (< DIGIT >)+ > | < IDENTIFIER : (~[" ", "\n", "\r", "\t", "\""])+ >
| < QUOTEDSTRING : "\"" (~["\"", "\n", "\r"])* "\"" >
}
View
10 .../net/sf/eclipsefp/haskell/profiler/internal/parser/ProfilingOutputParserTokenManager.java
@@ -15,8 +15,6 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0)
switch (pos)
{
case 0:
- if ((active0 & 0x8L) != 0L)
- return 0;
if ((active0 & 0x7e0L) != 0L)
{
jjmatchedKind = 14;
@@ -129,8 +127,6 @@ private int jjMoveStringLiteralDfa0_0()
{
switch(curChar)
{
- case 9:
- return jjStartNfaWithStates_0(0, 3, 0);
case 66:
return jjMoveStringLiteralDfa1_0(0x200L);
case 68:
@@ -445,7 +441,7 @@ private int jjMoveNfa_0(int startState, int curPos)
switch(jjstateSet[--i])
{
case 1:
- if ((0xfffffffaffffdbffL & l) != 0L)
+ if ((0xfffffffaffffd9ffL & l) != 0L)
{
if (kind > 14)
kind = 14;
@@ -461,7 +457,7 @@ else if (curChar == 34)
}
break;
case 0:
- if ((0xfffffffaffffdbffL & l) == 0L)
+ if ((0xfffffffaffffd9ffL & l) == 0L)
break;
if (kind > 14)
kind = 14;
@@ -686,7 +682,7 @@ public Token getNextToken()
}
try { input_stream.backup(0);
- while (curChar <= 32 && (0x100002400L & (1L << curChar)) != 0L)
+ while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L)
curChar = input_stream.BeginToken();
}
catch (java.io.IOException e1) { continue EOFLoop; }
View
23 ...lipsefp.haskell.profiler/src/net/sf/eclipsefp/haskell/profiler/internal/util/UITexts.java
@@ -0,0 +1,23 @@
+// Copyright (c) 2006-2008 by Leif Frenzel - see http://leiffrenzel.de
+// Copyright (c) 2011 by Alejandro Serrano
+// This code is made available under the terms of the Eclipse Public License,
+// version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
+package net.sf.eclipsefp.haskell.profiler.internal.util;
+
+import org.eclipse.osgi.util.NLS;
+
+/** <p>provides access to the internationalized UI texts.</p>
+ *
+ * @author Leif Frenzel
+ */
+public final class UITexts extends NLS {
+
+ // message fields
+ public static String graph_restOfTrace;
+
+ private static final String BUNDLE_NAME = UITexts.class.getPackage().getName() + ".uitexts"; //$NON-NLS-1$
+
+ static {
+ NLS.initializeMessages( BUNDLE_NAME, UITexts.class );
+ }
+}
View
6 ...p.haskell.profiler/src/net/sf/eclipsefp/haskell/profiler/internal/util/uitexts.properties
@@ -0,0 +1,6 @@
+# Copyright (c) 2006-2008 by Leif Frenzel - see http://leiffrenzel.de
+# Copyright (c) 2011 by Alejandro Serrano
+# This code is made available under the terms of the Eclipse Public License,
+# version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
+
+graph_restOfTrace = (rest)
View
39 net.sf.eclipsefp.haskell.profiler/src/net/sf/eclipsefp/haskell/profiler/model/Job.java
@@ -2,9 +2,15 @@
import java.io.InputStream;
import java.io.Reader;
+import java.math.BigInteger;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import net.sf.eclipsefp.haskell.profiler.internal.parser.ParseException;
@@ -62,4 +68,37 @@ public static Job parse(Reader stream) throws ParseException {
ProfilingOutputParser parser = new ProfilingOutputParser(stream);
return parser.job();
}
+
+ public BigInteger getTotal() {
+ BigInteger result = BigInteger.ZERO;
+ for (Sample s : getSamples())
+ result = result.add(s.getTotal());
+ return result;
+ }
+
+ public Map<String, BigInteger> getTotalByEntry() {
+ LinkedHashMap<String, BigInteger> result = new LinkedHashMap<String, BigInteger>();
+ for (Sample s : getSamples()) {
+ for (Map.Entry<String, Long> e : s.getEntries()) {
+ if (!result.containsKey(e.getKey())) {
+ result.put(e.getKey(), BigInteger.ZERO);
+ }
+ BigInteger prev = result.get(e.getKey());
+ result.put(e.getKey(), prev.add(BigInteger.valueOf(e.getValue())));
+ }
+ }
+ return result;
+ }
+
+ public List<Map.Entry<String, BigInteger>> sortEntriesByTotal() {
+ ArrayList<Map.Entry<String, BigInteger>> totals =
+ new ArrayList<Map.Entry<String, BigInteger>>(
+ getTotalByEntry().entrySet());
+ Collections.sort(totals, new Comparator<Map.Entry<String, BigInteger>>() {
+ public int compare(Entry<String, BigInteger> a, Entry<String, BigInteger> b) {
+ return -a.getValue().compareTo(b.getValue());
+ }
+ });
+ return totals;
+ }
}
View
8 net.sf.eclipsefp.haskell.profiler/src/net/sf/eclipsefp/haskell/profiler/model/Sample.java
@@ -1,5 +1,6 @@
package net.sf.eclipsefp.haskell.profiler.model;
+import java.math.BigInteger;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
@@ -24,4 +25,11 @@ public void addEntry(String name, long value) {
public Set<Map.Entry<String, Long>> getEntries() {
return entries.entrySet();
}
+
+ public BigInteger getTotal() {
+ BigInteger result = BigInteger.ZERO;
+ for (long v : entries.values())
+ result = result.add(BigInteger.valueOf(v));
+ return result;
+ }
}
View
3  net.sf.eclipsefp.haskell.ui/META-INF/MANIFEST.MF
@@ -26,7 +26,8 @@ Require-Bundle: net.sf.eclipsefp.haskell.core,
net.sf.eclipsefp.haskell.util,
org.eclipse.core.variables;bundle-version="3.2.200",
net.sf.eclipsefp.haskell.debug.core;bundle-version="2.0.0",
- net.sf.eclipsefp.haskell.browser;bundle-version="0.0.1"
+ net.sf.eclipsefp.haskell.browser;bundle-version="0.0.1",
+ net.sf.eclipsefp.haskell.profiler;bundle-version="0.0.1"
Bundle-ManifestVersion: 2
Export-Package: net.sf.eclipsefp.common.ui.dialog;uses:="org.eclipse.swt.widgets",
net.sf.eclipsefp.common.ui.preferences;
Please sign in to comment.
Something went wrong with that request. Please try again.