proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/apiimpl/GraphContextMenu.java | GraphContextMenu | createMenuItemFromGraphContextMenuItem | class GraphContextMenu {
private final VizConfig config;
private final AbstractEngine engine;
private final DataBridge dataBridge;
public GraphContextMenu() {
config = VizController.getInstance().getVizConfig();
engine = VizController.getInstance().getEngine();
dataBridge = Viz... |
ContextMenuItemManipulator[] subItems = item.getSubItems();
if (subItems != null && item.canExecute()) {
JMenu subMenu = new JMenu();
subMenu.setText(item.getName());
if (item.getDescription() != null && !item.getDescription().isEmpty()) {
subMenu.set... | 729 | 641 | 1,370 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/apiimpl/contextmenuitems/CopyOrMoveToWorkspace.java | CopyOrMoveToWorkspace | getSubItems | class CopyOrMoveToWorkspace extends BasicItem implements NodesManipulator {
@Override
public void execute() {
}
@Override
public void setup(Node[] nodes, Node clickedNode) {
this.nodes = nodes;
}
@Override
public ContextMenuItemManipulator[] getSubItems() {<FILL_FUNCTION_BODY>... |
if (nodes != null) {
int i = 0;
ArrayList<GraphContextMenuItem> subItems = new ArrayList<>();
if (canExecute()) {
subItems.add(new CopyOrMoveToWorkspaceSubItem(null, true, 0, 0, isCopy()));//New workspace
ProjectController projectController = ... | 178 | 241 | 419 | <methods>public non-sealed void <init>() ,public java.lang.String getDescription() ,public java.lang.Integer getMnemonicKey() ,public org.gephi.datalab.spi.ContextMenuItemManipulator[] getSubItems() ,public org.gephi.datalab.spi.ManipulatorUI getUI() ,public boolean isAvailable() ,public void setup(Node[], Node) ,publi... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/apiimpl/contextmenuitems/CopyOrMoveToWorkspaceSubItem.java | CopyOrMoveToWorkspaceSubItem | copyToWorkspace | class CopyOrMoveToWorkspaceSubItem extends BasicItem implements NodesManipulator {
private final Workspace workspace;
private final boolean canExecute;
private final int type;
private final int position;
private final boolean copy;
/**
* Constructor with copy or move settings
*
... |
ProjectController projectController = Lookup.getDefault().lookup(ProjectController.class);
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
Workspace currentWorkspace = projectController.getCurrentWorkspace();
GraphModel currentGraphModel = graphCont... | 618 | 511 | 1,129 | <methods>public non-sealed void <init>() ,public java.lang.String getDescription() ,public java.lang.Integer getMnemonicKey() ,public org.gephi.datalab.spi.ContextMenuItemManipulator[] getSubItems() ,public org.gephi.datalab.spi.ManipulatorUI getUI() ,public boolean isAvailable() ,public void setup(Node[], Node) ,publi... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/apiimpl/contextmenuitems/Delete.java | Delete | execute | class Delete extends BasicItem {
@Override
public void execute() {<FILL_FUNCTION_BODY>}
@Override
public String getName() {
return NbBundle.getMessage(Delete.class, "GraphContextMenu_Delete");
}
@Override
public boolean canExecute() {
return nodes.length > 0;
}
@O... |
NotifyDescriptor.Confirmation notifyDescriptor = new NotifyDescriptor.Confirmation(
NbBundle.getMessage(Delete.class, "GraphContextMenu.Delete.message"),
NbBundle.getMessage(Delete.class, "GraphContextMenu.Delete.message.title"), NotifyDescriptor.YES_NO_OPTION);
if (DialogDispla... | 209 | 145 | 354 | <methods>public non-sealed void <init>() ,public java.lang.String getDescription() ,public java.lang.Integer getMnemonicKey() ,public org.gephi.datalab.spi.ContextMenuItemManipulator[] getSubItems() ,public org.gephi.datalab.spi.ManipulatorUI getUI() ,public boolean isAvailable() ,public void setup(Node[], Node) ,publi... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/apiimpl/contextmenuitems/Free.java | Free | canExecute | class Free extends BasicItem {
@Override
public void execute() {
GraphElementsController gec = Lookup.getDefault().lookup(GraphElementsController.class);
gec.setNodesFixed(nodes, false);
}
@Override
public String getName() {
return NbBundle.getMessage(Free.class, "GraphCont... |
GraphElementsController gec = Lookup.getDefault().lookup(GraphElementsController.class);
for (Node n : nodes) {
if (gec.isNodeFixed(n)) {
return true;
}
}
return false;
| 238 | 66 | 304 | <methods>public non-sealed void <init>() ,public java.lang.String getDescription() ,public java.lang.Integer getMnemonicKey() ,public org.gephi.datalab.spi.ContextMenuItemManipulator[] getSubItems() ,public org.gephi.datalab.spi.ManipulatorUI getUI() ,public boolean isAvailable() ,public void setup(Node[], Node) ,publi... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/apiimpl/contextmenuitems/SelectInDataLaboratory.java | SelectInDataLaboratory | setup | class SelectInDataLaboratory extends BasicItem {
private DataTablesController dtc;
@Override
public void setup(Graph graph, Node[] nodes) {<FILL_FUNCTION_BODY>}
@Override
public void execute() {
dtc.setNodeTableSelection(nodes);
dtc.selectNodesTable();
}
@Override
pub... |
this.nodes = nodes;
dtc = Lookup.getDefault().lookup(DataTablesController.class);
if (!dtc.isDataTablesReady()) {
dtc.prepareDataTables();
}
| 312 | 59 | 371 | <methods>public non-sealed void <init>() ,public java.lang.String getDescription() ,public java.lang.Integer getMnemonicKey() ,public org.gephi.datalab.spi.ContextMenuItemManipulator[] getSubItems() ,public org.gephi.datalab.spi.ManipulatorUI getUI() ,public boolean isAvailable() ,public void setup(Node[], Node) ,publi... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/apiimpl/contextmenuitems/Settle.java | Settle | canExecute | class Settle extends BasicItem {
@Override
public void execute() {
GraphElementsController gec = Lookup.getDefault().lookup(GraphElementsController.class);
gec.setNodesFixed(nodes, true);
}
@Override
public String getName() {
return NbBundle.getMessage(Settle.class, "GraphC... |
GraphElementsController gec = Lookup.getDefault().lookup(GraphElementsController.class);
for (Node n : nodes) {
if (!gec.isNodeFixed(n)) {
return true;
}
}
return false;
| 240 | 66 | 306 | <methods>public non-sealed void <init>() ,public java.lang.String getDescription() ,public java.lang.Integer getMnemonicKey() ,public org.gephi.datalab.spi.ContextMenuItemManipulator[] getSubItems() ,public org.gephi.datalab.spi.ManipulatorUI getUI() ,public boolean isAvailable() ,public void setup(Node[], Node) ,publi... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/component/ActionsToolbar.java | ActionsToolbar | actionPerformed | class ActionsToolbar extends JToolBar {
//Settings
private Color color = new Color(0.6f, 0.6f, 0.6f);
private float size = 10.0f;
public ActionsToolbar() {
initDesign();
initContent();
}
private void initContent() {
//Center on graph
final JButton centerOnGrap... |
color = resetColorButton.getColor();
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
GraphModel gm = gc.getGraphModel();
Graph graph = gm.getGraphVisible();
for (Node n : graph.getNodes()) {
n.se... | 1,252 | 230 | 1,482 | <methods>public void <init>() ,public void <init>(int) ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, int) ,public javax.swing.JButton add(javax.swing.Action) ,public void addSeparator() ,public void addSeparator(java.awt.Dimension) ,public javax.accessibility.AccessibleContext getAccessibl... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/component/CollapsePanel.java | CollapsePanel | initComponents | class CollapsePanel extends javax.swing.JPanel {
private boolean extended;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel buttonPanel;
private javax.swing.JButton extendButton;
// End of variables declaration//GEN-END:variables
/**
* Creates new f... |
buttonPanel = new javax.swing.JPanel();
extendButton = new javax.swing.JButton();
setOpaque(true);
setLayout(new java.awt.BorderLayout());
buttonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 3));
extendButton.setToolTipText(
org.o... | 763 | 214 | 977 | <methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void s... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/component/NodeSettingsPanel.java | NodeSettingsPanel | initComponents | class NodeSettingsPanel extends javax.swing.JPanel {
/**
* Creates new form NodeSettingsPanel
*/
public NodeSettingsPanel() {
initComponents();
}
public void setup() {
VizModel vizModel = VizController.getInstance().getVizModel();
}
public void setEnable(boolean ena... |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 581, Short.MAX_VALUE)
);
layout.setVerticalGroup(
... | 257 | 144 | 401 | <methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void s... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/component/SelectionToolbar.java | SelectionToolbar | initContent | class SelectionToolbar extends JToolBar {
private final ButtonGroup buttonGroup;
public SelectionToolbar() {
initDesign();
buttonGroup = new ButtonGroup();
initContent();
}
private void initContent() {<FILL_FUNCTION_BODY>}
private void initDesign() {
setFloatable(... |
//Mouse
final JToggleButton mouseButton =
new JToggleButton(ImageUtilities.loadImageIcon("VisualizationImpl/mouse.png", false));
mouseButton.setToolTipText(NbBundle.getMessage(SelectionToolbar.class, "SelectionToolbar.mouse.tooltip"));
mouseButton.addActionListener(new Acti... | 326 | 878 | 1,204 | <methods>public void <init>() ,public void <init>(int) ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, int) ,public javax.swing.JButton add(javax.swing.Action) ,public void addSeparator() ,public void addSeparator(java.awt.Dimension) ,public javax.accessibility.AccessibleContext getAccessibl... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/component/VizExtendedBar.java | VizExtendedBar | initComponents | class VizExtendedBar extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JSeparator separator;
private javax.swing.JTabbedPane tabbedPane;
// End of variables declaration//GEN-END:variables
/**
* Creates new form VizExtendedBar
*... |
separator = new javax.swing.JSeparator();
tabbedPane = new javax.swing.JTabbedPane();
setOpaque(true);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.sw... | 325 | 328 | 653 | <methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void s... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/component/VizToolbar.java | VizToolbar | setEnable | class VizToolbar extends JToolBar {
public VizToolbar(VizToolbarGroup[] groups) {
initDesign();
for (VizToolbarGroup g : groups) {
addSeparator();
for (JComponent c : g.getToolbarComponents()) {
add(c);
}
}
}
private void initDes... |
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (Component c : getComponents()) {
c.setEnabled(enabled);
}
}
});
| 246 | 62 | 308 | <methods>public void <init>() ,public void <init>(int) ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, int) ,public javax.swing.JButton add(javax.swing.Action) ,public void addSeparator() ,public void addSeparator(java.awt.Dimension) ,public javax.accessibility.AccessibleContext getAccessibl... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/model/edge/EdgeModeler.java | EdgeModeler | initModel | class EdgeModeler extends Modeler {
public EdgeModeler(CompatibilityEngine engine) {
super(engine);
}
public EdgeModel initModel(Edge edge, NodeModel sourceModel, NodeModel targetModelImpl) {<FILL_FUNCTION_BODY>}
@Override
public void beforeDisplay(GL2 gl, GLU glu) {
gl.glBegin(GL... |
EdgeModel edgeModel;
if (edge.isSelfLoop()) {
edgeModel = new SelfLoopModel(edge, sourceModel);
} else {
edgeModel = new Edge2dModel(edge, sourceModel, targetModelImpl);
}
return edgeModel;
| 292 | 72 | 364 | <methods>public void <init>(org.gephi.visualization.opengl.CompatibilityEngine) ,public abstract void afterDisplay(GL2, GLU) ,public abstract void beforeDisplay(GL2, GLU) ,public abstract void chooseModel(org.gephi.visualization.model.Model) ,public abstract int initDisplayLists(GL2, GLU, GLUquadric, int) ,public boole... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/model/node/NodeDiskModel.java | NodeDiskModel | display | class NodeDiskModel extends NodeModel {
public int modelType;
public int modelBorderType;
public NodeDiskModel(Node node) {
super(node);
}
@Override
public void display(GL2 gl, GLU glu, VizModel vizModel) {<FILL_FUNCTION_BODY>}
@Override
public boolean selectionTest(Vecf dist... |
boolean selec = selected;
boolean neighbor = false;
highlight = false;
if (vizModel.isAutoSelectNeighbor() && mark && !selec) {
selec = true;
highlight = true;
neighbor = true;
}
mark = false;
gl.glPushMatrix();
float s... | 162 | 1,032 | 1,194 | <methods>public void <init>(Node) ,public void addEdge(org.gephi.visualization.model.edge.EdgeModel) ,public float getCameraDistance() ,public abstract float getCollisionDistance(double) ,public float[] getDragDistanceFromMouse() ,public org.gephi.visualization.model.edge.EdgeModel[] getEdges() ,public ElementPropertie... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/model/node/NodeModel.java | NodeModel | octreePosition | class NodeModel implements Model, TextModel {
protected static final long ONEOVERPHI = 106039;
protected final Node node;
public int markTime;
public boolean mark;
protected float cameraDistance;
protected float[] dragDistance;
//Octant
protected Octant octant;
protected int octantI... |
//float radius = obj.getRadius();
int index = 0;
if (node.y() < centerY) {
index += 4;
}
if (node.z() > centerZ) {
index += 2;
}
if (node.x() < centerX) {
index += 1;
}
return index;
| 1,339 | 95 | 1,434 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/model/node/NodeModeler.java | NodeModeler | chooseModel | class NodeModeler extends Modeler {
public int SHAPE_DIAMOND;
public int SHAPE_DISK16;
public int SHAPE_DISK32;
public int SHAPE_DISK64;
public int BORDER16;
public int BORDER32;
public int BORDER64;
public NodeModeler(CompatibilityEngine engine) {
super(engine);
}
pub... |
NodeDiskModel obj = (NodeDiskModel) object3d;
if (config.isDisableLOD()) {
obj.modelType = SHAPE_DISK64;
obj.modelBorderType = BORDER64;
return;
}
float distance = cameraDistance(obj) / (obj.getNode().size() * drawable.getGlobalScale());
if (... | 1,134 | 212 | 1,346 | <methods>public void <init>(org.gephi.visualization.opengl.CompatibilityEngine) ,public abstract void afterDisplay(GL2, GLU) ,public abstract void beforeDisplay(GL2, GLU) ,public abstract void chooseModel(org.gephi.visualization.model.Model) ,public abstract int initDisplayLists(GL2, GLU, GLUquadric, int) ,public boole... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/octree/Octant.java | Octant | displayOctant | class Octant {
//Static
protected static final long ONEOVERPHI = 106039;
protected static final float TRIM_THRESHOLD = 1000;
protected static final float TRIM_RATIO = 0.3f;
//LeafId
protected int leafId = Octree.NULL_ID;
//Coordinates
protected float size;
protected float posX;
... |
float quantum = size / 2;
gl.glBegin(GL2.GL_QUAD_STRIP);
gl.glVertex3f(posX + quantum, posY + quantum, posZ + quantum);
gl.glVertex3f(posX + quantum, posY - quantum, posZ + quantum);
gl.glVertex3f(posX + quantum, posY + quantum, posZ - quantum);
gl.glVertex3f(posX + qua... | 1,488 | 495 | 1,983 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/octree/Octree.java | OctantIterator | hasNext | class OctantIterator implements Iterator<NodeModel> {
private final boolean ignoreVisibility;
private int leafId;
private Octant octant;
private int leavesLength;
private NodeModel[] nodes;
private int nodesId;
private int nodesLength;
private NodeModel p... |
pointer = null;
while (pointer == null) {
while (nodesId < nodesLength && pointer == null) {
pointer = nodes[nodesId++];
}
if (pointer == null) {
octant = null;
while (leafId < leavesLeng... | 248 | 174 | 422 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/opengl/AbstractEngine.java | EngineLifeCycle | setInited | class EngineLifeCycle {
private boolean started;
private boolean inited;
private boolean requestAnimation;
public void requestPauseAnimating() {
if (inited) {
stopAnimating();
}
}
public void requestResumeAnimating() {
... |
if (!inited) {
inited = true;
if (requestAnimation) {
//graphDrawable.display();
startAnimating();
requestAnimation = false;
}
} else {
dataBridge.reset();
... | 239 | 77 | 316 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/opengl/GraphicalConfiguration.java | GraphicalConfiguration | checkGeneralCompatibility | class GraphicalConfiguration {
private static boolean messageDelivered = false;
private final GLProfile profile = GLProfile.get(GLProfile.GL2);
private final GLCapabilities caps = new GLCapabilities(profile);
private final AbstractGraphicsDevice device = GLDrawableFactory.getFactory(profile).getDefault... |
if (messageDelivered) {
return;
}
try {
//Vendor
vendor = gl.glGetString(GL2.GL_VENDOR);
renderer = gl.glGetString(GL2.GL_RENDERER);
versionStr = gl.glGetString(GL2.GL_VERSION);
String currentConfig = String
... | 275 | 461 | 736 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/options/DefaultOptionsPanelController.java | DefaultOptionsPanelController | getPanel | class DefaultOptionsPanelController extends OptionsPanelController {
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
private DefaultPanel panel;
private boolean changed;
@Override
public void update() {
getPanel().load();
changed = false;
}
@Over... |
if (panel == null) {
panel = new DefaultPanel(this);
}
return panel;
| 410 | 30 | 440 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/scheduler/AbstractAnimator.java | AbstractAnimator | run | class AbstractAnimator extends Thread {
//Runnable
protected final Runnable runnable;
//Lock
protected final Semaphore semaphore;
//Flag
protected boolean animating = true;
public AbstractAnimator(Runnable runnable, Semaphore semaphore, String name) {
super(name);
this.sema... |
while (animating) {
synchronized (this) {
try {
wait();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
runnable.run();
semaphore.release();
}
... | 204 | 72 | 276 | <methods>public void <init>() ,public void <init>(java.lang.Runnable) ,public void <init>(java.lang.String) ,public void <init>(java.lang.ThreadGroup, java.lang.Runnable) ,public void <init>(java.lang.ThreadGroup, java.lang.String) ,public void <init>(java.lang.Runnable, java.lang.String) ,public void <init>(java.lang.... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/scheduler/BasicFPSAnimator.java | BasicFPSAnimator | run | class BasicFPSAnimator extends Thread {
//Runnable
protected final Runnable runnable;
//Lock
protected final Object worldLock;
protected final Object lock = new Object();
//Fps
protected long startTime;
protected long delay;
//Flag
protected boolean animating = true;
public... |
while (animating) {
startTime = System.currentTimeMillis();
//Execute
synchronized (worldLock) {
runnable.run();
}
//End
long timeout;
while ((timeout = delay - System.currentTimeMillis() + startTime) > 0) {
... | 291 | 160 | 451 | <methods>public void <init>() ,public void <init>(java.lang.Runnable) ,public void <init>(java.lang.String) ,public void <init>(java.lang.ThreadGroup, java.lang.Runnable) ,public void <init>(java.lang.ThreadGroup, java.lang.String) ,public void <init>(java.lang.Runnable, java.lang.String) ,public void <init>(java.lang.... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/scheduler/CompatibilityScheduler.java | CompatibilityScheduler | initArchitecture | class CompatibilityScheduler implements Scheduler, VizArchitecture {
private final float updateFpsLimit = 5f;
private final Object worldLock = new Object();
//States
AtomicBoolean animating = new AtomicBoolean();
AtomicBoolean cameraMoved = new AtomicBoolean();
AtomicBoolean mouseMoved = new At... |
this.graphDrawable = VizController.getInstance().getDrawable();
this.engine = (CompatibilityEngine) VizController.getInstance().getEngine();
this.vizConfig = VizController.getInstance().getVizConfig();
| 1,298 | 60 | 1,358 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/screenshot/OffscreenCanvas.java | OffscreenCanvas | display | class OffscreenCanvas extends GLAbstractListener implements TileRendererBase.TileRendererListener {
private final boolean transparentBackground;
public OffscreenCanvas(int width, int height, boolean transparentBackground, int antialiasing) {
super();
final GLProfile glp = GLProfile.get(GLProf... |
GL2 gl = drawable.getGL().getGL2();
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
float[] backgroundColor = vizController.getVizModel().getBackgroundColorComponents();
gl.glClearColor(backgroundColor[0], backgroundColor[1], backgroundColor[2], transparentBackground ? 0f : 1f);
engine.d... | 1,140 | 107 | 1,247 | <methods>public void <init>() ,public void destroy() ,public void display(GLAutoDrawable) ,public void display() ,public void dispose(GLAutoDrawable) ,public float[] getCameraLocation() ,public float[] getCameraTarget() ,public org.gephi.lib.gleem.linalg.Vec3f getCameraVector() ,public double getDraggingMarkerX() ,publ... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/selection/Cylinder.java | Cylinder | drawArea | class Cylinder implements SelectionArea {
//Variables
private static final float[] RECT_POINT = {1, 1};
//Architecture
private final GraphIO graphIO;
private final GraphDrawable drawable;
private final SelectionManager selectionManager;
private final VizModel vizModel;
private final flo... |
float diameter = selectionManager.getMouseSelectionDiameter();
if (diameter == 1) {
//Point
} else {
//Cylinder
float radius;
if (selectionManager.isMouseSelectionZoomProportionnal()) {
radius = (float) (diameter * Math.abs(drawabl... | 568 | 375 | 943 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/selection/Rectangle.java | Rectangle | start | class Rectangle implements SelectionArea {
private static final float[] POINT_RECT = {1, 1};
private final GraphDrawable drawable;
private final VizConfig config;
private final float[] color;
private final float[] rectangle = new float[2];
private final float[] rectangle3d = new float[2];
p... |
this.startPosition = Arrays.copyOf(mousePosition, 2);
this.startPosition3d = Arrays.copyOf(mousePosition3d, 2);
this.rectangle[0] = startPosition[0];
this.rectangle[1] = startPosition[1];
this.rectangle3d[0] = startPosition3d[0];
this.rectangle3d[1] = startPosition3d[1];... | 1,523 | 125 | 1,648 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/swing/GraphCanvas.java | GraphCanvas | render3DScene | class GraphCanvas extends GLAbstractListener {
private final GLUT glut = new GLUT();
@Override
protected GLAutoDrawable initDrawable() {
GLCanvas glCanvas = new GLCanvas(getCaps());
// glCanvas.setMinimumSize(new Dimension(0, 0)); //Fix Canvas resize Issue
graphComponent = glCanv... |
if (vizController.getVizConfig().isShowFPS()) {
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport);
glu.gluOrtho2D(0,... | 342 | 291 | 633 | <methods>public void <init>() ,public void destroy() ,public void display(GLAutoDrawable) ,public void display() ,public void dispose(GLAutoDrawable) ,public float[] getCameraLocation() ,public float[] getCameraTarget() ,public org.gephi.lib.gleem.linalg.Vec3f getCameraVector() ,public double getDraggingMarkerX() ,publ... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/swing/NewtGraphCanvas.java | NewtGraphCanvas | render3DScene | class NewtGraphCanvas extends GLAbstractListener {
private final GLUT glut = new GLUT();
private NewtCanvasAWT glCanvas;
@Override
protected GLAutoDrawable initDrawable() {
GLWindow glWindow = GLWindow.create(getCaps());
// glWindow.setSurfaceScale(new float[]{ScalableSurface.AUTOMAX_P... |
if (vizController.getVizConfig().isShowFPS()) {
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport);
glu.gluOrtho2D(0,... | 824 | 359 | 1,183 | <methods>public void <init>() ,public void destroy() ,public void display(GLAutoDrawable) ,public void display() ,public void dispose(GLAutoDrawable) ,public float[] getCameraLocation() ,public float[] getCameraTarget() ,public org.gephi.lib.gleem.linalg.Vec3f getCameraVector() ,public double getDraggingMarkerX() ,publ... |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/text/ObjectColorMode.java | ObjectColorMode | textColor | class ObjectColorMode implements ColorMode {
private final VizConfig vizConfig;
public ObjectColorMode() {
this.vizConfig = VizController.getInstance().getVizConfig();
}
@Override
public void defaultEdgeColor(Renderer renderer) {
}
@Override
public void defaultNodeColor(Rende... |
if (vizConfig.isLightenNonSelected()) {
if (!selected) {
float lightColorFactor = 1 - vizConfig.getLightenNonSelectedFactor();
renderer.setColor(text.getElementProperties().r(), text.getElementProperties().g(),
text.getElementProperties().b(), lig... | 341 | 171 | 512 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/text/TextColorMode.java | TextColorMode | textColor | class TextColorMode implements ColorMode {
private final VizConfig vizConfig;
private float[] color;
public TextColorMode() {
this.vizConfig = VizController.getInstance().getVizConfig();
}
@Override
public void defaultNodeColor(Renderer renderer) {
color = VizController.getIns... |
if (text.hasCustomTextColor()) {
if (vizConfig.isLightenNonSelected()) {
if (!selected) {
float lightColorFactor = 1 - vizConfig.getLightenNonSelectedFactor();
renderer.setColor(text.getTextR(), text.getTextG(), text.getTextB(), lightColorFact... | 379 | 291 | 670 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/text/TextManager.java | Renderer3D | drawTextEdge | class Renderer3D implements Renderer {
private TextRenderer renderer;
@Override
public void initRenderer(Font font) {
renderer = new TextRenderer(font, antialised, fractionalMetrics, null, shouldUseMipmapGeneration());
}
@Override
public void reinitRenderer... |
Edge edge = objectModel.getEdge();
TextProperties textData = (TextProperties) edge.getTextProperties();
if (textData != null) {
String txt = textData.getText();
float width, height, posX, posY;
if (txt == null || txt.isEmpty()) {
... | 989 | 495 | 1,484 | <no_super_class> |
gephi_gephi | gephi/modules/VisualizationImpl/src/main/java/org/gephi/visualization/text/UniqueColorMode.java | UniqueColorMode | textColor | class UniqueColorMode implements ColorMode {
private final VizConfig vizConfig;
private float[] color;
public UniqueColorMode() {
this.vizConfig = VizController.getInstance().getVizConfig();
}
@Override
public void defaultNodeColor(Renderer renderer) {
color = VizController.ge... |
if (vizConfig.isLightenNonSelected()) {
if (!selected) {
float lightColorFactor = 1 - vizConfig.getLightenNonSelectedFactor();
renderer.setColor(color[0], color[1], color[2], lightColorFactor);
} else {
renderer.setColor(color[0], color[1]... | 432 | 134 | 566 | <no_super_class> |
gephi_gephi | gephi/modules/WelcomeScreen/src/main/java/org/gephi/desktop/welcome/Installer.java | Installer | restored | class Installer extends ModuleInstall {
@Override
public void restored() {<FILL_FUNCTION_BODY>}
} |
if (NbPreferences.forModule(WelcomeTopComponent.class)
.getBoolean(WelcomeTopComponent.STARTUP_PREF, Boolean.TRUE)) {
WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
@Override
public void run() {
WelcomeTopComponent comp... | 34 | 170 | 204 | <no_super_class> |
gephi_gephi | gephi/modules/WelcomeScreen/src/main/java/org/gephi/desktop/welcome/WelcomeAction.java | WelcomeAction | run | class WelcomeAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {<FILL_FUNCTION_BODY>}
});
}
} |
WelcomeTopComponent component = WelcomeTopComponent.getInstance();
JDialog dialog = new JDialog(WindowManager.getDefault().getMainWindow(),
component.getName(), false);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
... | 74 | 113 | 187 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/Doc.java | Level | computeBroken | class Level extends Doc {
private final Indent plusIndent; // The extra indent following breaks.
private final List<Doc> docs = new ArrayList<>(); // The elements of the level.
private Level(Indent plusIndent) {
this.plusIndent = plusIndent;
}
/**
* Factory method for {@code Level}s.
... |
splitByBreaks(docs, splits, breaks);
state =
computeBreakAndSplit(
commentsHelper, maxWidth, state, /* optBreakDoc= */ Optional.empty(), splits.get(0));
// Handle following breaks and split.
for (int i = 0; i < breaks.size(); i++) {
state =
computeB... | 1,603 | 134 | 1,737 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/DocBuilder.java | DocBuilder | withOps | class DocBuilder {
private final Doc.Level base = Doc.Level.make(Indent.Const.ZERO);
private final ArrayDeque<Doc.Level> stack = new ArrayDeque<>();
/**
* A possibly earlier {@link Doc.Level} for appending text, à la Philip Wadler.
*
* <p>Processing {@link Doc}s presents a subtle problem. Suppose we hav... |
for (Op op : ops) {
op.add(this); // These operations call the operations below to build the doc.
}
return this;
| 848 | 42 | 890 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/FormatterDiagnostic.java | FormatterDiagnostic | toString | class FormatterDiagnostic {
private final int lineNumber;
private final String message;
private final int column;
public static FormatterDiagnostic create(String message) {
return new FormatterDiagnostic(-1, -1, message);
}
public static FormatterDiagnostic create(int lineNumber, int column, String me... |
StringBuilder sb = new StringBuilder();
if (lineNumber >= 0) {
sb.append(lineNumber).append(':');
}
if (column >= 0) {
// internal column numbers are 0-based, but diagnostics use 1-based indexing by convention
sb.append(column + 1).append(':');
}
if (lineNumber >= 0 || column ... | 349 | 135 | 484 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/Indent.java | If | toString | class If extends Indent {
private final BreakTag condition;
private final Indent thenIndent;
private final Indent elseIndent;
private If(BreakTag condition, Indent thenIndent, Indent elseIndent) {
this.condition = condition;
this.thenIndent = thenIndent;
this.elseIndent = elseIndent;
... |
return MoreObjects.toStringHelper(this)
.add("condition", condition)
.add("thenIndent", thenIndent)
.add("elseIndent", elseIndent)
.toString();
| 202 | 54 | 256 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/InputOutput.java | InputOutput | computeRanges | class InputOutput {
private ImmutableList<String> lines = ImmutableList.of();
protected static final Range<Integer> EMPTY_RANGE = Range.closedOpen(-1, -1);
private static final DiscreteDomain<Integer> INTEGERS = DiscreteDomain.integers();
/** Set the lines. */
protected final void setLines(ImmutableList<Str... |
int lineI = 0;
for (Input.Tok tok : toks) {
String txt = tok.getOriginalText();
int lineI0 = lineI;
lineI += Newlines.count(txt);
int k = tok.getIndex();
if (k >= 0) {
for (int i = lineI0; i <= lineI; i++) {
addToRanges(ranges, i, k);
}
}
}
| 841 | 119 | 960 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/Newlines.java | LineOffsetIterator | next | class LineOffsetIterator implements Iterator<Integer> {
private int curr = 0;
private int idx = 0;
private final String input;
private LineOffsetIterator(String input) {
this.input = input;
}
@Override
public boolean hasNext() {
return curr != -1;
}
@Override
publ... |
if (curr == -1) {
throw new NoSuchElementException();
}
int result = curr;
advance();
return result;
| 273 | 43 | 316 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/Output.java | BreakTag | recordBroken | class BreakTag {
Optional<Boolean> taken = Optional.empty();
public void recordBroken(boolean broken) {<FILL_FUNCTION_BODY>}
public boolean wasBreakTaken() {
return taken.orElse(false);
}
} |
// TODO(cushon): enforce invariants.
// Currently we rely on setting Breaks multiple times, e.g. when deciding
// whether a Level should be flowed. Using separate data structures
// instead of mutation or adding an explicit 'reset' step would allow
// a useful invariant to be enforced her... | 71 | 89 | 160 | <methods>public non-sealed void <init>() ,public final java.lang.String getLine(int) ,public final int getLineCount() ,public final Range<java.lang.Integer> getRanges(int) ,public static Map<java.lang.Integer,Range<java.lang.Integer>> makeKToIJ(com.google.googlejavaformat.InputOutput) ,public java.lang.String toString(... |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/CommandLineOptions.java | Builder | build | class Builder {
private final ImmutableList.Builder<String> files = ImmutableList.builder();
private final RangeSet<Integer> lines = TreeRangeSet.create();
private final ImmutableList.Builder<Integer> offsets = ImmutableList.builder();
private final ImmutableList.Builder<Integer> lengths = ImmutableLis... |
return new CommandLineOptions(
files.build(),
inPlace,
ImmutableRangeSet.copyOf(lines),
offsets.build(),
lengths.build(),
aosp,
version,
help,
stdin,
fixImportsOnly,
sortImports,
removeUnusedIm... | 784 | 119 | 903 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/CommandLineOptionsParser.java | CommandLineOptionsParser | parse | class CommandLineOptionsParser {
private static final Splitter COMMA_SPLITTER = Splitter.on(',');
private static final Splitter COLON_SPLITTER = Splitter.on(':');
private static final Splitter ARG_SPLITTER =
Splitter.on(CharMatcher.breakingWhitespace()).omitEmptyStrings().trimResults();
/** Parses {@lin... |
CommandLineOptions.Builder optionsBuilder = CommandLineOptions.builder();
List<String> expandedOptions = new ArrayList<>();
expandParamsFiles(options, expandedOptions);
Iterator<String> it = expandedOptions.iterator();
while (it.hasNext()) {
String option = it.next();
if (!option.starts... | 971 | 773 | 1,744 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/DimensionHelpers.java | TypeWithDims | extractDims | class TypeWithDims {
final Tree node;
final ImmutableList<List<AnnotationTree>> dims;
public TypeWithDims(Tree node, ImmutableList<List<AnnotationTree>> dims) {
this.node = node;
this.dims = dims;
}
}
enum SortedDims {
YES,
NO
}
/** Returns a (possibly re-ordered) {@link T... |
Deque<List<AnnotationTree>> builder = new ArrayDeque<>();
node = extractDims(builder, node);
Iterable<List<AnnotationTree>> dims;
if (sorted == SortedDims.YES) {
dims = reorderBySourcePosition(builder);
} else {
dims = builder;
}
return new TypeWithDims(node, ImmutableList.copyO... | 155 | 113 | 268 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/FormatFileCallable.java | Result | fixImports | class Result {
abstract @Nullable Path path();
abstract String input();
abstract @Nullable String output();
boolean changed() {
return !input().equals(output());
}
abstract @Nullable FormatterException exception();
static Result create(
@Nullable Path path,
String ... |
if (parameters.removeUnusedImports()) {
input = RemoveUnusedImports.removeUnusedImports(input);
}
if (parameters.sortImports()) {
input = ImportOrderer.reorderImports(input, options.style());
}
return input;
| 446 | 76 | 522 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatTool.java | GoogleJavaFormatTool | run | class GoogleJavaFormatTool implements Tool {
@Override
public String name() {
return "google-java-format";
}
@Override
public Set<SourceVersion> getSourceVersions() {
return Arrays.stream(SourceVersion.values()).collect(toImmutableEnumSet());
}
@Override
public int run(InputStream in, OutputSt... |
PrintStream outStream = new PrintStream(out);
PrintStream errStream = new PrintStream(err);
try {
return Main.main(in, outStream, errStream, args);
} catch (RuntimeException e) {
errStream.print(e.getMessage());
errStream.flush();
return 1; // pass non-zero value back indicating... | 117 | 99 | 216 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatToolProvider.java | GoogleJavaFormatToolProvider | run | class GoogleJavaFormatToolProvider implements ToolProvider {
@Override
public String name() {
return "google-java-format";
}
@Override
public int run(PrintWriter out, PrintWriter err, String... args) {<FILL_FUNCTION_BODY>}
} |
try {
return Main.main(System.in, out, err, args);
} catch (RuntimeException e) {
err.print(e.getMessage());
err.flush();
return 1; // pass non-zero value back indicating an error has happened
}
| 73 | 71 | 144 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/ImportOrderer.java | StringAndIndex | scanImported | class StringAndIndex {
private final String string;
private final int index;
StringAndIndex(String string, int index) {
this.string = string;
this.index = index;
}
}
/**
* Scans the imported thing, the dot-separated name that comes after import [static] and before
* the semicolon... |
int i = start;
StringBuilder imported = new StringBuilder();
// At the start of each iteration of this loop, i points to an identifier.
// On exit from the loop, i points to a token after an identifier or after *.
while (true) {
Preconditions.checkState(isIdentifierToken(i));
imported.a... | 286 | 222 | 508 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/JavaCommentsHelper.java | JavaCommentsHelper | javadocShaped | class JavaCommentsHelper implements CommentsHelper {
private final String lineSeparator;
private final JavaFormatterOptions options;
public JavaCommentsHelper(String lineSeparator, JavaFormatterOptions options) {
this.lineSeparator = lineSeparator;
this.options = options;
}
@Override
public Strin... |
Iterator<String> it = lines.iterator();
if (!it.hasNext()) {
return false;
}
String first = it.next().trim();
// if it's actually javadoc, we're done
if (first.startsWith("/**")) {
return true;
}
// if it's a block comment, check all trailing lines for '*'
if (!first.sta... | 1,535 | 165 | 1,700 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/JavacTokens.java | RawTok | readAllTokens | class RawTok {
private final String stringVal;
private final TokenKind kind;
private final int pos;
private final int endPos;
RawTok(String stringVal, TokenKind kind, int pos, int endPos) {
checkElementIndex(pos, endPos, "pos");
checkArgument(pos < endPos, "expected pos (%s) < endPos (%... |
if (source == null) {
return ImmutableList.of();
}
ScannerFactory fac = ScannerFactory.instance(context);
char[] buffer = (source + EOF_COMMENT).toCharArray();
Scanner scanner =
new AccessibleScanner(fac, new CommentSavingTokenizer(fac, buffer, buffer.length));
List<Token> tokens ... | 420 | 381 | 801 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/ModifierOrderer.java | ModifierOrderer | asModifier | class ModifierOrderer {
/** Reorders all modifiers in the given text to be in JLS order. */
static JavaInput reorderModifiers(String text) throws FormatterException {
return reorderModifiers(
new JavaInput(text), ImmutableList.of(Range.closedOpen(0, text.length())));
}
/**
* Reorders all modifi... |
TokenKind kind = ((JavaInput.Tok) token.getTok()).kind();
if (kind != null) {
switch (kind) {
case PUBLIC:
return Modifier.PUBLIC;
case PROTECTED:
return Modifier.PROTECTED;
case PRIVATE:
return Modifier.PRIVATE;
case ABSTRACT:
retur... | 1,049 | 335 | 1,384 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/RemoveUnusedImports.java | UnusedImportScanner | caseTreeGetLabels | class UnusedImportScanner extends TreePathScanner<Void, Void> {
private final Set<String> usedNames = new LinkedHashSet<>();
private final Multimap<String, Range<Integer>> usedInJavadoc = HashMultimap.create();
final JavacTrees trees;
final DocTreeScanner docTreeSymbolScanner;
private UnusedImport... |
try {
return CaseTree.class.getMethod("getLabels");
} catch (NoSuchMethodException e) {
return null;
}
| 1,131 | 42 | 1,173 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/Replacement.java | Replacement | create | class Replacement {
public static Replacement create(int startPosition, int endPosition, String replaceWith) {<FILL_FUNCTION_BODY>}
private final Range<Integer> replaceRange;
private final String replacementString;
private Replacement(Range<Integer> replaceRange, String replacementString) {
this.replaceR... |
checkArgument(startPosition >= 0, "startPosition must be non-negative");
checkArgument(startPosition <= endPosition, "startPosition cannot be after endPosition");
return new Replacement(Range.closedOpen(startPosition, endPosition), replaceWith);
| 316 | 63 | 379 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/SnippetFormatter.java | SnippetWrapper | snippetWrapper | class SnippetWrapper {
int offset;
final StringBuilder contents = new StringBuilder();
public SnippetWrapper append(String str) {
contents.append(str);
return this;
}
public SnippetWrapper appendSource(String source) {
this.offset = contents.length();
contents.append(source... |
/*
* Synthesize a dummy class around the code snippet provided by Eclipse. The dummy class is
* correctly formatted -- the blocks use correct indentation, etc.
*/
switch (kind) {
case COMPILATION_UNIT:
{
SnippetWrapper wrapper = new SnippetWrapper();
for (int i... | 1,357 | 541 | 1,898 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/StringWrapper.java | LongStringsAndTextBlockScanner | wrapLongStrings | class LongStringsAndTextBlockScanner extends TreePathScanner<Void, Void> {
private final List<TreePath> longStringLiterals;
private final List<Tree> textBlocks;
LongStringsAndTextBlockScanner(List<TreePath> longStringLiterals, List<Tree> textBlocks) {
this.longStringLiterals = longStringLite... |
for (TreePath path : longStringLiterals) {
// Find the outermost contiguous enclosing concatenation expression
TreePath enclosing = path;
while (enclosing.getParentPath().getLeaf().getKind() == Kind.PLUS) {
enclosing = enclosing.getParentPath();
}
// Is the liter... | 990 | 455 | 1,445 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/Trees.java | Trees | operatorName | class Trees {
/** Returns the length of the source for the node. */
static int getLength(Tree tree, TreePath path) {
return getEndPosition(tree, path) - getStartPosition(tree);
}
/** Returns the source start position of the node. */
static int getStartPosition(Tree expression) {
return ((JCTree) expr... |
JCTree.Tag tag = ((JCTree) expression).getTag();
if (tag == JCTree.Tag.ASSIGN) {
return "=";
}
boolean assignOp = expression instanceof CompoundAssignmentTree;
if (assignOp) {
tag = tag.noAssignOp();
}
String name = new Pretty(/*writer*/ null, /*sourceOutput*/ true).operatorName... | 740 | 122 | 862 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/TypeNameClassifier.java | TypeNameClassifier | from | class TypeNameClassifier {
private TypeNameClassifier() {}
/** A state machine for classifying qualified names. */
private enum TyParseState {
/** The start state. */
START(false) {
@Override
public TyParseState next(JavaCaseFormat n) {
switch (n) {
case UPPERCASE:
... |
Verify.verify(!name.isEmpty());
boolean firstUppercase = false;
boolean hasUppercase = false;
boolean hasLowercase = false;
boolean first = true;
for (int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
if (!Character.isAlphabetic(c)) {
continue;
... | 1,052 | 239 | 1,291 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/UsageException.java | UsageException | buildMessage | class UsageException extends Exception {
private static final Joiner NEWLINE_JOINER = Joiner.on(System.lineSeparator());
private static final String[] DOCS_LINK = {
"https://github.com/google/google-java-format",
};
private static final String[] USAGE = {
"",
"Usage: google-java-format [options] ... |
StringBuilder builder = new StringBuilder();
if (message != null) {
builder.append(message).append('\n');
}
appendLines(builder, USAGE);
appendLines(builder, ADDITIONAL_USAGE);
appendLines(builder, new String[] {""});
appendLine(builder, Main.versionString());
appendLines(builder,... | 893 | 112 | 1,005 | <methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.Throwable) ,public void <init>(java.lang.String, java.lang.Throwable) <variables>static final long serialVersionUID |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/filer/FormattingJavaFileObject.java | FormattingJavaFileObject | openWriter | class FormattingJavaFileObject extends ForwardingJavaFileObject<JavaFileObject> {
/** A rough estimate of the average file size: 80 chars per line, 500 lines. */
private static final int DEFAULT_FILE_SIZE = 80 * 500;
private final Formatter formatter;
private final Messager messager;
/**
* Create a new {... |
final StringBuilder stringBuilder = new StringBuilder(DEFAULT_FILE_SIZE);
return new Writer() {
@Override
public void write(char[] chars, int start, int end) throws IOException {
stringBuilder.append(chars, start, end - start);
}
@Override
public void write(String string)... | 233 | 324 | 557 | <methods>public javax.lang.model.element.Modifier getAccessLevel() ,public javax.tools.JavaFileObject.Kind getKind() ,public javax.lang.model.element.NestingKind getNestingKind() ,public boolean isNameCompatible(java.lang.String, javax.tools.JavaFileObject.Kind) <variables> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/javadoc/CharStream.java | CharStream | readAndResetRecorded | class CharStream {
String remaining;
int toConsume;
CharStream(String input) {
this.remaining = checkNotNull(input);
}
boolean tryConsume(String expected) {
if (!remaining.startsWith(expected)) {
return false;
}
toConsume = expected.length();
return true;
}
/*
* @param patt... |
String result = remaining.substring(0, toConsume);
remaining = remaining.substring(toConsume);
toConsume = 0; // TODO(cpovirk): Set this to a bogus value here and in the constructor.
return result;
| 248 | 66 | 314 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocFormatter.java | JavadocFormatter | render | class JavadocFormatter {
static final int MAX_LINE_LENGTH = 100;
/**
* Formats the given Javadoc comment, which must start with ∕✱✱ and end with ✱∕. The output will
* start and end with the same characters.
*/
public static String formatJavadoc(String input, int blockIndent) {
ImmutableList<Token> ... |
JavadocWriter output = new JavadocWriter(blockIndent);
for (Token token : input) {
switch (token.getType()) {
case BEGIN_JAVADOC:
output.writeBeginJavadoc();
break;
case END_JAVADOC:
output.writeEndJavadoc();
return output.toString();
case F... | 886 | 750 | 1,636 | <no_super_class> |
google_google-java-format | google-java-format/core/src/main/java/com/google/googlejavaformat/java/javadoc/Token.java | Token | toString | class Token {
/**
* Javadoc token type.
*
* <p>The general idea is that every token that requires special handling (extra line breaks,
* indentation, forcing or forbidding whitespace) from {@link JavadocWriter} gets its own type.
* But I haven't been super careful about it, so I'd imagine that we could... |
return "\n" + getType() + ": " + getValue();
| 1,359 | 21 | 1,380 | <no_super_class> |
google_gson | gson/extras/src/main/java/com/google/gson/extras/examples/rawcollections/RawCollectionsExample.java | Event | main | class Event {
private String name;
private String source;
private Event(String name, String source) {
this.name = name;
this.source = source;
}
@Override
public String toString() {
return String.format("(name=%s, source=%s)", name, source);
}
}
@SuppressWarnings({"un... |
Gson gson = new Gson();
Collection collection = new ArrayList();
collection.add("hello");
collection.add(5);
collection.add(new Event("GREETINGS", "guest"));
String json = gson.toJson(collection);
System.out.println("Using Gson.toJson() on a raw collection: " + json);
JsonArray array = ... | 131 | 208 | 339 | <no_super_class> |
google_gson | gson/extras/src/main/java/com/google/gson/graph/GraphAdapterBuilder.java | Factory | write | class Factory implements TypeAdapterFactory, InstanceCreator<Object> {
private final Map<Type, InstanceCreator<?>> instanceCreators;
@SuppressWarnings("ThreadLocalUsage")
private final ThreadLocal<Graph> graphThreadLocal = new ThreadLocal<>();
Factory(Map<Type, InstanceCreator<?>> instanceCreators) {
... |
if (value == null) {
out.nullValue();
return;
}
Graph graph = graphThreadLocal.get();
boolean writeEntireGraph = false;
/*
* We have one of two cases:
* 1. We've encountered the first known object in this graph. Write
... | 1,054 | 415 | 1,469 | <no_super_class> |
google_gson | gson/extras/src/main/java/com/google/gson/interceptors/InterceptorFactory.java | InterceptorFactory | create | class InterceptorFactory implements TypeAdapterFactory {
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {<FILL_FUNCTION_BODY>}
static class InterceptorAdapter<T> extends TypeAdapter<T> {
private final TypeAdapter<T> delegate;
private final JsonPostDeserializer<T> postDeserialize... |
Intercept intercept = type.getRawType().getAnnotation(Intercept.class);
if (intercept == null) {
return null;
}
TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
return new InterceptorAdapter<>(delegate, intercept);
| 289 | 80 | 369 | <no_super_class> |
google_gson | gson/extras/src/main/java/com/google/gson/typeadapters/PostConstructAdapterFactory.java | PostConstructAdapter | read | class PostConstructAdapter<T> extends TypeAdapter<T> {
private final TypeAdapter<T> delegate;
private final Method method;
public PostConstructAdapter(TypeAdapter<T> delegate, Method method) {
this.delegate = delegate;
this.method = method;
}
@Override
public T read(JsonReader in) ... |
T result = delegate.read(in);
if (result != null) {
try {
method.invoke(result);
} catch (IllegalAccessException e) {
throw new AssertionError(e);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof RuntimeException) {
throw ... | 140 | 125 | 265 | <no_super_class> |
google_gson | gson/extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java | RuntimeTypeAdapterFactory | write | class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory {
private final Class<?> baseType;
private final String typeFieldName;
private final Map<String, Class<?>> labelToSubtype = new LinkedHashMap<>();
private final Map<Class<?>, String> subtypeToLabel = new LinkedHashMap<>();
private final boolean ... |
Class<?> srcType = value.getClass();
String label = subtypeToLabel.get(srcType);
@SuppressWarnings("unchecked") // registration requires that subtype extends T
TypeAdapter<R> delegate = (TypeAdapter<R>) subtypeToDelegate.get(srcType);
if (delegate == null) {
throw new ... | 1,500 | 316 | 1,816 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/JsonParser.java | JsonParser | parseReader | class JsonParser {
/**
* @deprecated No need to instantiate this class, use the static methods instead.
*/
@Deprecated
public JsonParser() {}
/**
* Parses the specified JSON string into a parse tree. An exception is thrown if the JSON string
* has multiple top-level JSON elements, or if there is tr... |
Strictness strictness = reader.getStrictness();
if (strictness == Strictness.LEGACY_STRICT) {
// For backward compatibility change to LENIENT if reader has default strictness LEGACY_STRICT
reader.setStrictness(Strictness.LENIENT);
}
try {
return Streams.parse(reader);
} catch (Sta... | 1,031 | 190 | 1,221 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/JsonStreamParser.java | JsonStreamParser | next | class JsonStreamParser implements Iterator<JsonElement> {
private final JsonReader parser;
private final Object lock;
/**
* @param json The string containing JSON elements concatenated to each other.
* @since 1.4
*/
public JsonStreamParser(String json) {
this(new StringReader(json));
}
/**
... |
if (!hasNext()) {
throw new NoSuchElementException();
}
try {
return Streams.parse(parser);
} catch (StackOverflowError e) {
throw new JsonParseException("Failed parsing JSON source to Json", e);
} catch (OutOfMemoryError e) {
throw new JsonParseException("Failed parsing JS... | 542 | 101 | 643 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/TypeAdapter.java | TypeAdapter | nullSafe | class TypeAdapter<T> {
public TypeAdapter() {}
/**
* Writes one JSON value (an array, object, string, number, boolean or null) for {@code value}.
*
* @param value the Java object to write. May be null.
*/
public abstract void write(JsonWriter out, T value) throws IOException;
/**
* Converts {@... |
return new TypeAdapter<T>() {
@Override
public void write(JsonWriter out, T value) throws IOException {
if (value == null) {
out.nullValue();
} else {
TypeAdapter.this.write(out, value);
}
}
@Override
public T read(JsonReader reader) throws... | 1,775 | 141 | 1,916 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/$Gson$Preconditions.java | $Gson$Preconditions | checkNotNull | class $Gson$Preconditions {
private $Gson$Preconditions() {
throw new UnsupportedOperationException();
}
/**
* @deprecated This is an internal Gson method. Use {@link Objects#requireNonNull(Object)}
* instead.
*/
// Only deprecated for now because external projects might be using this by accid... |
if (obj == null) {
throw new NullPointerException();
}
return obj;
| 154 | 28 | 182 | |
google_gson | gson/gson/src/main/java/com/google/gson/internal/Excluder.java | Excluder | create | class Excluder implements TypeAdapterFactory, Cloneable {
private static final double IGNORE_VERSIONS = -1.0d;
public static final Excluder DEFAULT = new Excluder();
private double version = IGNORE_VERSIONS;
private int modifiers = Modifier.TRANSIENT | Modifier.STATIC;
private boolean serializeInnerClasses =... |
Class<?> rawType = type.getRawType();
final boolean skipSerialize = excludeClass(rawType, true);
final boolean skipDeserialize = excludeClass(rawType, false);
if (!skipSerialize && !skipDeserialize) {
return null;
}
return new TypeAdapter<T>() {
/**
* The delegate is lazil... | 1,486 | 350 | 1,836 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/JavaVersion.java | JavaVersion | extractBeginningInt | class JavaVersion {
// Oracle defines naming conventions at
// http://www.oracle.com/technetwork/java/javase/versioning-naming-139433.html
// However, many alternate implementations differ. For example, Debian used 9-debian as the
// version string
private static final int majorJavaVersion = determineMajorJa... |
try {
StringBuilder num = new StringBuilder();
for (int i = 0; i < javaVersion.length(); ++i) {
char c = javaVersion.charAt(i);
if (Character.isDigit(c)) {
num.append(c);
} else {
break;
}
}
return Integer.parseInt(num.toString());
} c... | 571 | 118 | 689 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/LazilyParsedNumber.java | LazilyParsedNumber | equals | class LazilyParsedNumber extends Number {
private final String value;
/**
* @param value must not be null
*/
public LazilyParsedNumber(String value) {
this.value = value;
}
private BigDecimal asBigDecimal() {
return NumberLimits.parseBigDecimal(value);
}
@Override
public int intValue() ... |
if (this == obj) {
return true;
}
if (obj instanceof LazilyParsedNumber) {
LazilyParsedNumber other = (LazilyParsedNumber) obj;
return value.equals(other.value);
}
return false;
| 498 | 76 | 574 | <methods>public void <init>() ,public byte byteValue() ,public abstract double doubleValue() ,public abstract float floatValue() ,public abstract int intValue() ,public abstract long longValue() ,public short shortValue() <variables>private static final long serialVersionUID |
google_gson | gson/gson/src/main/java/com/google/gson/internal/LinkedTreeMap.java | EntrySet | remove | class EntrySet extends AbstractSet<Entry<K, V>> {
@Override
public int size() {
return size;
}
@Override
public Iterator<Entry<K, V>> iterator() {
return new LinkedTreeMapIterator<Entry<K, V>>() {
@Override
public Entry<K, V> next() {
return nextNode();
... |
if (!(o instanceof Entry)) {
return false;
}
Node<K, V> node = findByEntry((Entry<?, ?>) o);
if (node == null) {
return false;
}
removeInternal(node, true);
return true;
| 199 | 75 | 274 | <methods>public void clear() ,public boolean containsKey(java.lang.Object) ,public boolean containsValue(java.lang.Object) ,public abstract Set<Entry<K,V>> entrySet() ,public boolean equals(java.lang.Object) ,public V get(java.lang.Object) ,public int hashCode() ,public boolean isEmpty() ,public Set<K> keySet() ,public... |
google_gson | gson/gson/src/main/java/com/google/gson/internal/NonNullElementWrapperList.java | NonNullElementWrapperList | nonNull | class NonNullElementWrapperList<E> extends AbstractList<E> implements RandomAccess {
// Explicitly specify ArrayList as type to guarantee that delegate implements RandomAccess
private final ArrayList<E> delegate;
@SuppressWarnings("NonApiType")
public NonNullElementWrapperList(ArrayList<E> delegate) {
this... |
if (element == null) {
throw new NullPointerException("Element must be non-null");
}
return element;
| 645 | 35 | 680 | <methods>public boolean add(E) ,public void add(int, E) ,public boolean addAll(int, Collection<? extends E>) ,public void clear() ,public boolean equals(java.lang.Object) ,public abstract E get(int) ,public int hashCode() ,public int indexOf(java.lang.Object) ,public Iterator<E> iterator() ,public int lastIndexOf(java.... |
google_gson | gson/gson/src/main/java/com/google/gson/internal/NumberLimits.java | NumberLimits | parseBigDecimal | class NumberLimits {
private NumberLimits() {}
private static final int MAX_NUMBER_STRING_LENGTH = 10_000;
private static void checkNumberStringLength(String s) {
if (s.length() > MAX_NUMBER_STRING_LENGTH) {
throw new NumberFormatException("Number string too large: " + s.substring(0, 30) + "...");
... |
checkNumberStringLength(s);
BigDecimal decimal = new BigDecimal(s);
// Cast to long to avoid issues with abs when value is Integer.MIN_VALUE
if (Math.abs((long) decimal.scale()) >= 10_000) {
throw new NumberFormatException("Number has unsupported scale: " + s);
}
return decimal;
| 184 | 95 | 279 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/PreJava9DateFormatProvider.java | PreJava9DateFormatProvider | getDatePartOfDateTimePattern | class PreJava9DateFormatProvider {
private PreJava9DateFormatProvider() {}
/**
* Returns the same DateFormat as {@code DateFormat.getDateTimeInstance(dateStyle, timeStyle,
* Locale.US)} in Java 8 or below.
*/
public static DateFormat getUsDateTimeFormat(int dateStyle, int timeStyle) {
String pattern... |
switch (dateStyle) {
case DateFormat.SHORT:
return "M/d/yy";
case DateFormat.MEDIUM:
return "MMM d, yyyy";
case DateFormat.LONG:
return "MMMM d, yyyy";
case DateFormat.FULL:
return "EEEE, MMMM d, yyyy";
default:
throw new IllegalArgumentExceptio... | 290 | 122 | 412 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/Primitives.java | Primitives | wrap | class Primitives {
private Primitives() {}
/** Returns true if this type is a primitive. */
public static boolean isPrimitive(Type type) {
return type instanceof Class<?> && ((Class<?>) type).isPrimitive();
}
/**
* Returns {@code true} if {@code type} is one of the nine primitive-wrapper types, such ... |
if (type == int.class) return (Class<T>) Integer.class;
if (type == float.class) return (Class<T>) Float.class;
if (type == byte.class) return (Class<T>) Byte.class;
if (type == double.class) return (Class<T>) Double.class;
if (type == long.class) return (Class<T>) Long.class;
if (type == char.... | 704 | 199 | 903 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/ReflectionAccessFilterHelper.java | ReflectionAccessFilterHelper | getFilterResult | class ReflectionAccessFilterHelper {
private ReflectionAccessFilterHelper() {}
// Platform type detection is based on Moshi's Util.isPlatformType(Class)
// See
// https://github.com/square/moshi/blob/3c108919ee1cce88a433ffda04eeeddc0341eae7/moshi/src/main/java/com/squareup/moshi/internal/Util.java#L141
publ... |
for (ReflectionAccessFilter filter : reflectionFilters) {
FilterResult result = filter.check(c);
if (result != FilterResult.INDECISIVE) {
return result;
}
}
return FilterResult.ALLOW;
| 864 | 67 | 931 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/Streams.java | Streams | parse | class Streams {
private Streams() {
throw new UnsupportedOperationException();
}
/** Takes a reader in any state and returns the next value as a JsonElement. */
public static JsonElement parse(JsonReader reader) throws JsonParseException {<FILL_FUNCTION_BODY>}
/** Writes the JSON element to the writer, ... |
boolean isEmpty = true;
try {
JsonToken unused = reader.peek();
isEmpty = false;
return TypeAdapters.JSON_ELEMENT.read(reader);
} catch (EOFException e) {
/*
* For compatibility with JSON 1.5 and earlier, we return a JsonNull for
* empty documents instead of throwing.
... | 830 | 206 | 1,036 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java | UnsafeAllocator | create | class UnsafeAllocator {
public abstract <T> T newInstance(Class<T> c) throws Exception;
/**
* Asserts that the class is instantiable. This check should have already occurred in {@link
* ConstructorConstructor}; this check here acts as safeguard since trying to use Unsafe for
* non-instantiable classes mig... |
// try JVM
// public class Unsafe {
// public Object allocateInstance(Class<?> type);
// }
try {
Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
Field f = unsafeClass.getDeclaredField("theUnsafe");
f.setAccessible(true);
final Object unsafe = f.get(null);
fi... | 218 | 807 | 1,025 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/bind/ArrayTypeAdapter.java | ArrayTypeAdapter | read | class ArrayTypeAdapter<E> extends TypeAdapter<Object> {
public static final TypeAdapterFactory FACTORY =
new TypeAdapterFactory() {
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Type type = typeToken.getType();
if (!(type instanceof GenericAr... |
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
ArrayList<E> list = new ArrayList<>();
in.beginArray();
while (in.hasNext()) {
E instance = componentTypeAdapter.read(in);
list.add(instance);
}
in.endArray();
int size = list.size();
// Have ... | 490 | 252 | 742 | <methods>public void <init>() ,public final java.lang.Object fromJson(java.io.Reader) throws java.io.IOException,public final java.lang.Object fromJson(java.lang.String) throws java.io.IOException,public final java.lang.Object fromJsonTree(com.google.gson.JsonElement) ,public final TypeAdapter<java.lang.Object> nullSaf... |
google_gson | gson/gson/src/main/java/com/google/gson/internal/bind/CollectionTypeAdapterFactory.java | Adapter | read | class Adapter<E> extends TypeAdapter<Collection<E>> {
private final TypeAdapter<E> elementTypeAdapter;
private final ObjectConstructor<? extends Collection<E>> constructor;
public Adapter(
Gson context,
Type elementType,
TypeAdapter<E> elementTypeAdapter,
ObjectConstructor<?... |
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
Collection<E> collection = constructor.construct();
in.beginArray();
while (in.hasNext()) {
E instance = elementTypeAdapter.read(in);
collection.add(instance);
}
in.endArray();
... | 252 | 100 | 352 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/bind/DefaultDateTypeAdapter.java | DateType | deserializeToDate | class DateType<T extends Date> {
public static final DateType<Date> DATE =
new DateType<Date>(Date.class) {
@Override
protected Date deserialize(Date date) {
return date;
}
};
private final Class<T> dateClass;
protected DateType(Class<T> dateClass)... |
String s = in.nextString();
// Needs to be synchronized since JDK DateFormat classes are not thread-safe
synchronized (dateFormats) {
for (DateFormat dateFormat : dateFormats) {
TimeZone originalTimeZone = dateFormat.getTimeZone();
try {
return dateFormat.parse(s);
}... | 807 | 205 | 1,012 | <methods>public void <init>() ,public final T fromJson(java.io.Reader) throws java.io.IOException,public final T fromJson(java.lang.String) throws java.io.IOException,public final T fromJsonTree(com.google.gson.JsonElement) ,public final TypeAdapter<T> nullSafe() ,public abstract T read(com.google.gson.stream.JsonReade... |
google_gson | gson/gson/src/main/java/com/google/gson/internal/bind/JsonAdapterAnnotationTypeAdapterFactory.java | DummyTypeAdapterFactory | getTypeAdapter | class DummyTypeAdapterFactory implements TypeAdapterFactory {
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
throw new AssertionError("Factory should not be used");
}
}
/** Factory used for {@link TreeTypeAdapter}s created for {@code @JsonAdapter} on a class. */
priv... |
Object instance = createAdapter(constructorConstructor, annotation.value());
TypeAdapter<?> typeAdapter;
boolean nullSafe = annotation.nullSafe();
if (instance instanceof TypeAdapter) {
typeAdapter = (TypeAdapter<?>) instance;
} else if (instance instanceof TypeAdapterFactory) {
TypeAd... | 828 | 555 | 1,383 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java | JsonTreeWriter | endObject | class JsonTreeWriter extends JsonWriter {
private static final Writer UNWRITABLE_WRITER =
new Writer() {
@Override
public void write(char[] buffer, int offset, int counter) {
throw new AssertionError();
}
@Override
public void flush() {
throw new Asse... |
if (stack.isEmpty() || pendingName != null) {
throw new IllegalStateException();
}
JsonElement element = peek();
if (element instanceof JsonObject) {
stack.remove(stack.size() - 1);
return this;
}
throw new IllegalStateException();
| 1,587 | 79 | 1,666 | <methods>public void <init>(java.io.Writer) ,public com.google.gson.stream.JsonWriter beginArray() throws java.io.IOException,public com.google.gson.stream.JsonWriter beginObject() throws java.io.IOException,public void close() throws java.io.IOException,public com.google.gson.stream.JsonWriter endArray() throws java.i... |
google_gson | gson/gson/src/main/java/com/google/gson/internal/bind/MapTypeAdapterFactory.java | Adapter | write | class Adapter<K, V> extends TypeAdapter<Map<K, V>> {
private final TypeAdapter<K> keyTypeAdapter;
private final TypeAdapter<V> valueTypeAdapter;
private final ObjectConstructor<? extends Map<K, V>> constructor;
public Adapter(
Gson context,
Type keyType,
TypeAdapter<K> keyTypeAd... |
if (map == null) {
out.nullValue();
return;
}
if (!complexMapKeySerialization) {
out.beginObject();
for (Map.Entry<K, V> entry : map.entrySet()) {
out.name(String.valueOf(entry.getKey()));
valueTypeAdapter.write(out, entry.getValue());
}
... | 741 | 429 | 1,170 | <no_super_class> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/bind/NumberTypeAdapter.java | NumberTypeAdapter | getFactory | class NumberTypeAdapter extends TypeAdapter<Number> {
/** Gson default factory using {@link ToNumberPolicy#LAZILY_PARSED_NUMBER}. */
private static final TypeAdapterFactory LAZILY_PARSED_NUMBER_FACTORY =
newFactory(ToNumberPolicy.LAZILY_PARSED_NUMBER);
private final ToNumberStrategy toNumberStrategy;
pr... |
if (toNumberStrategy == ToNumberPolicy.LAZILY_PARSED_NUMBER) {
return LAZILY_PARSED_NUMBER_FACTORY;
} else {
return newFactory(toNumberStrategy);
}
| 433 | 63 | 496 | <methods>public void <init>() ,public final java.lang.Number fromJson(java.io.Reader) throws java.io.IOException,public final java.lang.Number fromJson(java.lang.String) throws java.io.IOException,public final java.lang.Number fromJsonTree(com.google.gson.JsonElement) ,public final TypeAdapter<java.lang.Number> nullSaf... |
google_gson | gson/gson/src/main/java/com/google/gson/internal/bind/ObjectTypeAdapter.java | ObjectTypeAdapter | read | class ObjectTypeAdapter extends TypeAdapter<Object> {
/** Gson default factory using {@link ToNumberPolicy#DOUBLE}. */
private static final TypeAdapterFactory DOUBLE_FACTORY = newFactory(ToNumberPolicy.DOUBLE);
private final Gson gson;
private final ToNumberStrategy toNumberStrategy;
private ObjectTypeAdapt... |
// Either List or Map
Object current;
JsonToken peeked = in.peek();
current = tryBeginNesting(in, peeked);
if (current == null) {
return readTerminal(in, peeked);
}
Deque<Object> stack = new ArrayDeque<>();
while (true) {
while (in.hasNext()) {
String name = null;... | 778 | 425 | 1,203 | <methods>public void <init>() ,public final java.lang.Object fromJson(java.io.Reader) throws java.io.IOException,public final java.lang.Object fromJson(java.lang.String) throws java.io.IOException,public final java.lang.Object fromJsonTree(com.google.gson.JsonElement) ,public final TypeAdapter<java.lang.Object> nullSaf... |
google_gson | gson/gson/src/main/java/com/google/gson/internal/bind/TreeTypeAdapter.java | SingleTypeFactory | create | class SingleTypeFactory implements TypeAdapterFactory {
private final TypeToken<?> exactType;
private final boolean matchRawType;
private final Class<?> hierarchyType;
private final JsonSerializer<?> serializer;
private final JsonDeserializer<?> deserializer;
SingleTypeFactory(
Object t... |
boolean matches =
exactType != null
? exactType.equals(type) || (matchRawType && exactType.getType() == type.getRawType())
: hierarchyType.isAssignableFrom(type.getRawType());
return matches
? new TreeTypeAdapter<>(
(JsonSerializer<T>) serialize... | 285 | 112 | 397 | <methods>public non-sealed void <init>() ,public abstract TypeAdapter<T> getSerializationDelegate() <variables> |
google_gson | gson/gson/src/main/java/com/google/gson/internal/bind/TypeAdapterRuntimeTypeWrapper.java | TypeAdapterRuntimeTypeWrapper | write | class TypeAdapterRuntimeTypeWrapper<T> extends TypeAdapter<T> {
private final Gson context;
private final TypeAdapter<T> delegate;
private final Type type;
TypeAdapterRuntimeTypeWrapper(Gson context, TypeAdapter<T> delegate, Type type) {
this.context = context;
this.delegate = delegate;
this.type =... |
// Order of preference for choosing type adapters
// First preference: a type adapter registered for the runtime type
// Second preference: a type adapter registered for the declared type
// Third preference: reflective type adapter for the runtime type
// (if it is a subclass of ... | 418 | 374 | 792 | <methods>public void <init>() ,public final T fromJson(java.io.Reader) throws java.io.IOException,public final T fromJson(java.lang.String) throws java.io.IOException,public final T fromJsonTree(com.google.gson.JsonElement) ,public final TypeAdapter<T> nullSafe() ,public abstract T read(com.google.gson.stream.JsonReade... |
google_gson | gson/gson/src/main/java/com/google/gson/internal/sql/SqlDateTypeAdapter.java | SqlDateTypeAdapter | write | class SqlDateTypeAdapter extends TypeAdapter<java.sql.Date> {
static final TypeAdapterFactory FACTORY =
new TypeAdapterFactory() {
@SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeT... |
if (value == null) {
out.nullValue();
return;
}
String dateString;
synchronized (this) {
dateString = format.format(value);
}
out.value(dateString);
| 414 | 63 | 477 | <methods>public void <init>() ,public final java.sql.Date fromJson(java.io.Reader) throws java.io.IOException,public final java.sql.Date fromJson(java.lang.String) throws java.io.IOException,public final java.sql.Date fromJsonTree(com.google.gson.JsonElement) ,public final TypeAdapter<java.sql.Date> nullSafe() ,public ... |
google_gson | gson/gson/src/main/java/com/google/gson/internal/sql/SqlTimeTypeAdapter.java | SqlTimeTypeAdapter | read | class SqlTimeTypeAdapter extends TypeAdapter<Time> {
static final TypeAdapterFactory FACTORY =
new TypeAdapterFactory() {
@SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
... |
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
String s = in.nextString();
synchronized (this) {
TimeZone originalTimeZone = format.getTimeZone(); // Save the original time zone
try {
Date date = format.parse(s);
return new Time(date.getTime());... | 278 | 173 | 451 | <methods>public void <init>() ,public final java.sql.Time fromJson(java.io.Reader) throws java.io.IOException,public final java.sql.Time fromJson(java.lang.String) throws java.io.IOException,public final java.sql.Time fromJsonTree(com.google.gson.JsonElement) ,public final TypeAdapter<java.sql.Time> nullSafe() ,public ... |
google_gson | gson/gson/src/main/java/com/google/gson/internal/sql/SqlTimestampTypeAdapter.java | SqlTimestampTypeAdapter | read | class SqlTimestampTypeAdapter extends TypeAdapter<Timestamp> {
static final TypeAdapterFactory FACTORY =
new TypeAdapterFactory() {
@SuppressWarnings("unchecked") // we use a runtime check to make sure the 'T's equal
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type... |
Date date = dateTypeAdapter.read(in);
return date != null ? new Timestamp(date.getTime()) : null;
| 287 | 36 | 323 | <methods>public void <init>() ,public final java.sql.Timestamp fromJson(java.io.Reader) throws java.io.IOException,public final java.sql.Timestamp fromJson(java.lang.String) throws java.io.IOException,public final java.sql.Timestamp fromJsonTree(com.google.gson.JsonElement) ,public final TypeAdapter<java.sql.Timestamp>... |
google_gson | gson/metrics/src/main/java/com/google/gson/metrics/BagOfPrimitives.java | BagOfPrimitives | hashCode | class BagOfPrimitives {
public static final long DEFAULT_VALUE = 0;
public long longValue;
public int intValue;
public boolean booleanValue;
public String stringValue;
public BagOfPrimitives() {
this(DEFAULT_VALUE, 0, false, "");
}
public BagOfPrimitives(long longValue, int intValue, boolean boole... |
final int prime = 31;
int result = 1;
result = prime * result + (booleanValue ? 1231 : 1237);
result = prime * result + intValue;
result = prime * result + (int) (longValue ^ (longValue >>> 32));
result = prime * result + ((stringValue == null) ? 0 : stringValue.hashCode());
return result;
... | 476 | 107 | 583 | <no_super_class> |
google_gson | gson/metrics/src/main/java/com/google/gson/metrics/BagOfPrimitivesDeserializationBenchmark.java | BagOfPrimitivesDeserializationBenchmark | timeBagOfPrimitivesStreaming | class BagOfPrimitivesDeserializationBenchmark {
private Gson gson;
private String json;
public static void main(String[] args) {
NonUploadingCaliperRunner.run(BagOfPrimitivesDeserializationBenchmark.class, args);
}
@BeforeExperiment
void setUp() throws Exception {
this.gson = new Gson();
BagO... |
for (int i = 0; i < reps; ++i) {
StringReader reader = new StringReader(json);
JsonReader jr = new JsonReader(reader);
jr.beginObject();
long longValue = 0;
int intValue = 0;
boolean booleanValue = false;
String stringValue = null;
while (jr.hasNext()) {
Stri... | 667 | 263 | 930 | <no_super_class> |
google_gson | gson/metrics/src/main/java/com/google/gson/metrics/CollectionsDeserializationBenchmark.java | CollectionsDeserializationBenchmark | timeCollectionsDefault | class CollectionsDeserializationBenchmark {
private static final TypeToken<List<BagOfPrimitives>> LIST_TYPE_TOKEN =
new TypeToken<List<BagOfPrimitives>>() {};
private static final Type LIST_TYPE = LIST_TYPE_TOKEN.getType();
private Gson gson;
private String json;
public static void main(String[] args)... |
for (int i = 0; i < reps; ++i) {
gson.fromJson(json, LIST_TYPE_TOKEN);
}
| 1,107 | 43 | 1,150 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.