Files
clang-p2996/lldb/source/Plugins/Language/Java/JavaLanguage.cpp
Kate Stone b9c1b51e45 *** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style.  This kind of mass change has
*** two obvious implications:

Firstly, merging this particular commit into a downstream fork may be a huge
effort.  Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit.  The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):

    find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
    find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;

The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.

Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit.  There are alternatives available that will attempt
to look through this change and find the appropriate prior commit.  YMMV.

llvm-svn: 280751
2016-09-06 20:57:50 +00:00

101 lines
3.2 KiB
C++

//===-- JavaLanguage.cpp ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// C Includes
#include <string.h>
// C++ Includes
#include <functional>
#include <mutex>
// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
// Project includes
#include "JavaFormatterFunctions.h"
#include "JavaLanguage.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Symbol/JavaASTContext.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
void JavaLanguage::Initialize() {
PluginManager::RegisterPlugin(GetPluginNameStatic(), "Java Language",
CreateInstance);
}
void JavaLanguage::Terminate() {
PluginManager::UnregisterPlugin(CreateInstance);
}
lldb_private::ConstString JavaLanguage::GetPluginNameStatic() {
static ConstString g_name("Java");
return g_name;
}
lldb_private::ConstString JavaLanguage::GetPluginName() {
return GetPluginNameStatic();
}
uint32_t JavaLanguage::GetPluginVersion() { return 1; }
Language *JavaLanguage::CreateInstance(lldb::LanguageType language) {
if (language == eLanguageTypeJava)
return new JavaLanguage();
return nullptr;
}
bool JavaLanguage::IsNilReference(ValueObject &valobj) {
if (!valobj.GetCompilerType().IsReferenceType())
return false;
// If we failed to read the value then it is not a nil reference.
return valobj.GetValueAsUnsigned(UINT64_MAX) == 0;
}
lldb::TypeCategoryImplSP JavaLanguage::GetFormatters() {
static std::once_flag g_initialize;
static TypeCategoryImplSP g_category;
std::call_once(g_initialize, [this]() -> void {
DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
if (g_category) {
const char *array_regexp = "^.*\\[\\]&?$";
lldb::TypeSummaryImplSP string_summary_sp(new CXXFunctionSummaryFormat(
TypeSummaryImpl::Flags().SetDontShowChildren(true),
lldb_private::formatters::JavaStringSummaryProvider,
"java.lang.String summary provider"));
g_category->GetTypeSummariesContainer()->Add(
ConstString("java::lang::String"), string_summary_sp);
lldb::TypeSummaryImplSP array_summary_sp(new CXXFunctionSummaryFormat(
TypeSummaryImpl::Flags().SetDontShowChildren(true),
lldb_private::formatters::JavaArraySummaryProvider,
"Java array summary provider"));
g_category->GetRegexTypeSummariesContainer()->Add(
RegularExpressionSP(new RegularExpression(array_regexp)),
array_summary_sp);
#ifndef LLDB_DISABLE_PYTHON
AddCXXSynthetic(
g_category,
lldb_private::formatters::JavaArraySyntheticFrontEndCreator,
"Java array synthetic children", ConstString(array_regexp),
SyntheticChildren::Flags().SetCascades(true), true);
#endif
}
});
return g_category;
}