aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidSourceViewerConfig.java1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/Hyperlinks.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationEditorDelegate.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorEditorDelegate.java8
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonSourceViewerConfig.java1
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlDelegate.java22
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlEditor.java28
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableEditorDelegate.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java58
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java4
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java2
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/menu/MenuEditorDelegate.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/otherxml/OtherXmlEditorDelegate.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/tree/UiElementDetail.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/tree/UiTreeBlock.java3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/ValuesEditorDelegate.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java20
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintRunner.java6
-rw-r--r--lint/cli/src/com/android/tools/lint/Main.java2
-rw-r--r--lint/cli/src/com/android/tools/lint/TextReporter.java2
-rw-r--r--lint/libs/lint_api/src/com/android/tools/lint/detector/api/Context.java2
-rw-r--r--sdkstats/src/com/android/sdkstats/SdkStatsService.java212
23 files changed, 284 insertions, 135 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidSourceViewerConfig.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidSourceViewerConfig.java
index 8334c61..b2c10ec 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidSourceViewerConfig.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidSourceViewerConfig.java
@@ -17,7 +17,6 @@
package com.android.ide.eclipse.adt.internal.editors;
-import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor;
import com.android.ide.eclipse.adt.internal.editors.formatting.AndroidXmlFormatter;
import com.android.ide.eclipse.adt.internal.editors.formatting.AndroidXmlFormattingStrategy;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/Hyperlinks.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/Hyperlinks.java
index 6da978d..08ca60a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/Hyperlinks.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/Hyperlinks.java
@@ -710,7 +710,7 @@ public class Hyperlinks {
if (refDelegate != null) {
IProject refProject = refDelegate.getEditor().getProject();
if (project == null || project == refProject) {
- GraphicalEditorPart refGraphicalEditor = delegate.getGraphicalEditor();
+ GraphicalEditorPart refGraphicalEditor = refDelegate.getGraphicalEditor();
if (refGraphicalEditor != null) {
return refGraphicalEditor.getConfiguration();
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationEditorDelegate.java
index a606e6c..bd1fa3d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationEditorDelegate.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/animator/AnimationEditorDelegate.java
@@ -69,7 +69,7 @@ public class AnimationEditorDelegate extends CommonXmlDelegate {
}
@Override
- public void createFormPages() {
+ public void delegateCreateFormPages() {
/* Disabled for now; doesn't work quite right
try {
addPage(new AnimatorTreePage(this));
@@ -86,14 +86,14 @@ public class AnimationEditorDelegate extends CommonXmlDelegate {
* @param xmlDoc The XML document, if available, or null if none exists.
*/
@Override
- public void xmlModelChanged(Document xmlDoc) {
+ public void delegateXmlModelChanged(Document xmlDoc) {
Element rootElement = xmlDoc.getDocumentElement();
if (rootElement != null) {
mRootTag = rootElement.getTagName();
}
// create the ui root node on demand.
- initUiRootNode(false /*force*/);
+ delegateInitUiRootNode(false /*force*/);
if (mRootTag != null
&& !mRootTag.equals(getUiRootNode().getDescriptor().getXmlLocalName())) {
@@ -126,7 +126,7 @@ public class AnimationEditorDelegate extends CommonXmlDelegate {
}
@Override
- public void initUiRootNode(boolean force) {
+ public void delegateInitUiRootNode(boolean force) {
// The manifest UI node is always created, even if there's no corresponding XML node.
if (getUiRootNode() == null || force) {
ElementDescriptor descriptor;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorEditorDelegate.java
index 3fc1552..2398486 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorEditorDelegate.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/color/ColorEditorDelegate.java
@@ -65,7 +65,7 @@ public class ColorEditorDelegate extends CommonXmlDelegate {
}
@Override
- public void createFormPages() {
+ public void delegateCreateFormPages() {
/* Disabled for now; doesn't work quite right
try {
addPage(new ColorTreePage(this));
@@ -77,16 +77,16 @@ public class ColorEditorDelegate extends CommonXmlDelegate {
}
@Override
- public void xmlModelChanged(Document xmlDoc) {
+ public void delegateXmlModelChanged(Document xmlDoc) {
// create the ui root node on demand.
- initUiRootNode(false /*force*/);
+ delegateInitUiRootNode(false /*force*/);
Element rootElement = xmlDoc.getDocumentElement();
getUiRootNode().loadFromXmlNode(rootElement);
}
@Override
- public void initUiRootNode(boolean force) {
+ public void delegateInitUiRootNode(boolean force) {
// The manifest UI node is always created, even if there's no corresponding XML node.
if (getUiRootNode() == null || force) {
ElementDescriptor descriptor;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonSourceViewerConfig.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonSourceViewerConfig.java
index ed6e5e9..be31040 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonSourceViewerConfig.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonSourceViewerConfig.java
@@ -17,7 +17,6 @@
package com.android.ide.eclipse.adt.internal.editors.common;
import com.android.ide.eclipse.adt.internal.editors.AndroidSourceViewerConfig;
-import com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.source.ISourceViewer;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlDelegate.java
index 36e51e7..7c454fb 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlDelegate.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlDelegate.java
@@ -107,7 +107,7 @@ public abstract class CommonXmlDelegate {
}
/** Called to compute the initial {@code UiRootNode}. */
- public abstract void initUiRootNode(boolean force);
+ public abstract void delegateInitUiRootNode(boolean force);
/**
* Returns true, indicating the "save as" operation is supported by this editor.
@@ -119,16 +119,16 @@ public abstract class CommonXmlDelegate {
/**
* Create the various form pages.
*/
- public abstract void createFormPages();
+ public abstract void delegateCreateFormPages();
- public void postCreatePages() {
+ public void delegatePostCreatePages() {
// pass
}
/**
* Changes the tab/title name to include the project name.
*/
- public void setInput(IEditorInput input) {
+ public void delegateSetInput(IEditorInput input) {
if (input instanceof FileEditorInput) {
FileEditorInput fileInput = (FileEditorInput) input;
IFile file = fileInput.getFile();
@@ -141,13 +141,13 @@ public abstract class CommonXmlDelegate {
*
* @param xml_doc The XML document, if available, or null if none exists.
*/
- public abstract void xmlModelChanged(Document xml_doc);
+ public abstract void delegateXmlModelChanged(Document xml_doc);
- public void pageChange(int newPageIndex) {
+ public void delegatePageChange(int newPageIndex) {
// pass
}
- public void postPageChange(int newPageIndex) {
+ public void delegatePostPageChange(int newPageIndex) {
// pass
}
/**
@@ -160,7 +160,7 @@ public abstract class CommonXmlDelegate {
* Here we just need to tell the graphical editor that the model has
* been saved.
*/
- public void doSave(IProgressMonitor monitor) {
+ public void delegateDoSave(IProgressMonitor monitor) {
// pass
}
@@ -168,7 +168,7 @@ public abstract class CommonXmlDelegate {
* Tells the editor to start a Lint check.
* It's up to the caller to check whether this should be done depending on preferences.
*/
- public Job runLint() {
+ public Job delegateRunLint() {
return getEditor().startLintJob();
}
@@ -176,7 +176,7 @@ public abstract class CommonXmlDelegate {
/**
* Returns the custom IContentOutlinePage or IPropertySheetPage when asked for it.
*/
- public Object getAdapter(Class<?> adapter) {
+ public Object delegateGetAdapter(Class<?> adapter) {
return null;
}
@@ -196,7 +196,7 @@ public abstract class CommonXmlDelegate {
* @return false since editors do not support automatically formatting XML
* affected by GUI changes unless they explicitly opt in to it.
*/
- public boolean supportsFormatOnGuiEdit() {
+ public boolean delegateSupportsFormatOnGuiEdit() {
return false;
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlEditor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlEditor.java
index b9168ba..3ddc115 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlEditor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlEditor.java
@@ -195,14 +195,14 @@ public class CommonXmlEditor extends AndroidXmlEditor implements IShowEditorInpu
* all data to the XML model and then having the Structured XML Editor
* save the XML.
* <p/>
- * Here we just need to tell the graphical editor that the model has
+ * Here we just need to tell the delegate that the model has
* been saved.
*/
@Override
public void doSave(IProgressMonitor monitor) {
super.doSave(monitor);
if (mDelegate != null) {
- mDelegate.doSave(monitor);
+ mDelegate.delegateDoSave(monitor);
}
}
@@ -225,7 +225,7 @@ public class CommonXmlEditor extends AndroidXmlEditor implements IShowEditorInpu
@Override
protected void createFormPages() {
if (mDelegate != null) {
- mDelegate.createFormPages();
+ mDelegate.delegateCreateFormPages();
}
}
@@ -234,7 +234,7 @@ public class CommonXmlEditor extends AndroidXmlEditor implements IShowEditorInpu
super.postCreatePages();
if (mDelegate != null) {
- mDelegate.postCreatePages();
+ mDelegate.delegatePostCreatePages();
}
}
@@ -266,15 +266,15 @@ public class CommonXmlEditor extends AndroidXmlEditor implements IShowEditorInpu
super.setInput(input);
assert mDelegate != null;
if (mDelegate != null) {
- mDelegate.setInput(input);
+ mDelegate.delegateSetInput(input);
}
}
@Override
- protected void setInputWithNotify(IEditorInput input) {
+ public void setInputWithNotify(IEditorInput input) {
super.setInputWithNotify(input);
if (mDelegate instanceof LayoutEditorDelegate) {
- ((LayoutEditorDelegate) mDelegate).setInputWithNotify(input);
+ ((LayoutEditorDelegate) mDelegate).delegateSetInputWithNotify(input);
}
}
@@ -286,14 +286,14 @@ public class CommonXmlEditor extends AndroidXmlEditor implements IShowEditorInpu
@Override
protected void xmlModelChanged(Document xml_doc) {
if (mDelegate != null) {
- mDelegate.xmlModelChanged(xml_doc);
+ mDelegate.delegateXmlModelChanged(xml_doc);
}
}
@Override
protected Job runLint() {
if (mDelegate != null) {
- return mDelegate.runLint();
+ return mDelegate.delegateRunLint();
}
return null;
}
@@ -304,7 +304,7 @@ public class CommonXmlEditor extends AndroidXmlEditor implements IShowEditorInpu
@Override
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
if (mDelegate != null) {
- Object value = mDelegate.getAdapter(adapter);
+ Object value = mDelegate.delegateGetAdapter(adapter);
if (value != null) {
return value;
}
@@ -317,20 +317,20 @@ public class CommonXmlEditor extends AndroidXmlEditor implements IShowEditorInpu
@Override
protected void pageChange(int newPageIndex) {
if (mDelegate != null) {
- mDelegate.pageChange(newPageIndex);
+ mDelegate.delegatePageChange(newPageIndex);
}
super.pageChange(newPageIndex);
if (mDelegate != null) {
- mDelegate.postPageChange(newPageIndex);
+ mDelegate.delegatePostPageChange(newPageIndex);
}
}
@Override
public void initUiRootNode(boolean force) {
if (mDelegate != null) {
- mDelegate.initUiRootNode(force);
+ mDelegate.delegateInitUiRootNode(force);
}
}
@@ -345,7 +345,7 @@ public class CommonXmlEditor extends AndroidXmlEditor implements IShowEditorInpu
@Override
public boolean supportsFormatOnGuiEdit() {
if (mDelegate != null) {
- return mDelegate.supportsFormatOnGuiEdit();
+ return mDelegate.delegateSupportsFormatOnGuiEdit();
}
return super.supportsFormatOnGuiEdit();
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableEditorDelegate.java
index e9e0674..d5234bd 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableEditorDelegate.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/drawable/DrawableEditorDelegate.java
@@ -71,7 +71,7 @@ public class DrawableEditorDelegate extends CommonXmlDelegate {
}
@Override
- public void createFormPages() {
+ public void delegateCreateFormPages() {
/* Disabled for now; doesn't work quite right
try {
addPage(new DrawableTreePage(this));
@@ -83,13 +83,13 @@ public class DrawableEditorDelegate extends CommonXmlDelegate {
}
@Override
- public void xmlModelChanged(Document xmlDoc) {
+ public void delegateXmlModelChanged(Document xmlDoc) {
Element rootElement = xmlDoc.getDocumentElement();
if (rootElement != null) {
mRootTag = rootElement.getTagName();
}
- initUiRootNode(false /*force*/);
+ delegateInitUiRootNode(false /*force*/);
if (mRootTag != null
&& !mRootTag.equals(getUiRootNode().getDescriptor().getXmlLocalName())) {
@@ -118,7 +118,7 @@ public class DrawableEditorDelegate extends CommonXmlDelegate {
}
@Override
- public void initUiRootNode(boolean force) {
+ public void delegateInitUiRootNode(boolean force) {
// The manifest UI node is always created, even if there's no corresponding XML node.
if (getUiRootNode() == null || force) {
ElementDescriptor descriptor;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java
index 9883ff5..8d02bda 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorDelegate.java
@@ -191,16 +191,16 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
/**
* Save the XML.
* <p/>
- * The actual save operation is done in the super class by committing
- * all data to the XML model and then having the Structured XML Editor
- * save the XML.
+ * Clients must NOT call this directly. Instead they should always
+ * call {@link CommonXmlEditor#doSave(IProgressMonitor)} so that th
+ * editor super class can commit the data properly.
* <p/>
* Here we just need to tell the graphical editor that the model has
* been saved.
*/
@Override
- public void doSave(IProgressMonitor monitor) {
- super.doSave(monitor);
+ public void delegateDoSave(IProgressMonitor monitor) {
+ super.delegateDoSave(monitor);
if (mGraphicalEditor != null) {
mGraphicalEditor.doSave(monitor);
}
@@ -210,7 +210,7 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
* Create the various form pages.
*/
@Override
- public void createFormPages() {
+ public void delegateCreateFormPages() {
try {
// get the file being edited so that it can be passed to the layout editor.
IFile editedFile = null;
@@ -254,7 +254,7 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
}
@Override
- public void postCreatePages() {
+ public void delegatePostCreatePages() {
// Optional: set the default page. Eventually a default page might be
// restored by selectDefaultPage() later based on the last page used by the user.
// For example, to make the last page the default one (rather than the first page),
@@ -266,7 +266,7 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
* Change the tab/title name to include the name of the layout.
*/
@Override
- public void setInput(IEditorInput input) {
+ public void delegateSetInput(IEditorInput input) {
handleNewInput(input);
}
@@ -274,7 +274,7 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
* (non-Javadoc)
* @see org.eclipse.ui.part.EditorPart#setInputWithNotify(org.eclipse.ui.IEditorInput)
*/
- public void setInputWithNotify(IEditorInput input) {
+ public void delegateSetInputWithNotify(IEditorInput input) {
handleNewInput(input);
}
@@ -289,28 +289,30 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
return;
}
- // save the current editor input.
- doSave(new NullProgressMonitor());
+ // Save the current editor input. This must be called on the editor itself
+ // since it's the base editor that commits pending changes.
+ getEditor().doSave(new NullProgressMonitor());
- // get the current page
+ // Get the current page
int currentPage = getEditor().getActivePage();
- // remove the pages, except for the graphical editor, which will be dynamically adapted
+ // Remove the pages, except for the graphical editor, which will be dynamically adapted
// to the new model.
// page after the graphical editor:
int count = getEditor().getPageCount();
for (int i = count - 1 ; i > mGraphicalEditorIndex ; i--) {
getEditor().removePage(i);
}
- // pages before the graphical editor
+ // Pages before the graphical editor
for (int i = mGraphicalEditorIndex - 1 ; i >= 0 ; i--) {
getEditor().removePage(i);
}
- // set the current input.
- setInputWithNotify(editorInput);
+ // Set the current input. We're in the delegate, the input must
+ // be set into the actual editor instance.
+ getEditor().setInputWithNotify(editorInput);
- // re-create or reload the pages with the default page shown as the previous active page.
+ // Re-create or reload the pages with the default page shown as the previous active page.
getEditor().createAndroidPages();
getEditor().selectDefaultPage(Integer.toString(currentPage));
@@ -323,7 +325,7 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
public void refreshXmlModel() {
Document xmlDoc = mUiDocRootNode.getXmlDocument();
- initUiRootNode(true /*force*/);
+ delegateInitUiRootNode(true /*force*/);
mUiDocRootNode.loadFromXmlNode(xmlDoc);
// Update the model first, since it is used by the viewers.
@@ -341,9 +343,9 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
* @param xml_doc The XML document, if available, or null if none exists.
*/
@Override
- public void xmlModelChanged(Document xml_doc) {
+ public void delegateXmlModelChanged(Document xml_doc) {
// init the ui root on demand
- initUiRootNode(false /*force*/);
+ delegateInitUiRootNode(false /*force*/);
mUiDocRootNode.loadFromXmlNode(xml_doc);
@@ -370,13 +372,13 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
* affected by GUI changes
*/
@Override
- public boolean supportsFormatOnGuiEdit() {
+ public boolean delegateSupportsFormatOnGuiEdit() {
return true;
}
@Override
- public Job runLint() {
- Job job = super.runLint();
+ public Job delegateRunLint() {
+ Job job = super.delegateRunLint();
if (job != null) {
job.addJobChangeListener(new JobChangeAdapter() {
@@ -400,7 +402,7 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
* Returns the custom IContentOutlinePage or IPropertySheetPage when asked for it.
*/
@Override
- public Object getAdapter(Class<?> adapter) {
+ public Object delegateGetAdapter(Class<?> adapter) {
// For the outline, force it to come from the Graphical Editor.
// This fixes the case where a layout file is opened in XML view first and the outline
// gets stuck in the XML outline.
@@ -422,11 +424,11 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
}
// return default
- return super.getAdapter(adapter);
+ return super.delegateGetAdapter(adapter);
}
@Override
- public void pageChange(int newPageIndex) {
+ public void delegatePageChange(int newPageIndex) {
if (getEditor().getCurrentPage() == getEditor().getTextPageIndex() &&
newPageIndex == mGraphicalEditorIndex) {
// You're switching from the XML editor to the WYSIWYG editor;
@@ -442,7 +444,7 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
}
}
- super.pageChange(newPageIndex);
+ super.delegatePageChange(newPageIndex);
if (mGraphicalEditor != null) {
if (newPageIndex == mGraphicalEditorIndex) {
@@ -534,7 +536,7 @@ public class LayoutEditorDelegate extends CommonXmlDelegate
}
@Override
- public void initUiRootNode(boolean force) {
+ public void delegateInitUiRootNode(boolean force) {
// The root UI node is always created, even if there's no corresponding XML node.
if (mUiDocRootNode == null || force) {
// get the target data from the opened file (and its project)
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
index 236d5fd..7c8cc81 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
@@ -168,7 +168,7 @@ import java.util.Set;
* <p/>
* This part is also an {@link ISelectionListener}. It listens to the site's selection
* service and thus receives selection changes from itself as well as the associated
- * outline and property sheet (these are registered by {@link LayoutEditorDelegate#getAdapter(Class)}).
+ * outline and property sheet (these are registered by {@link LayoutEditorDelegate#delegateGetAdapter(Class)}).
*
* @since GLE2
*/
@@ -826,7 +826,7 @@ public class GraphicalEditorPart extends EditorPart
// recreate the ui root node always, this will also call onTargetChange
// on the config composite
- mEditorDelegate.initUiRootNode(true /*force*/);
+ mEditorDelegate.delegateInitUiRootNode(true /*force*/);
}
private IProject getProject() {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java
index 211296f..b097743 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java
@@ -306,7 +306,7 @@ public class LayoutCanvas extends Canvas {
// --- setup outline ---
// Get the outline associated with this editor, if any and of the right type.
Object outline = editorDelegate == null ? null :
- editorDelegate.getAdapter(IContentOutlinePage.class);
+ editorDelegate.delegateGetAdapter(IContentOutlinePage.class);
if (outline instanceof OutlinePage) {
mOutlinePage = (OutlinePage) outline;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java
index 3939a60..ef1a17c 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage.java
@@ -102,7 +102,7 @@ import java.util.Set;
/**
* An outline page for the layout canvas view.
* <p/>
- * The page is created by {@link LayoutEditorDelegate#getAdapter(Class)}. This means
+ * The page is created by {@link LayoutEditorDelegate#delegateGetAdapter(Class)}. This means
* we have *one* instance of the outline page per open canvas editor.
* <p/>
* It sets itself as a listener on the site's selection service in order to be
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/menu/MenuEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/menu/MenuEditorDelegate.java
index 275d3a0..a55d6e4 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/menu/MenuEditorDelegate.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/menu/MenuEditorDelegate.java
@@ -74,7 +74,7 @@ public class MenuEditorDelegate extends CommonXmlDelegate {
* Create the various form pages.
*/
@Override
- public void createFormPages() {
+ public void delegateCreateFormPages() {
try {
getEditor().addPage(new MenuTreePage(getEditor()));
} catch (PartInitException e) {
@@ -91,7 +91,7 @@ public class MenuEditorDelegate extends CommonXmlDelegate {
* @param xml_doc The XML document, if available, or null if none exists.
*/
@Override
- public void xmlModelChanged(Document xml_doc) {
+ public void delegateXmlModelChanged(Document xml_doc) {
if (mUpdatingModel) {
return;
}
@@ -100,7 +100,7 @@ public class MenuEditorDelegate extends CommonXmlDelegate {
mUpdatingModel = true;
// init the ui root on demand
- initUiRootNode(false /*force*/);
+ delegateInitUiRootNode(false /*force*/);
getUiRootNode().setXmlDocument(xml_doc);
if (xml_doc != null) {
@@ -135,7 +135,7 @@ public class MenuEditorDelegate extends CommonXmlDelegate {
* @param force if true, a new UiRootNode is recreated even if it already exists.
*/
@Override
- public void initUiRootNode(boolean force) {
+ public void delegateInitUiRootNode(boolean force) {
// The root UI node is always created, even if there's no corresponding XML node.
if (getUiRootNode() == null || force) {
Document doc = null;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/otherxml/OtherXmlEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/otherxml/OtherXmlEditorDelegate.java
index e1e13b2..f6e23de 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/otherxml/OtherXmlEditorDelegate.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/otherxml/OtherXmlEditorDelegate.java
@@ -69,7 +69,7 @@ public class OtherXmlEditorDelegate extends CommonXmlDelegate {
* Create the various form pages.
*/
@Override
- public void createFormPages() {
+ public void delegateCreateFormPages() {
try {
getEditor().addPage(new OtherXmlTreePage(getEditor()));
} catch (PartInitException e) {
@@ -83,9 +83,9 @@ public class OtherXmlEditorDelegate extends CommonXmlDelegate {
* @param xml_doc The XML document, if available, or null if none exists.
*/
@Override
- public void xmlModelChanged(Document xml_doc) {
+ public void delegateXmlModelChanged(Document xml_doc) {
// init the ui root on demand
- initUiRootNode(false /*force*/);
+ delegateInitUiRootNode(false /*force*/);
getUiRootNode().loadFromXmlNode(xml_doc);
}
@@ -95,7 +95,7 @@ public class OtherXmlEditorDelegate extends CommonXmlDelegate {
* @param force if true, a new UiRootNode is recreated even if it already exists.
*/
@Override
- public void initUiRootNode(boolean force) {
+ public void delegateInitUiRootNode(boolean force) {
// The root UI node is always created, even if there's no corresponding XML node.
if (getUiRootNode() == null || force) {
Document doc = null;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/tree/UiElementDetail.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/tree/UiElementDetail.java
index 972af93..2aa56a8 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/tree/UiElementDetail.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/tree/UiElementDetail.java
@@ -346,9 +346,9 @@ class UiElementDetail implements IDetailsPage {
final IUiUpdateListener updateListener = new IUiUpdateListener() {
@Override
- public void uiElementNodeUpdated(UiElementNode ui_node, UiUpdateState state) {
+ public void uiElementNodeUpdated(UiElementNode uiNode, UiUpdateState state) {
if (state == UiUpdateState.ATTR_UPDATED) {
- updateUnknownAttributesSection(ui_node, unknownTable, managedForm,
+ updateUnknownAttributesSection(uiNode, unknownTable, managedForm,
reference);
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/tree/UiTreeBlock.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/tree/UiTreeBlock.java
index 42fd32a..d11b8a4 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/tree/UiTreeBlock.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/ui/tree/UiTreeBlock.java
@@ -642,11 +642,10 @@ public final class UiTreeBlock extends MasterDetailsBlock implements ICommitXml
*
* @return A new list of {@link UiElementNode} with at least one item or null.
*/
- @SuppressWarnings("unchecked")
private ArrayList<UiElementNode> filterSelection(ITreeSelection selection) {
ArrayList<UiElementNode> selected = new ArrayList<UiElementNode>();
- for (Iterator it = selection.iterator(); it.hasNext(); ) {
+ for (Iterator<Object> it = selection.iterator(); it.hasNext(); ) {
Object selectedObj = it.next();
if (selectedObj instanceof UiElementNode) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/ValuesEditorDelegate.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/ValuesEditorDelegate.java
index fa2b52d..6198fcd 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/ValuesEditorDelegate.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/values/ValuesEditorDelegate.java
@@ -77,7 +77,7 @@ public class ValuesEditorDelegate extends CommonXmlDelegate {
* Create the various form pages.
*/
@Override
- public void createFormPages() {
+ public void delegateCreateFormPages() {
try {
getEditor().addPage(new ValuesTreePage(getEditor()));
} catch (PartInitException e) {
@@ -92,9 +92,9 @@ public class ValuesEditorDelegate extends CommonXmlDelegate {
* @param xml_doc The XML document, if available, or null if none exists.
*/
@Override
- public void xmlModelChanged(Document xml_doc) {
+ public void delegateXmlModelChanged(Document xml_doc) {
// init the ui root on demand
- initUiRootNode(false /*force*/);
+ delegateInitUiRootNode(false /*force*/);
getUiRootNode().setXmlDocument(xml_doc);
if (xml_doc != null) {
@@ -122,7 +122,7 @@ public class ValuesEditorDelegate extends CommonXmlDelegate {
* @param force if true, a new UiRootNode is recreated even if it already exists.
*/
@Override
- public void initUiRootNode(boolean force) {
+ public void delegateInitUiRootNode(boolean force) {
// The manifest UI node is always created, even if there's no corresponding XML node.
if (getUiRootNode() == null || force) {
ElementDescriptor resources_desc =
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java
index 3289bbe..fc8d5b1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java
@@ -102,7 +102,6 @@ public class EclipseLintClient extends LintClient implements IDomParser {
private final IDocument mDocument;
private boolean mWasFatal;
private boolean mFatalOnly;
- private Configuration mConfiguration;
private EclipseJavaParser mJavaParser;
/**
@@ -199,18 +198,14 @@ public class EclipseLintClient extends LintClient implements IDomParser {
@Override
public Configuration getConfiguration(Project project) {
- if (mConfiguration == null) {
- if (project != null) {
- IProject eclipseProject = getProject(project);
- if (eclipseProject != null) {
- mConfiguration = ProjectLintConfiguration.get(this, eclipseProject, mFatalOnly);
- return mConfiguration;
- }
+ if (project != null) {
+ IProject eclipseProject = getProject(project);
+ if (eclipseProject != null) {
+ return ProjectLintConfiguration.get(this, eclipseProject, mFatalOnly);
}
-
- mConfiguration = GlobalLintConfiguration.get();
}
- return mConfiguration;
+
+ return GlobalLintConfiguration.get();
}
@Override
@@ -483,6 +478,9 @@ public class EclipseLintClient extends LintClient implements IDomParser {
}
sb.append("Issue: ");
sb.append(summary);
+ sb.append('\n');
+ sb.append("Id: ");
+ sb.append(issue.getId());
sb.append('\n').append('\n');
sb.append(explanation);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintRunner.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintRunner.java
index faf29d9..36a388a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintRunner.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintRunner.java
@@ -193,8 +193,10 @@ public class EclipseLintRunner {
}
for (IProject project : projects) {
ProjectState state = Sdk.getProjectState(project);
- for (IProject library : state.getFullLibraryProjects()) {
- allProjects.put(library, library);
+ if (state != null) {
+ for (IProject library : state.getFullLibraryProjects()) {
+ allProjects.put(library, library);
+ }
}
}
for (IProject project : allProjects.keySet()) {
diff --git a/lint/cli/src/com/android/tools/lint/Main.java b/lint/cli/src/com/android/tools/lint/Main.java
index 629c932..e12e473 100644
--- a/lint/cli/src/com/android/tools/lint/Main.java
+++ b/lint/cli/src/com/android/tools/lint/Main.java
@@ -1025,7 +1025,7 @@ public class Main extends LintClient {
// Detectors shouldn't be returning ignore as a default severity,
// but in case they do, force it up to warning here to ensure that
// it's run
- if (severity == Severity.IGNORE) {
+ if (severity == Severity.IGNORE && severity == issue.getDefaultSeverity()) {
return Severity.WARNING;
} else {
return severity;
diff --git a/lint/cli/src/com/android/tools/lint/TextReporter.java b/lint/cli/src/com/android/tools/lint/TextReporter.java
index 4d08c0b..47202d1 100644
--- a/lint/cli/src/com/android/tools/lint/TextReporter.java
+++ b/lint/cli/src/com/android/tools/lint/TextReporter.java
@@ -38,8 +38,10 @@ class TextReporter extends Reporter {
StringBuilder output = new StringBuilder(issues.size() * 200);
if (issues.size() == 0) {
+ mWriter.write('\n');
mWriter.write("No issues found.");
mWriter.write('\n');
+ mWriter.flush();
} else {
for (Warning warning : issues) {
int startLength = output.length();
diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Context.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Context.java
index d82ae0b..33e39e7 100644
--- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Context.java
+++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Context.java
@@ -19,8 +19,8 @@ package com.android.tools.lint.detector.api;
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.tools.lint.client.api.Configuration;
-import com.android.tools.lint.client.api.LintDriver;
import com.android.tools.lint.client.api.LintClient;
+import com.android.tools.lint.client.api.LintDriver;
import com.android.tools.lint.client.api.SdkInfo;
import com.google.common.annotations.Beta;
diff --git a/sdkstats/src/com/android/sdkstats/SdkStatsService.java b/sdkstats/src/com/android/sdkstats/SdkStatsService.java
index b56247a..298132d 100644
--- a/sdkstats/src/com/android/sdkstats/SdkStatsService.java
+++ b/sdkstats/src/com/android/sdkstats/SdkStatsService.java
@@ -137,29 +137,11 @@ public class SdkStatsService {
* @param id of the local installation
* @throws IOException if the ping failed
*/
- @SuppressWarnings("deprecation")
private static void actuallySendPing(String app, String version, long id)
throws IOException {
- // Detect and report the host OS.
- String os = System.getProperty("os.name"); //$NON-NLS-1$
- if (os.startsWith("Mac OS")) { //$NON-NLS-1$
- os = "mac"; //$NON-NLS-1$
- String osVers = getVersion();
- if (osVers != null) {
- os = os + "-" + osVers; //$NON-NLS-1$
- }
- } else if (os.startsWith("Windows")) { //$NON-NLS-1$
- os = "win"; //$NON-NLS-1$
- String osVers = getVersion();
- if (osVers != null) {
- os = os + "-" + osVers; //$NON-NLS-1$
- }
- } else if (os.startsWith("Linux")) { //$NON-NLS-1$
- os = "linux"; //$NON-NLS-1$
- } else {
- // Unknown -- surprising -- send it verbatim so we can see it.
- os = URLEncoder.encode(os);
- }
+ String osName = URLEncoder.encode(getOsName(), "UTF-8");
+ String osArch = URLEncoder.encode(getOsArch(), "UTF-8");
+ String jvmArch = URLEncoder.encode(getJvmInfo(), "UTF-8");
// Include the application's name as part of the as= value.
// Share the user ID for all apps, to allow unified activity reports.
@@ -170,7 +152,9 @@ public class SdkStatsService {
"/service/update?as=androidsdk_" + app + //$NON-NLS-1$
"&id=" + Long.toHexString(id) + //$NON-NLS-1$
"&version=" + version + //$NON-NLS-1$
- "&os=" + os); //$NON-NLS-1$
+ "&os=" + osName + //$NON-NLS-1$
+ "&osa=" + osArch + //$NON-NLS-1$
+ "&vma=" + jvmArch); //$NON-NLS-1$
// Discard the actual response, but make sure it reads OK
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
@@ -185,24 +169,188 @@ public class SdkStatsService {
}
/**
- * Returns the version of the os if it is defined as X.Y, or null otherwise.
+ * Detects and reports the host OS: "linux", "win" or "mac".
+ * For Windows and Mac also append the version, so for example
+ * Win XP will return win-5.1.
+ */
+ private static String getOsName() {
+ String os = System.getProperty("os.name"); //$NON-NLS-1$
+
+ if (os == null || os.length() == 0) {
+ return "unknown"; //$NON-NLS-1$
+ }
+
+ if (os.startsWith("Mac OS")) { //$NON-NLS-1$
+ os = "mac"; //$NON-NLS-1$
+ String osVers = getOsVersion();
+ if (osVers != null) {
+ os = os + '-' + osVers;
+ }
+ } else if (os.startsWith("Windows")) { //$NON-NLS-1$
+ os = "win"; //$NON-NLS-1$
+ String osVers = getOsVersion();
+ if (osVers != null) {
+ os = os + '-' + osVers;
+ }
+ } else if (os.startsWith("Linux")) { //$NON-NLS-1$
+ os = "linux"; //$NON-NLS-1$
+
+ } else if (os.length() > 32) {
+ // Unknown -- send it verbatim so we can see it
+ // but protect against arbitrarily long values
+ os = os.substring(0, 32);
+ }
+ return os;
+ }
+
+ /**
+ * Detects and returns the OS architecture: x86, x86_64, ppc.
+ * This may differ or be equal to the JVM architecture in the sense that
+ * a 64-bit OS can run a 32-bit JVM.
+ */
+ private static String getOsArch() {
+ String arch = getJvmArch();
+
+ if ("x86_64".equals(arch)) { //$NON-NLS-1$
+ // This is a simple case: the JVM runs in 64-bit so the
+ // OS must be a 64-bit one.
+ return arch;
+
+ } else if ("x86".equals(arch)) { //$NON-NLS-1$
+ // This is the misleading case: the JVM is 32-bit but the OS
+ // might be either 32 or 64. We can't tell just from this
+ // property.
+ // Macs are always on 64-bit, so we just need to figure it
+ // out for Windows and Linux.
+
+ String os = getOsName();
+ if (os.startsWith("win")) { //$NON-NLS-1$
+ // When WOW64 emulates a 32-bit environment under a 64-bit OS,
+ // it sets PROCESSOR_ARCHITEW6432 to AMD64 or IA64 accordingly.
+ // Ref: http://msdn.microsoft.com/en-us/library/aa384274(v=vs.85).aspx
+
+ String w6432 = System.getenv("PROCESSOR_ARCHITEW6432"); //$NON-NLS-1$
+ if (w6432 != null && w6432.indexOf("64") != -1) { //$NON-NLS-1$
+ return "x86_64"; //$NON-NLS-1$
+ }
+ } else if (os.startsWith("linux")) { //$NON-NLS-1$
+ // Let's try the obvious. This works in Ubuntu and Debian
+ String s = System.getenv("HOSTTYPE"); //$NON-NLS-1$
+
+ s = sanitizeOsArch(s);
+ if (s.indexOf("86") != -1) {
+ arch = s;
+ }
+ }
+ }
+
+ return arch;
+ }
+
+ /**
+ * Returns the version of the OS version if it is defined as X.Y, or null otherwise.
* <p/>
* Example of returned versions can be found at http://lopica.sourceforge.net/os.html
* <p/>
* This method removes any exiting micro versions.
*/
- private static String getVersion() {
+ private static String getOsVersion() {
Pattern p = Pattern.compile("(\\d+)\\.(\\d+).*"); //$NON-NLS-1$
String osVers = System.getProperty("os.version"); //$NON-NLS-1$
Matcher m = p.matcher(osVers);
if (m.matches()) {
- return m.group(1) + "." + m.group(2); //$NON-NLS-1$
+ return m.group(1) + '.' + m.group(2);
}
return null;
}
/**
+ * Detects and returns the JVM info: version + architecture.
+ * Examples: 1.4-ppc, 1.6-x86, 1.7-x86_64
+ */
+ private static String getJvmInfo() {
+ return getJvmVersion() + '-' + getJvmArch();
+ }
+
+ /**
+ * Returns the major.minor Java version.
+ * <p/>
+ * The "java.version" property returns something like "1.6.0_20"
+ * of which we want to return "1.6".
+ */
+ private static String getJvmVersion() {
+ String version = System.getProperty("java.version"); //$NON-NLS-1$
+
+ if (version == null || version.length() == 0) {
+ return "unknown"; //$NON-NLS-1$
+ }
+
+ Pattern p = Pattern.compile("(\\d+)\\.(\\d+).*"); //$NON-NLS-1$
+ Matcher m = p.matcher(version);
+ if (m.matches()) {
+ return m.group(1) + '.' + m.group(2);
+ }
+
+ // Unknown version. Send it as-is within a reasonable size limit.
+ if (version.length() > 8) {
+ version = version.substring(0, 8);
+ }
+ return version;
+ }
+
+ /**
+ * Detects and returns the JVM architecture.
+ * <p/>
+ * The HotSpot JVM has a private property for this, "sun.arch.data.model",
+ * which returns either "32" or "64". However it's not in any kind of spec.
+ * <p/>
+ * What we want is to know whether the JVM is running in 32-bit or 64-bit and
+ * the best indicator is to use the "os.arch" property.
+ * - On a 32-bit system, only a 32-bit JVM can run so it will be x86 or ppc.<br/>
+ * - On a 64-bit system, a 32-bit JVM will also return x86 since the OS needs
+ * to masquerade as a 32-bit OS for backward compatibility.<br/>
+ * - On a 64-bit system, a 64-bit JVM will properly return x86_64.
+ * <pre>
+ * JVM: Java 32-bit Java 64-bit
+ * Windows: x86 x86_64
+ * Linux: x86 x86_64
+ * Mac untested x86_64
+ * </pre>
+ */
+ private static String getJvmArch() {
+ String arch = System.getProperty("os.arch"); //$NON-NLS-1$
+ return sanitizeOsArch(arch);
+ }
+
+ private static String sanitizeOsArch(String arch) {
+ if (arch == null || arch.length() == 0) {
+ return "unknown"; //$NON-NLS-1$
+ }
+
+ if (arch.equalsIgnoreCase("x86_64") || //$NON-NLS-1$
+ arch.equalsIgnoreCase("ia64") || //$NON-NLS-1$
+ arch.equalsIgnoreCase("amd64")) { //$NON-NLS-1$
+ return "x86_64"; //$NON-NLS-1$
+ }
+
+ if (arch.length() == 4 && arch.charAt(0) == 'i' && arch.lastIndexOf("86") == 2) {
+ // Any variation of iX86 counts as x86 (i386, i486, i686).
+ return "x86"; //$NON-NLS-1$
+ }
+
+ if (arch.equalsIgnoreCase("PowerPC")) { //$NON-NLS-1$
+ return "ppc"; //$NON-NLS-1$
+ }
+
+ // Unknown arch. Send it as-is but protect against arbitrarily long values.
+ if (arch.length() > 32) {
+ arch = arch.substring(0, 32);
+ }
+ return arch;
+ }
+
+ /**
* Validate the supplied application version, and normalize the version.
* @param app to report
* @param version supplied by caller
@@ -210,25 +358,25 @@ public class SdkStatsService {
*/
private static String normalizeVersion(String app, String version) {
// Application name must contain only word characters (no punctuation)
- if (!app.matches("\\w+")) {
- throw new IllegalArgumentException("Bad app name: " + app);
+ if (!app.matches("\\w+")) { //$NON-NLS-1$
+ throw new IllegalArgumentException("Bad app name: " + app); //$NON-NLS-1$
}
// Version must be between 1 and 4 dotted numbers
- String[] numbers = version.split("\\.");
+ String[] numbers = version.split("\\."); //$NON-NLS-1$
if (numbers.length > 4) {
- throw new IllegalArgumentException("Bad version: " + version);
+ throw new IllegalArgumentException("Bad version: " + version); //$NON-NLS-1$
}
for (String part: numbers) {
- if (!part.matches("\\d+")) {
- throw new IllegalArgumentException("Bad version: " + version);
+ if (!part.matches("\\d+")) { //$NON-NLS-1$
+ throw new IllegalArgumentException("Bad version: " + version); //$NON-NLS-1$
}
}
// Always output 4 numbers, even if fewer were supplied (pad with .0)
StringBuffer normal = new StringBuffer(numbers[0]);
for (int i = 1; i < 4; i++) {
- normal.append(".").append(i < numbers.length ? numbers[i] : "0");
+ normal.append('.').append(i < numbers.length ? numbers[i] : "0"); //$NON-NLS-1$
}
return normal.toString();
}